예제 #1
0
파일: Role.php 프로젝트: smhillin/p4
 public static function rolesForDropdown()
 {
     #get all clients
     $roles = \p4\Role::orderBy('name', 'ASC')->get();
     #build array for client dropdown
     $roles_for_dropdown = [];
     $roles_for_dropdown[0] = 'Choose a role';
     foreach ($roles as $role) {
         $roles_for_dropdown[$role->id] = $role->name;
     }
     return $roles_for_dropdown;
 }
예제 #2
0
 /**
  * Run the User table database seeds.
  *
  * @return void
  */
 public function run()
 {
     $client_id = \p4\Client::where('name', '=', 'Roth Rugs')->pluck('id')->first();
     $role_id = \p4\Role::where('name', '=', 'Agency')->pluck('id')->first();
     DB::table('users')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), "name" => "Jill", "email" => "*****@*****.**", "password" => bcrypt("helloworld"), "client_id" => $client_id, "role_id" => $role_id]);
     $client_id = \p4\Client::where('name', '=', 'Uptown Realty')->pluck('id')->first();
     $role_id = \p4\Role::where('name', '=', 'Client')->pluck('id')->first();
     DB::table('users')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), "name" => "Jamal", "email" => "*****@*****.**", "password" => bcrypt("helloworld"), "client_id" => $client_id, "role_id" => $role_id]);
     $client_id = \p4\Client::where('name', '=', 'Uptown Realty')->pluck('id')->first();
     $role_id = \p4\Role::where('name', '=', 'Agency')->pluck('id')->first();
     DB::table('users')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), "name" => "Shaun", "email" => "*****@*****.**", "password" => bcrypt("helloworld"), "client_id" => $client_id, "admin" => "1", "role_id" => $role_id]);
 }
예제 #3
0
 public function addUser(Request $request)
 {
     $messages = ['client.not_in' => "You have to choose a client.", 'role.not_in' => "You have to choose a role."];
     $this->validate($request, ['user_name' => 'required|max:25', 'user_email' => 'required', 'client' => 'not_in:0', 'role' => 'not_in:0'], $messages);
     $admin = \Request::get('admin');
     $client_id = \Request::get('client');
     $role_id = \Request::get('role');
     $client = \p4\Client::find($client_id);
     $role = \p4\Role::find($role_id);
     $user = new \p4\User();
     if ($admin == 'true') {
         $user->admin = '1';
     }
     $user->name = \Request::get('user_name');
     $user->email = \Request::get('user_email');
     $user->client_id = $client->id;
     $user->role_id = $role->id;
     $user->role()->associate($role);
     $user->client()->associate($client);
     $user->save();
     \Session::flash('message', 'User has been successfully created');
     return redirect()->back();
 }