Skip to content

Instantly share code, notes, and snippets.

@itsdonnix
Last active December 4, 2022 23:09
Show Gist options
  • Save itsdonnix/e887b6e38a520980db303d38221cdd31 to your computer and use it in GitHub Desktop.
Save itsdonnix/e887b6e38a520980db303d38221cdd31 to your computer and use it in GitHub Desktop.
Laravel Cheatsheets

Laravel Cheatsheets

Laravel Upload file to storage folder (local)

if ($request->hasFile('image')) {
  $image = $request->file('image');
  // Will upload to /storage/public/472385852.jpg for example
  $destination  = 'public/' . time() . "." . $image->getClientOriginalExtension();
  Storage::disk('local')->put($destination, file_get_contents($image->getRealPath()));
  // You can store the $destination value to your database
}

Get controller of current view

your_view.blade.php

{{ dd(request()->route()->getAction()) }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment