#why is there `Post $post` in the function when i create resource controller?

6 messages · Page 1 of 1 (latest)

kindred swift
#

I need to understand this..can anyone help me ?

`public function update(Request $request, Post $post)
{
$data['title']= $request->title;
$data['details']= $request->details;

    if($request->hasFile('image')){

        $file= $request->file('image');
        $path= 'images';
        $file_name =rand(00000,99999).'.'.$file->getClientOriginalExtension();
        $file->move(public_path('public/images'),$file_name);

        $data['image']= $file_name;
        if(file_exists($post->image)){
            unlink($post->image);
        }
    }
    $post->update($data);
    return redirect()->route('post.index');
}`
shadow ginkgo
#

Dependency injection.

kindred swift
#

is it because of the $post that i used later on the code??@shadow ginkgo

shadow ginkgo
#

I am not sure what you are asking. If you read the docs on all these things, you'd understand.