Exemplo n.º 1
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function edit(int $id)
 {
     $setData['groupUser'] = GroupUser::where('status', 1)->get();
     $setData['data'] = User::where('id', $id)->get();
     $setData['actionLink'] = action('Admin\\UserController@update', ['id' => $id]);
     if ($setData['data']) {
         $setData['action'] = 'edit';
         return View::make('admin.user.add_edit', $setData);
     } else {
         return abort(404);
     }
 }
Exemplo n.º 2
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $faker = Faker\Factory::create();
     // seed group_user
     foreach (range(1, 6) as $index) {
         GroupUser::create(['group_name' => $faker->safeColorName, 'sort_order' => $index, 'status' => rand(0, 1)]);
     }
     // seed user
     $group_user = GroupUser::all();
     foreach (range(0, 20) as $index) {
         User::create(['group_id' => $group_user->shuffle()->first()->id, 'username' => 'test' . $index . '@col.com', 'password' => Hash::make('1234'), 'first_name' => $faker->firstName, 'last_name' => $faker->lastName, 'position' => $faker->companySuffix, 'department' => $faker->company, 'status' => $index == 0 ? 1 : rand(0, 1)]);
     }
 }
 public function destroy(int $id) : int
 {
     return GroupUser::where('id', $id)->first()->delete();
 }