Ejemplo n.º 1
0
 /**
  * Scope queries to territories that are being worked on by the logged in user
  *
  * @param  [type] $query [description]
  * @return [type]        [description]
  */
 public function scopeMyMaps($query)
 {
     $user = Auth::user();
     //dd($user);
     //$query->whereNotNull('finished_on');
     $query->whereHas('users', function ($q) use($user) {
         $q->where('finished_on', NULL)->where('user_id', $user->id);
     });
 }
Ejemplo n.º 2
0
 /**
  * [scopeSearchHasRelated description]
  * @param  [type] $query [description]
  * @param  [type] $data  [description]
  * @return [type]        [description]
  */
 public function scopeSearchHasRelated($query, $data)
 {
     $query->whereHas($data['related'], function ($q) use($data) {
         $q->where($data['field'], $data['sign'], $data['search']);
     });
 }