Call to a member function where() on null code example

Example 1: Call to a member function move() on string

if ($request->hasFile('file')) {
    $destinationPath = 'path/th/save/file/';
    $files = $request->file('file'); // will get all files

    foreach ($files as $file) {//this statement will loop through all files.
        $file_name = $file->getClientOriginalName(); //Get file original name
        $file->move($destinationPath , $file_name); // move files to destination folder
    }
}

Example 2: Call to a member function connection() on null

I think you just uncomment $app->withFacades();, $app->withEloquent(); lines in bootstrap/app.php;

And check again, it works for me.

Tags:

Misc Example