|
|
|
@ -11,7 +11,7 @@ class Customer extends Model |
|
|
|
|
protected $table = 'se_customers'; |
|
|
|
|
protected $fillable = ['id', 'name', 'phone', 'email', 'grade', 'msg', 'agent_id', 'created_at', 'created_by', 'updated_at', 'updated_by', 'deleted_at']; |
|
|
|
|
protected $dates = ['deleted_at']; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// protected static function newFactory() |
|
|
|
|
// { |
|
|
|
|
// return \Modules\Agents\Database\factories\CustomerFactory::new(); |
|
|
|
@ -23,7 +23,8 @@ class Customer extends Model |
|
|
|
|
* @param mixed $phone |
|
|
|
|
* @return mixed |
|
|
|
|
*/ |
|
|
|
|
public function scopeByPhone($query, $phone){ |
|
|
|
|
public function scopeByPhone($query, $phone) |
|
|
|
|
{ |
|
|
|
|
return $query->where('phone', $phone); |
|
|
|
|
} |
|
|
|
|
/** |
|
|
|
@ -32,7 +33,8 @@ class Customer extends Model |
|
|
|
|
* @param mixed $agentId |
|
|
|
|
* @return mixed |
|
|
|
|
*/ |
|
|
|
|
public function scopeNotAgent($query, $agentId){ |
|
|
|
|
public function scopeNotAgent($query, $agentId) |
|
|
|
|
{ |
|
|
|
|
return $query->where('agent_id', '<>', $agentId); |
|
|
|
|
} |
|
|
|
|
/** |
|
|
|
@ -41,7 +43,16 @@ class Customer extends Model |
|
|
|
|
* @param mixed $agentId |
|
|
|
|
* @return mixed |
|
|
|
|
* **/ |
|
|
|
|
public function scopeInAgent($query, $agentId){ |
|
|
|
|
public function scopeInAgent($query, $agentId) |
|
|
|
|
{ |
|
|
|
|
return $query->where('agent_id', '=', $agentId); |
|
|
|
|
} |
|
|
|
|
public function scopeSearch($query, $searchKey) |
|
|
|
|
{ |
|
|
|
|
return $query->where(function ($query) use ($searchKey) { |
|
|
|
|
$query->where('name', 'LIKE', '%' . $searchKey . '%') |
|
|
|
|
->orWhere('phone', 'LIKE', '%' . $searchKey . '%') |
|
|
|
|
->orWhere('email', 'LIKE', '%' . $searchKey . '%'); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|