Esempio n. 1
0
 public function store(AttachmentRequest $request, Attachment $attachment)
 {
     if (!Helper::getMode()) {
         return redirect()->back()->withErrors(config('constants.DISABLE_MESSAGE'));
     }
     $filename = uniqid();
     $data = $request->all();
     if ($request->hasFile('file')) {
         $extension = $request->file('file')->getClientOriginalExtension();
         $file = $request->file('file')->move('uploads/attachment_files/', $filename . "." . $extension);
         $data['file'] = $filename . "." . $extension;
     }
     $data['user_id'] = Auth::user()->id;
     $attachment->fill($data);
     $attachment->save();
     $activity = 'Attached a file on a ' . $request->input('belongs_to');
     Activity::log($activity);
     return redirect()->back()->withSuccess(config('constants.SAVED'));
 }