/** * Upload the file. * * @param Model $model * @param Request $request * * @return void */ private function uploadFileTest($model, Request $request) { // Filter through all the uploaded files, only grabbing the files in our // Fillable, (we don't want any extra things) $valid_files = collect($request->allFiles())->filter(function ($file, $key) use($model) { return in_array($key, $model->getFillable()); }); // For each file process the upload. // Of course, if the collection of valid_files is empty, nothing will happen. $valid_files->each(function (\Illuminate\Http\UploadedFile $file, $key) use($model) { $ext = $file->guessExtension(); $name = Warden::generateUUID() . '.' . $ext; $fs = new Filesystem(); $fs->makeDirectory($file_path = storage_path('app/uploads'), 0755, true, true); $model->{$key} = $name; $file->move($file_path, $name); }); }
protected function mapApiRoutes() { if (empty(config('kregel.warden.using.custom-routes'))) { Warden::apiRoutes(); } }