public function index() { $qb = User::with('profile'); $qb->whereHas('roles', function ($query) { $query->where('slug', 'authenticated_user'); }); $members = $qb->paginate(50); return view('admin.members.index', ['members' => $members]); }
public function index() { $qb = User::with('profile'); $qb->whereHas('roles', function ($query) { $query->whereIn('slug', ['property_manager', 'normal_administrator']); }); $users = $qb->paginate(50); return view('admin.users.index', ['users' => $users]); }
/** * Run the migrations. * * @return void */ public function up() { Schema::table('users', function (Blueprint $table) { $table->boolean('manage_property')->default(FALSE)->nullable(); }); $qb = \GoProp\Models\User::with('profile'); $qb->whereHas('roles', function ($query) { $query->where('slug', 'agent'); }); $agents = $qb->get(); foreach ($agents as $agent) { $agent->manage_property = TRUE; $agent->save(); } }
public function index() { $qb = User::with('profile'); $qb->whereHas('roles', function ($query) { $query->where('slug', 'agent'); }); $user = Auth::user(); if ($user->is('property_manager')) { $qb->whereHas('profile', function ($query) use($user) { $query->where('province', $user->profile->province); }); } $agents = $qb->paginate(50); return view('admin.agents.index', ['agents' => $agents]); }