/**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     $admin = new \App\Models\Users\User(["email" => "*****@*****.**", "password" => bcrypt("admin")]);
     $admin->save();
     $admin->roles()->save(Role::find(1));
     $student = new \App\Models\Users\User(["email" => "*****@*****.**", "password" => bcrypt("student")]);
     $student->save();
     $student->roles()->save(Role::find(2));
 }
예제 #2
0
파일: Role.php 프로젝트: Omen-/ups-plasma
 public static function usersof($role)
 {
     return Role::where("title", "student")->get()->first()->users;
 }
예제 #3
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     //
     $role = Role::find($id);
     if ($role->delete()) {
         return response()->json(['success' => TRUE]);
     }
 }
예제 #4
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     return view('admin.index.student', ["students" => Role::usersof('student'), "trainings" => Training::all()]);
 }
예제 #5
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     //
     if (!Entrust::can('user-update')) {
         return redirect('');
     }
     $this->data['sub_title'] = 'Edit User';
     $this->data['user'] = User::find($id);
     $this->data['roles'] = Role::lists('name', 'id');
     return view('backend.user.edit', $this->data);
 }
예제 #6
0
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, $id)
 {
     $rules = array('role' => 'required', 'email' => 'required|email', 'password' => '', 'lastname' => 'required', 'firstname' => 'required');
     $validator = \Validator::make(\Input::all(), $rules);
     if ($validator->fails()) {
         return redirect()->back()->withInput()->withErrors($validator);
     }
     $user = User::find($id);
     if ($request->has('password')) {
         $user->password = bcrypt($request->input('password'));
     }
     $user->email = $request->input('email');
     $user->last_name = $request->input('lastname');
     $user->first_name = $request->input('firstname');
     $user->roles()->detach();
     $user->roles()->save(Role::find($request->input('role')));
     $user->save();
     return redirect()->back();
 }