/**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     BackgroundImage::truncate();
     Schema::table('background_images', function ($table) {
         $table->dropColumn('file');
         $table->integer('file_id')->unsigned();
         $table->foreign('file_id')->references('id')->on('files');
     });
 }
コード例 #2
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy(BackgroundImage $backgroundImage)
 {
     if (!Auth::user()->can('administrate-background_images')) {
         abort(401, 'User does not have permission to delete background images');
     }
     $backgroundImage->delete();
 }
コード例 #3
0
ファイル: BackgroundImage.php プロジェクト: dwoodard/IserveU
 /**
  * @param boolean checks that the user is an admin, returns false if not. Automatically sets the closing time to be one week out from now.
  */
 public function setActiveAttribute($value)
 {
     if (!Auth::user()->can('administrate-background_images')) {
         return false;
     }
     $this->attributes['active'] = $value;
     if ($value) {
         //Setting it  active
         $last = BackgroundImage::whereNotNull('display_date')->active()->orderBy('display_date', 'desc')->first();
         if (!$last) {
             $last = Carbon::yesterday();
         } else {
             $last = $last->display_date;
         }
         $this->attributes['display_date'] = $last->add(new \DateInterval('P1D'))->format('Y-m-d');
     } else {
         //Setting it inactive
         $this->attributes['display_date'] = null;
     }
     return true;
 }