public function image(UploadedFile $file = null, Attachment $attachment = null) { if ($file == null) { return; } if ($attachment == null) { $attachment = new Attachment(); } // dd($file->getClientOriginalExtension()); $name = time() . '.' . $file->getClientOriginalExtension(); $file->move(public_path() . $this->path . 'attachments/', $name); $attachment->name = $name; $attachment->path = $attachment->getUploadPath() . $name; //$attachment->user_id = Auth::user()->id; $attachment->save(); return $attachment; }