Changed account search to user search, show connection charges on invoice for pending services
This commit is contained in:
41
app/User.php
41
app/User.php
@@ -104,7 +104,7 @@ class User extends Authenticatable
|
||||
return $this->hasMany(static::class,'parent_id','id');
|
||||
}
|
||||
|
||||
/** Attributes **/
|
||||
/** ATTRIBUTES **/
|
||||
|
||||
public function getActiveDisplayAttribute($value)
|
||||
{
|
||||
@@ -203,13 +203,50 @@ class User extends Authenticatable
|
||||
$this->notify((new ResetPasswordNotification($token))->onQueue('high'));
|
||||
}
|
||||
|
||||
/** Scopes **/
|
||||
/** SCOPES */
|
||||
|
||||
public function scopeActive()
|
||||
{
|
||||
return $this->where('active',TRUE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Search for a record
|
||||
*
|
||||
* @param $query
|
||||
* @param string $term
|
||||
* @return
|
||||
*/
|
||||
public function scopeSearch($query,string $term)
|
||||
{
|
||||
// Build our where clause
|
||||
// First Name, Last name
|
||||
if (preg_match('/\ /',$term)) {
|
||||
list($fn,$ln) = explode(' ',$term,2);
|
||||
|
||||
$query->where(function($query1) use ($fn,$ln,$term) {
|
||||
$query1->where(function($query2) use ($fn,$ln) {
|
||||
return $query2
|
||||
->where('firstname','like','%'.$fn.'%')
|
||||
->where('lastname','like','%'.$ln.'%');
|
||||
});
|
||||
});
|
||||
|
||||
} elseif (is_numeric($term)) {
|
||||
$query->where('id','like','%'.$term.'%');
|
||||
|
||||
} elseif (preg_match('/\@/',$term)) {
|
||||
$query->where('email','like','%'.$term.'%');
|
||||
|
||||
} else {
|
||||
$query
|
||||
->Where('firstname','like','%'.$term.'%')
|
||||
->orWhere('lastname','like','%'.$term.'%');
|
||||
}
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the user is an admin of the account with $id
|
||||
*
|
||||
|
Reference in New Issue
Block a user