public function run()
 {
     // TestDummy::times(20)->create('App\Post');
     DB::table('schedule')->delete();
     $user = User::take(2)->get();
     $shows = Show::all();
     for ($day = 0; $day <= 6; $day++) {
         for ($hour = 1; $hour <= 24; $hour++) {
             $idIndex = ($hour - 1) % 4 < 2 ? 0 : 1;
             $show = $shows->random();
             $slot = new TimeSlot(['show' => $show->id, 'dj' => $user[$idIndex]->id, 'day' => $day, 'hour' => $hour]);
             $slot->save();
         }
     }
 }
 /**
  * Reverse the migrations.
  *
  * @return void
  */
 public function down()
 {
     Schema::table('user', function (Blueprint $table) {
         $table->string('dj_name')->nullable();
         $table->string('picture')->default('default.jpg');
         $table->boolean('active')->default(false);
     });
     $djs = DJ::all();
     foreach ($djs as $dj) {
         $user = User::find($dj->id);
         if ($user != null) {
             $user->fill(['dj_name' => $dj->name, 'picture' => $dj->picture, 'active' => true]);
             $user->save();
         }
     }
     Schema::drop('djs');
 }
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     $users = User::all();
     $roles = Role::all();
     $normalRole = $roles->where('name', 'user')->first();
     $editorRole = $roles->where('name', 'admin')->first();
     $adminRole = $roles->where('name', 'super_admin')->first();
     $users->each(function ($user) use($normalRole, $editorRole, $adminRole) {
         if ($user->role->id != $normalRole->id && $user->role->id != $adminRole->id) {
             $user->role()->associate($editorRole);
             $user->save();
         }
     });
     $editorRole->name = 'editor';
     $editorRole->description = 'Content Editor';
     $editorRole->save();
     $adminRole->name = 'admin';
     $adminRole->description = 'Administrator';
     $adminRole->save();
     $ids = [$normalRole->id, $editorRole->id, $adminRole->id];
     DB::table('user_roles')->whereNotIn('id', $ids)->delete();
 }
示例#4
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function delete($id)
 {
     $user = User::findOrFail($id);
     File::delete(public_path() . '/img/djs/' . $user->picture);
     User::destroy($id);
     return redirect()->route('admin.users.index')->with('success', 'User Deleted!');
 }
示例#5
0
 /**
  * Create a new user instance after a valid registration.
  *
  * @param  array  $data
  * @return User
  */
 public function create(array $data)
 {
     return User::create(['name' => $data['name'], 'email' => $data['email'], 'password' => bcrypt($data['password'])]);
 }