Пример #1
0
 public function destroy(Attachment $attachment)
 {
     if (!Helper::getMode()) {
         return redirect()->back()->withErrors(config('constants.DISABLE_MESSAGE'));
     }
     if ($attachment->user_id != Auth::user()->id && !Entrust::hasRole('admin')) {
         return redirect()->back()->withErrors(config('constants.INVALID_LINK'));
     }
     $belongs_to = $attachment->belongs_to;
     File::delete('uploads/attachment_files/' . $attachment->file);
     $attachment->delete($id);
     $activity = 'Deleted a file on a ' . $belongs_to;
     Activity::log($activity);
     return redirect()->back()->withSuccess(config('constants.DELETED'));
 }
Пример #2
0
 /**
  * Created By Dara on 21/2/2016
  * delete attachment
  */
 public function attachmentDelete(Session $session, Attachment $attachment, Request $request)
 {
     $user = $this->user;
     if (Storage::disk('local')->exists($attachment->file)) {
         Storage::delete($attachment->file);
     } else {
         //not exists
         die('not exists');
     }
     $attachment->delete();
     return ['msg' => trans('users.attachmentDeleted')];
 }