public function sendNotificationEmail(Group $group, User $user) { if ($user->verified == 1) { // Establish timestamp for notifications from membership data (when was an email sent for the last time?) $membership = \App\Membership::where('user_id', '=', $user->id)->where('group_id', "=", $group->id)->firstOrFail(); $last_notification = $membership->notified_at; // find unread discussions since timestamp $discussions = QueryHelper::getUnreadDiscussionsSince($user->id, $group->id, $membership->notified_at); // find new files since timestamp $files = \App\File::where('updated_at', '>', $membership->notified_at)->where('group_id', "=", $group->id)->get(); // find new members since timestamp $users = QueryHelper::getNewMembersSince($user->id, $group->id, $membership->notified_at); // find future actions until next 2 weeks, this is curently hardcoded... TODO use the mail sending interval to determine stop date $actions = \App\Action::where('start', '>', Carbon::now())->where('stop', '<', Carbon::now()->addWeek()->addWeek())->where('group_id', "=", $group->id)->orderBy('start')->get(); // we only trigger mail sending if a new action has been **created** since last notfication email. // BUT we will send actions for the next two weeks in all cases, IF a mail must be sent $actions_count = \App\Action::where('created_at', '>', $membership->notified_at)->where('group_id', "=", $group->id)->count(); // in all cases update timestamp $membership->notified_at = Carbon::now(); $membership->save(); // if we have anything, build the message and send // removed that : or count($users) > 0 // because we don't want to be notified just because there is a new member if (count($discussions) > 0 or count($files) > 0 or $actions_count > 0) { Mail::send('emails.notification', ['user' => $user, 'group' => $group, 'membership' => $membership, 'discussions' => $discussions, 'files' => $files, 'users' => $users, 'actions' => $actions, 'last_notification' => $last_notification], function ($message) use($user, $group) { $message->from(env('MAIL_NOREPLY', '*****@*****.**'), env('APP_NAME', 'Laravel'))->to($user->email)->subject('[' . env('APP_NAME') . '] ' . trans('messages.news_from_group_email_subject') . ' "' . $group->name . '"'); }); return true; } return false; } }
/** * Display a listing of the resource. * * @return Response */ public function displayVolunteer() { //Find all File $files = File::where('type', File::VOLUNTEER)->get(); //Send the your to the index page return view('volunteer.file.index', compact('files')); }
private function handleFile($root_folder, $f) { /* The "black" identifier is just an abstract reference, not a real file: we skip analysis for it */ if ($f == 'black') { return true; } /* This is to manage eventual files embedded multiple times: we track only one, and eventually will substitute once all occurrences in the mlt file when required */ $path = $this->guessPath($root_folder, $f); $test_count = File::where('project_id', '=', $this->project->id)->where('original_path', '=', $path)->first(); if ($test_count != null) { $test_count->references = $test_count->references + 1; $test_count->save(); return true; } $file = new File(); $file->project_id = $this->project->id; $file->filename = basename($f); $file->original_path = $path; $file->references = 1; $ret = $file->testReach(); $file->save(); return $ret; }
public function traverseInsideFolder($folderPath = 'root', $token_id) { // $token = User::find($this->usrId)->tokens->find($token_id); $root = File::where('token_id', $token_id)->where('path', $folderPath)->first(); $file = $root->children()->get(); return $file; }
public function IdentitasHandle($req, $id) { // PDF tidak di update / melalui form // Gagal mengupload file PDF // Sukses Mengupload DOkumen $temp_iden_pesan = ['error' => ['user' => 'Peringatan : File PDF tidak di atur dengan benar !', 'sistem' => 'Terjadi kesalahan upload File PDf '], 'succes' => ['store' => 'Sukses mengupload Dokumen PDF ', 'update' => 'Sukses mengupdate Dokumen PDF ']]; $temp_file_pesan = ['error' => '', 'succes' => '']; // dd($req->all()); $file = $req->file('gambar'); if ($file and $file->getClientMimeType() == 'application/pdf') { // dd($file); $extension = $file->getClientOriginalExtension(); $FileIdentity = File::where('dokumen_id', $id); // Update if (count($FileIdentity->get()->toArray())) { $this->result['identitas']['lama'] = $FileIdentity->get()->toArray(); //delete file $data_for_update = ['mime' => $file->getClientMimeType(), 'original_filename' => $file->getClientOriginalName(), 'filename' => $file->getFilename() . '.' . $extension]; if ($FileIdentity->update($update)) { $this->result['identitas']['baru'] = $FileIdentity->get()->toArray(); $this->{$result}['pesan'] = $temp_iden_pesan['succes']['update']; // proses storage if (\Storage::delete($FileIdentity->get()->toArray()[0]['filename']) && \Storage::disk('local')->put($file->getFilename() . '.' . $extension, \File::get($file))) { $this->file_pesan['succes'] = $temp_file_pesan['succes']; return true; } else { $this->file_pesan['error'] = $temp_file_pesan['error']; return false; } return true; } else { return false; } } else { // echo " new file"; $new_dokument = new File(); $new_dokument->dokumen_id = $id; $new_dokument->mime = $file->getClientMimeType(); $new_dokument->original_filename = $file->getClientOriginalName(); $new_dokument->filename = $file->getFilename() . '.' . $extension; //new identitas if ($new_dokument->save()) { // new pdf if (\Storage::disk('local')->put($file->getFilename() . '.' . $extension, \File::get($file))) { return true; } $this->{$result}['pesan'] = $temp_iden_pesan['succes']['store']; return true; } else { $this->{$result}['pesan'] = $temp_iden_pesan['error']['sistem']; return false; } } // } } else { $this->{$result}['pesan'] = $temp_iden_pesan['error']['user']; return false; } }
public static function checkFilePath($data) { $var = \App\File::where('file_path', '=', $data)->first(); if ($var) { $var = $var->file_path; return $var; } }
public function getHistoryEvents() { $banners = File::where('img_type', 'banner')->where("created_at", "like", $this->year . "%")->get(); if ($banners->count() == 0) { $banners = ""; } return view('introduction.history', compact('banners'))->with('year', $this->curYear); }
public function getServer() { $server = 0; while (File::where('server', '=', $server)->sum('size') >= 1500000000) { $server++; } return $server; }
/** * Display the specified resource. * * @param int $id * @return Response */ public function show($id) { // $files = File::where('created_by', Auth::user()->id)->where('folder_id', $id)->get(); $folders = Folder::where('created_by', Auth::user()->id)->get(); $folder = Folder::findOrFail($id); return view('view-folder')->with('folder', $folder)->with('folders', $folders)->with('files', $files); }
public function getFileById($id = 0) { /** @var FileModel $file */ $file = FileModel::where('id', $id)->first(); if (!$file) { throw new NotFoundException(NotFoundException::FileNotFound); } return $this->buildResponse(trans('api.file.get.success'), $file); }
public function getSubmissionGuidelines() { $submission = CMS::where("name", "submission")->where("type", "paper")->where("created_at", "like", $this->year . "%")->first(); $paper = File::where('img_type', "paper")->where("created_at", "like", $this->year . "%")->first(); $poster = File::where('img_type', "poster")->where("created_at", "like", $this->year . "%")->first(); $subFiles = File::where('img_type', 'submission')->where("created_at", "like", $this->year . "%")->get(); $journal = File::where('img_type', 'journal')->where("created_at", "like", $this->year . "%")->get(); return view('paper.submission', compact(['paper', 'poster', 'submission', 'subFiles', 'journal']))->with('year', $this->curYear); }
public function indexPath($path, Category $category, $parent = null) { $directory = new \DirectoryIterator($path); $dev = stat($path)[0]; $files = []; $directories = []; foreach ($directory as $file) { if ($file->isDot() || !$file->isReadable()) { continue; } if ($file->isFile()) { $node = $file->getInode(); if ($node <= 0 || $node == false) { continue; } $f = File::where('dev', $dev)->where('inode', $node)->get(); if (is_null($f) || !count($f)) { $f = new File(['dev' => $dev, 'inode' => $node]); } else { $f = $f->first(); } $f->filename = $file->getFilename(); $f->size = $file->getSize(); if ($f->isDirty()) { $f->save(); } $files[] = $f; } else { if ($file->isDir()) { $directories[] = $file->getPathname(); } } } if (count($files) > 0 || count($directories) > 0) { $pathFile = new SplFileInfo($path); $item = Item::where('path', $pathFile->getRealPath())->get(); if (is_null($item) || !count($item)) { $item = $category->items()->create(['title' => $pathFile->getFilename(), 'path' => $pathFile->getRealPath(), 'parent_id' => $parent]); } else { $item = $item->first(); } // Files foreach ($files as $ob) { $ob->item()->associate($item); $ob->save(); } /** * Directories * @todo Improve recursion */ foreach ($directories as $dir) { $this->indexPath($dir, $category, $item->id); } } }
public function download($orderId, $filename) { $fileid = \App\File::where('filename', $filename)->first(); $orderItem = OrderItem::where('order_id', '=', $orderId)->where('file_id', $fileid->id)->first(); if (!$orderItem) { redirect('/failed'); } $entry = \App\File::where('filename', $filename)->first(); $file = Storage::disk('local')->get($entry->filename); return (new Response($file, 200))->header('Content-Type', $entry->mime); }
/** * Execute the console command. * * @return mixed */ public function handle() { $weekAgoUnix = time() - 86400 * 7; $weekAgo = date('Y-m-d H:i:s', $weekAgoUnix); $files = File::where('type', File::TYPE_TEMPORARY)->where('created_at', '<=', $weekAgo)->get(); foreach ($files as $file) { $name = $file->name; $file->delete(); unlink(storage_path('upload/' . $name)); $this->line('Deleted ' . $name); } }
public function index(Request $request) { if ($request->has('query')) { $query = $request->get('query'); // build a list of public groups and groups the user has access to $my_groups = Auth::user()->groups()->orderBy('name')->get(); $my_groups_id = []; // using this array we can adjust the queries after to only include stuff the user has // might be a good idea to find a clever way to build this array of groups id : foreach ($my_groups as $the_group) { $my_groups_id[$the_group->id] = $the_group->id; } $public_groups = \App\Group::where('group_type', \App\Group::OPEN)->get(); $public_groups_id = []; // using this array we can adjust the queries after to only include stuff the user has // might be a good idea to find a clever way to build this array of groups id : foreach ($public_groups as $the_group) { $public_groups_id[$the_group->id] = $the_group->id; } $allowed_groups = array_merge($my_groups_id, $public_groups_id); $groups = \App\Group::where('name', 'like', '%' . $query . '%')->orWhere('body', 'like', '%' . $query . '%')->orderBy('name')->get(); $users = \App\User::where('name', 'like', '%' . $query . '%')->orWhere('body', 'like', '%' . $query . '%')->orderBy('name')->with('groups')->get(); $discussions = \App\Discussion::where('name', 'like', '%' . $query . '%')->orWhere('body', 'like', '%' . $query . '%')->whereIn('group_id', $allowed_groups)->orderBy('updated_at', 'desc')->with('group')->get(); $actions = \App\Action::where('name', 'like', '%' . $query . '%')->orWhere('body', 'like', '%' . $query . '%')->whereIn('group_id', $allowed_groups)->with('group')->orderBy('updated_at', 'desc')->get(); $files = \App\File::where('name', 'like', '%' . $query . '%')->whereIn('group_id', $allowed_groups)->with('group')->orderBy('updated_at', 'desc')->get(); $comments = \App\Comment::where('body', 'like', '%' . $query . '%')->with('discussion.group')->orderBy('updated_at', 'desc')->get(); // set in advance which tab will be active on the search results page $groups->class = ''; $discussions->class = ''; $actions->class = ''; $users->class = ''; $comments->class = ''; $files->class = ''; // the order of those ifs should match the order of the tabs on the results view :-) if ($groups->count() > 0) { $groups->class = 'active'; } elseif ($discussions->count() > 0) { $discussions->class = 'active'; } elseif ($actions->count() > 0) { $action->class = 'active'; } elseif ($users->count() > 0) { $users->class = 'active'; } elseif ($comments->count() > 0) { $comments->class = 'active'; } elseif ($files->count() > 0) { $files->class = 'active'; } return view('search.results')->with('groups', $groups)->with('users', $users)->with('discussions', $discussions)->with('files', $files)->with('comments', $comments)->with('actions', $actions)->with('query', $query); } }
public function removeFile($uri) { $this->storage = $this->uriToStorage($uri); $link = $this->uriToUrl($uri); if ($this->storage == 's3') { $this->removeFileFromS3($link); } else { $link = str_replace(url('/') . '/', '', $link); unlink($link); } $file = File::where('file_path', $uri)->first(); DB::table('fileables')->where('file_id', $file->id)->delete(); $file->delete(); }
/** * Show a file. * * @return response */ public function show($shareId) { $file = File::where('share_id', $shareId)->select('mime', 'password', 'user_id', 'id', 'file_name')->firstOrFail(); $this->checkPassword($file); $path = 'application/storage/uploads/' . ($file->user_id ? $file->user_id : 'no-auth') . '/' . $file->id . '/' . $file->file_name; if (Storage::exists($path)) { $mime = $file->mime; $type = explode('/', $mime)[0]; if ($type === 'image' && Input::get('w') && Input::get('h')) { $file = $this->resizeImage($path, $file->extension); } elseif ($this->shouldStream($mime, $type)) { return $this->streamVideo($path, $mime, $file->file_name); } else { $file = Storage::get($path); } return response($file, 200, ['Content-Type' => $mime]); } abort(404); }
function getName() { $chars = array_flatten([range('a', 'z'), range('A', 'Z'), range(0, 9)]); $params = http_build_query(['c' => implode('', $chars), 'l' => 4]); $name = ''; while (true) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'http://g.iili.li'); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $params); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $name = curl_exec($ch); curl_close($ch); $file = File::where('name', '=', $name); if (!$file->exists()) { break; } } return $name; }
public function getChartingImages($search_string = "") { $images = new Collection(); $files = []; if ($search_string) { $files = File::where('patient_id', $this->id)->where(function ($query) use($search_string) { $query->where('name', 'LIKE', '%' . $search_string . '%')->orWhere('description', 'LIKE', '%' . $search_string . '%'); })->get(); } else { $files = $this->files; } foreach ($files as $f) { if ($f->icon->type == 'Image') { $images->push($f); } } return $images; }
public function postPoster(Request $request) { $poster = File::where('img_type', "poster")->where("created_at", "like", $this->year . "%")->first(); $file = $request->file('poster'); if ($request->hasFile('poster')) { if ($poster == null) { $sub = new File(); $sub->name = Carbon::now()->timestamp . '_' . $file->getClientOriginalName(); $sub->original_name = $file->getClientOriginalName(); $sub->description = "Poster template"; $sub->type = $file->getClientOriginalExtension(); $sub->img_type = "poster"; $sub->save(); } else { $sub = File::where('img_type', "poster")->where("created_at", "like", $this->year . "%")->first(); $sub->name = Carbon::now()->timestamp . '_' . $file->getClientOriginalName(); $sub->original_name = $file->getClientOriginalName(); $sub->description = "Poster template"; $sub->type = $file->getClientOriginalExtension(); $sub->img_type = "poster"; $sub->save(); } $file->move('assets/files', Carbon::now()->timestamp . '_' . $file->getClientOriginalName()); return back()->with('success', 'file'); } else { return "error upload"; } }
public function getHistoryEvent() { $banners = File::where('img_type', 'banner')->where("created_at", "like", date("Y") . "%")->get(); if ($banners->count() == 0) { $banners = ""; } return view('frontend/introduction/history_event.index', compact('banners'))->with('year', $this->year); }
public function getTenFileAttribute($id) { $tenfile = File::where('id', $id)->value('name'); return $tenfile; }
public function getPaginated() { return $this->file->where('type', self::FILE_TYPE_VIDEO)->simplePaginate(9); }
public function getSubmission() { $image = File::where('img_type', 'submission')->where("created_at", "like", $this->year . "%")->get(); return view('admin.image_management.submission', compact('image')); }
public function getGallery() { $image = File::where('img_type', 'gallery')->where("created_at", "like", $this->year . "%")->get(); return view('asialics_indonesia.gallery', compact('image'))->with('year', $this->curYear); }
public function handleFile($id, Request $req) { $action = $req->input('_action'); if ($action == 'updateFile') { $params = ["client_report" => $req['client_report'], "intern_report" => $req['intern_report']]; $ok = File::where('id', $id)->update($params); if ($ok) { $stamp = date('d/m/Y, H:i:s'); return ['status' => "success", "stamp" => $stamp]; } else { return ['status' => "error"]; } } else { if ($action == 'calculateInvoice') { $response = Order::calculateInvoice($req); if (isset($req['shifting_amount'])) { $params["shifting_amount"] = $req['shifting_amount']; $params["shifting_vat"] = $req['shifting_vat']; } if (isset($req['labor_amount'])) { $params["labor_amount"] = $req['labor_amount']; $params["labor_vat"] = $req['labor_vat']; } if (isset($req['part_amount'])) { $params["part_amount"] = $req['part_amount']; $params["part_vat"] = $req['part_vat']; } if (isset($req['advance_amount'])) { $params["advance_amount"] = $req['advance_amount']; $response['remaining'] = $response['total'] - $req['advance_amount']; } $params['sum_amount'] = $response['total']; $file = File::find($id)->update($params); $response = isset($response) ? ['status' => 'success', 'invoice' => $response] : ['status' => 'error']; return response($response); } else { if ($action == 'setStatusOrder') { $param['code_status_id'] = $req['code_status_id']; $param['file_id'] = $req['file_id']; $param['created_at'] = date('d/m/Y, H:i:s'); $param['user_id'] = $req['user_id']; $param['comment'] = $req['comment']; $response = StatusFile::create($param)->id; File::find($param['file_id'])->touch(); $param['user'] = Auth::user()->name; $response = $response != '' ? ['status' => 'success', 'new' => $param] : ['status' => 'error']; return response($response); } else { } } } }
public function getfileex($filename) { $fileext = File::where('id', $filename)->value('mine'); }
/** * Update the specified resource in storage. * * @param Request $request * @param int $id * @return Response */ public function filehandle($req, $id) { // PDF tidak di update / melalui form // Gagal mengupload file PDF // Sukses Mengupload DOkumen $pesan = ['error' => ['Peringatan : File PDF tidak di atur dengan benar !', 'Terjadi kesalahan upload File PDf '], 'succes' => 'Sukses mengupload Dokumen PDF ']; // dd($req->all()); $file = $req->file('gambar'); // $lokasi_tujuan=str_slug( str_replace('-', ' ', $req->get('no_boks'))); $lokasi_tujuan = $req->get('no_boks'); if ($file and $file->getClientMimeType() == 'application/pdf') { // dd($file); $extension = $file->getClientOriginalExtension(); $entry = File::where('dokumen_id', '=', $id)->first(); // format nama file = ============================================================================================== $nama_file = str_slug(str_replace('/', '-', $req->get('no_sppd'))) . '-' . str_slug(str_replace('/', '-', $req->get('nama_dokumen'))) . '-' . $file->getFilename() . '.' . $extension; // echo $nama_file; // dd($entry); if (count($entry)) { // dd(count($entry->get()->toArray())); // $entry=File::find($entry->id); // dd($entry->with('dokumen')->get()); // dd($entry->get()->toArray()[0]['filename']); // if (\Storage::exists($entry->get()->toArray()[0]['dir'].'/'.$entry->get()->toArray()[0]['filename'])) { // \Storage::delete($entry->get()->toArray()[0]['dir'].'/'.$entry->get()->toArray()[0]['filename']); // } // if($entry){ $lokasi_baru = $entry->dir . '/' . $entry->nama_baru; $lokasi_lama = $entry->filename; if ($entry->dir && $entry->nama_baru && \Storage::exists($lokasi_baru)) { // echo $lokasi_baru; \Storage::move($lokasi_baru, 'RecycleBin/' . $entry->nama_baru); // \Storage::delete($lokasi_baru); } if ($entry->filename && \Storage::exists($lokasi_lama)) { // echo $lokasi_lama; \Storage::move($lokasi_lama, 'RecycleBin/' . $entry->nama_baru); // \Storage::delete($lokasi_lama); } // dd($lokasi_baru); // $entry->delete(); // } $update = ['mime' => $file->getClientMimeType(), 'original_filename' => $file->getClientOriginalName(), 'filename' => $nama_file, 'nama_baru' => $nama_file, 'dir' => $lokasi_tujuan]; if ($entry->update($update)) { $dirs = \Storage::allDirectories(); // $dir=str_slug( str_replace('-', ' ', $req->get('no_boks'))); $dir = $lokasi_tujuan; if (!in_array($dir, $dirs)) { \Storage::makeDirectory($lokasi_tujuan); } echo $nama_file; \Storage::put($dir . '/' . $nama_file, \File::get($file)); return true; } return false; } else { $entry = new File(); $entry->dokumen_id = $id; $entry->mime = $file->getClientMimeType(); $entry->original_filename = $file->getClientOriginalName(); $entry->filename = $nama_file; $entry->nama_baru = $nama_file; // $entry->dir = str_slug( $req->get('no_boks'), "-"); $entry->dir = $lokasi_tujuan; if ($entry->save()) { $dirs = \Storage::allDirectories(); // $dir=str_slug( str_replace('-', ' ', $req->get('no_boks'))); $dir = $lokasi_tujuan; if (!in_array($dir, $dirs)) { \Storage::makeDirectory($lokasi_tujuan); } echo $nama_file; \Storage::put($dir . '/' . $nama_file, \File::get($file)); return true; } return false; } // } } else { // Handle file pdf //pINDAH DIREKTORI KARENA UPDATE NO BOX $entry = File::where('dokumen_id', '=', $id)->first(); //JIKA NAMA dir dari file $entry !== str_slug($req->boks) // $lokasi_tujuan=str_slug( str_replace('-', ' ', $req->get('no_boks'))); if ($entry && $entry->dir !== $lokasi_tujuan) { $nama_file = str_slug(str_replace('/', '-', $req->get('no_sppd'))) . '-' . str_slug(str_replace('/', '-', $req->get('nama_dokumen'))) . '-' . $entry->filename; // $nama_file_baru= str_slug( str_replace('-', ' ', $req->get('no_sppd'))).'-'.str_slug( str_replace('-', ' ', $req->get('nama_dokumen'))).'-'.$entry->filename; // $entry->nama_baru=!empty($entry->nama_baru) ? $entry->nama_baru:str_replace('/', '-', $entry->dokumen->no_sppd).'-'.$entry->filename; $entry->nama_baru = !empty($entry->nama_baru) ? $entry->nama_baru : $nama_file; // $entry->nama_baru=str_replace('/', '-', $entry->dokumen->no_sppd).'-'.$entry->filename; // dd('lama masuk '); $lokasi_lama_file = $entry->dir . '/' . $entry->nama_baru; $lokasi_lama_lama_migrasi = $entry->filename; // echo "baru".$lokasi_baru; // echo "baru".$lokasi_lama; $lokasi_tujuan_and_file = $lokasi_tujuan . '/' . $entry->nama_baru; // handle file yang telah dimigrasi if (\Storage::exists($lokasi_lama_file)) { //cek apakah lokasi baru sudah atau belum $dirs = \Storage::allDirectories(); if (in_array($lokasi_tujuan, $dirs)) { // dd('dir ada '); \Storage::move($lokasi_lama_file, $lokasi_tujuan_and_file); // return true; } elseif (!in_array($lokasi_tujuan, $dirs)) { // print_r($lokasi_tujuan); // print_r($dirs); // dd('dir tidak ada '); \Storage::makeDirectory($lokasi_tujuan); \Storage::move($lokasi_lama_file, $lokasi_tujuan_and_file); // return true; } else { // return 'Adalah masalah permissi penulisan file Anda '; } //pindahkan file ke lokasi baru //simpan nama lokasi baru } elseif (\Storage::exists($lokasi_lama_lama_migrasi)) { //cek apakah lokasi baru sudah atau belum $dirs = \Storage::allDirectories(); // Lokasi telah siap if (in_array($lokasi_tujuan, $dirs)) { \Storage::move($lokasi_lama_lama_migrasi, $lokasi_tujuan_and_file); // return true; } if (!in_array($lokasi_tujuan, $dirs)) { \Storage::makeDirectory($lokasi_tujuan); \Storage::move($lokasi_lama_lama_migrasi, $lokasi_tujuan_and_file); // return true; } else { // return 'Adalah masalah permissi penulisan file Anda '; } //pindahkan file ke lokasi baru //simpan nama lokasi baru } else { echo 'File lama tidak ada!!!!'; return false; } $entry->dir = $lokasi_tujuan; // dd($lokasi_tujuan); if ($entry->save()) { echo 'Telah diupdate Ke Lokasi baru'; return true; } } // Handle db file // $update= $entry; // ['mime' => $file->getClientMimeType(), // 'original_filename' => $file->getClientOriginalName(), // 'filename' =>$nama_file, // 'nama_baru' =>$nama_file, // 'dir' =>str_slug( $req->get('no_boks'), "-"), // ]; // $data['msg']='Gagal'; // // $data['errors']=$errors; // $data['errors']='File yang anda Upload bukan PDF'; // $data['code']=403; // // echo json_encode($data); // return \Response::make(json_encode($data), 403); return false; // return 'File yang anda Upload bukan PDF'; } }
public function randomFileName() { $randomName = rand(1000000, 9999999); if (File::where('rand', $randomName)->first() != null) { return $this->randomFileName(); } else { return $randomName; } }
/** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(Request $request, $id) { $input = $request->all(); if (isset($input['filepath'])) { $imgPath = $this->imageUpload($input['filepath']); $input['filepath'] = $imgPath; } else { $input['filepath'] = File::where('id', '=', $id)->pluck('filepath'); } $data = File::findOrFail($id); $data->update($input); return redirect('file')->with('status', 'Update successfully'); }