first commit
This commit is contained in:
98
app/Models/PropertyExecutive.php
Normal file
98
app/Models/PropertyExecutive.php
Normal file
@@ -0,0 +1,98 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
class PropertyExecutive extends BaseModel
|
||||
{
|
||||
/**
|
||||
* The database table used by the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'property_executive';
|
||||
protected $appends = ['view_full_phone', 'view_full_mobile', 'view_full_fax'];
|
||||
|
||||
const CREATED_AT = 'created_at';
|
||||
const UPDATED_AT = 'updated_at';
|
||||
|
||||
protected $dateFormat = 'U';
|
||||
protected $guarded = [];
|
||||
const CHARACTER_LENGTH = 6;
|
||||
|
||||
/**
|
||||
* The attributes excluded from the model's JSON form.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $hidden = [];
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
|
||||
public function getViewFullPhoneAttribute()
|
||||
{
|
||||
try {
|
||||
$response = null ;
|
||||
if($this->phone == null || $this->phone == "" || strlen( $this->phone) < self::CHARACTER_LENGTH){
|
||||
return null ;
|
||||
}
|
||||
if($this->phone_code){
|
||||
$response = strpos($this->phone_code, '+') === false ? '+'.$this->phone_code.$this->phone : $this->phone_code.$this->phone;
|
||||
}else{
|
||||
$response = strpos($this->phone, '+') === false ? '+'.$this->phone : $this->phone;
|
||||
}
|
||||
return $response;
|
||||
} catch (Exception $e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public function getViewFullMobileAttribute()
|
||||
{
|
||||
try {
|
||||
$response = null ;
|
||||
if($this->mobile == null || $this->mobile == "" || strlen( $this->mobile) < self::CHARACTER_LENGTH){
|
||||
return null ;
|
||||
}
|
||||
if($this->mobile_code){
|
||||
$response = strpos($this->mobile_code, '+') === false ? '+'.$this->mobile_code.$this->mobile : $this->mobile_code.$this->mobile;
|
||||
}else{
|
||||
$response = strpos($this->mobile, '+') === false ? '+'.$this->mobile : $this->mobile;
|
||||
}
|
||||
return $response;
|
||||
} catch (Exception $e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function getViewFullFaxAttribute()
|
||||
{
|
||||
try {
|
||||
$response = null ;
|
||||
if($this->fax == null || $this->fax == "" || strlen( $this->fax) < self::CHARACTER_LENGTH){
|
||||
return null ;
|
||||
}
|
||||
if($this->fax_code){
|
||||
$response = strpos($this->fax_code, '+') === false ? '+'.$this->fax_code.$this->fax : $this->fax_code.$this->fax;
|
||||
}else{
|
||||
$response = strpos($this->fax, '+') === false ? '+'.$this->fax : $this->fax;
|
||||
}
|
||||
return $response;
|
||||
} catch (Exception $e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public function executiveType()
|
||||
{
|
||||
return $this->hasOne('App\Models\PropertyExecutiveType','id', 'executive_type_id')->select('id', 'name', 'language_key', 'icon');
|
||||
}
|
||||
|
||||
|
||||
/*public function PropertyContentCategories()
|
||||
{
|
||||
return $this->hasMany('App\Models\PropertyContentCategory','id');
|
||||
}*/
|
||||
}
|
||||
Reference in New Issue
Block a user