コード例 #1
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Role::create(['name' => 'Super Administrador']);
     Role::create(['name' => 'Administrador']);
     Role::create(['name' => 'Proveedor']);
     Role::create(['name' => 'Cliente']);
     Role::create(['name' => 'Agente']);
     Role::create(['name' => 'Analista']);
 }
コード例 #2
0
 function searchUsers(Request $request)
 {
     $search = $request->input('search');
     $rows = User::with('role')->where(function ($query) use($search) {
         $query->Where('name', 'like', '%' . $search . '%')->orWhere('last_name', 'like', '%' . $search . '%')->orWhere('email', '=', $search)->orWhere('second_name', 'like', '%' . $search . '%')->orWhere('second_last_name', 'like', '%' . $search . '%')->orWhere('identification', '=', $search);
     })->sorted()->paginate(10);
     $users = Table::create($rows, ['name' => 'Nombre', 'email' => 'Email']);
     $users->addColumn('role_id', 'Rol', function ($model) {
         return $model->role()->first()->name;
     });
     $users->addColumn('id', 'Acciones', function ($model) {
         $id = $model->id;
         return '<a href="' . route('user', ['id' => $id]) . '"> ver </a>';
     });
     $roleName = $this->roleName;
     $routeSearch = 'searchUser';
     $roles = Role::whereRaw('id in (1,2,4,5)')->get();
     return view('back.users', compact('users', 'roleName', 'routeSearch', 'search', 'roles'));
 }
コード例 #3
0
 function user($id)
 {
     $user = User::findOrFail($id);
     $roles = Role::all();
     return view('back.userEdit', compact('user', 'roles'));
 }
コード例 #4
0
 public function __construct()
 {
     $this->roleName = Role::all();
 }