/**
  * 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));
 }
Esempio n. 2
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]);
     }
 }
Esempio n. 3
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();
 }