Laravel can't save photo

Laravel can't save photo

I have function code below but it won't save photo not in database nor in file path.

I have function code below but it won't save photo not in database nor in file path.

Code

public function store(Request $request)
    {
        $this->validate($request, array(
            'name' => 'required',
            'price' => 'required|numeric',
            'type_id' => 'required|numeric',
            'photo' => 'required',
        ));
        $item = new Menu;
        $item->name = $request->input('name');
        $item->price = $request->input('price');
        $item->type_id = $request->input('type_id');
        if ($request->hasFile('photo')) {
          $photo = $request->file('photo');
          $filename = 'MenuItem' . '-' . time() . '.' . $photo->getClientOriginalExtension();
          $location = public_path('images/'. $filename);
          Image::make($photo)->resize(500, 500)->save($location);
          $item->photo = $filename;
        }
        $item->save();
        Session::flash('success', 'Menu Item Saved Successfully.');
        return redirect()->back();
}

dd($request->all()); of code above

array:5 [▼
  "_token" => "awAvc7F8lOv9vKkfwyiTFj7jnQGszv8xjLQxcwRH"
  "name" => "test"
  "price" => "100"
  "photo" => "air putih.jpg"
  "type_id" => "1"
]

Any idea?

Update

Based on the Nabil Farhan answer below I was forgot about enctype="multipart/form-data" but now I'm getting

Intervention \ Image \ Exception \ NotReadableException
Unable to find file ().

Still not able to save my photo.

php laravel

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

Php how to delete multiple rows through checkbox using ajax in laravel

In this article i will let you know to delete multiple rows through checkbox using ajax in laravel and before delete we will give a confirmation message.

5 Laravel’s Hidden Gems

Spread the love1. Stop on first validation error By default, Laravel will check for all validation rules and return a list of errors. But if you want to stop this process after first validation failure, that’s how you can achieve…Read More→

Some of the most frequent how tos in Laravel

Spread the loveHow to get relationship from relationship using With() in Laravel Some times there are cases where you want to get relationship from relationship in Laravel, that can be achieved via following: How to create multiple where clauses in…Read More→

10 Laravel Quick Tips

Spread the loveTip 1. Controllers Having Single Action In some situations you need a single action in a controller, if this is the case in Laravel you can achieve it by __invoke() method. Routes: Artisan command to generate this controller:…Read More→

Laravel Sanctum vs Passport

After the Laravel Sanctum package was released? Everywhere question was asked that When to use Sanctum and when to use Passport? So, in this video, you will ...