Php 方法save不存在。拉维尔

Php 方法save不存在。拉维尔,php,laravel,save,Php,Laravel,Save,我试图在图像表中插入,但以下语法显示方法save未退出:Macroable.php第74行中的BadMethodCallException: 控制器: foreach ($request->file('image') as $i) { $image = new image(); $image = $i; $input['imagename'] = $request->vname.'_'.$user->id.'_'.str_random(2).'.'

我试图在图像表中插入,但以下语法显示方法save未退出:Macroable.php第74行中的BadMethodCallException:

控制器:

foreach ($request->file('image') as $i) 
{
    $image = new image();

    $image = $i; 
    $input['imagename'] = $request->vname.'_'.$user->id.'_'.str_random(2).'.'.$image->getClientOriginalExtension();
    $destinationPath = public_path('/images'); 
     //move image to folder
    $image->move($destinationPath, $input['imagename']);

    $image->title=$input['imagename'];
    $image->filepath=$destinationPath;
    $image->Vehicle_id=$vehicles->id;

    $image->save();

}
谁能告诉我我做错了什么吗?

这就行了

您将模型的对象替换为file here
$image=$i$image
没有可用的保存方法

foreach ($request->file('image') as $file) 
{
    $image = new image();

    $input['imagename'] = $request->vname.'_'.$user->id.'_'.str_random(2).'.'.$file->getClientOriginalExtension();
    $destinationPath = public_path('/images'); 
     //move image to folder
    $file->move($destinationPath, $input['imagename']);

    $image->title=$input['imagename'];
    $image->filepath=$destinationPath;
    $image->Vehicle_id=$vehicles->id;

    $image->save();

}
这就行了

您将模型的对象替换为file here
$image=$i$image
没有可用的保存方法

foreach ($request->file('image') as $file) 
{
    $image = new image();

    $input['imagename'] = $request->vname.'_'.$user->id.'_'.str_random(2).'.'.$file->getClientOriginalExtension();
    $destinationPath = public_path('/images'); 
     //move image to folder
    $file->move($destinationPath, $input['imagename']);

    $image->title=$input['imagename'];
    $image->filepath=$destinationPath;
    $image->Vehicle_id=$vehicles->id;

    $image->save();

}

添加完整的方法请(包括参数)保存不存在:BadMethodCallException在Macroable.php第74行我想这一行,您分配了$image=$I;完整代码@Frank provostry$image->move('paht/to/image/image.jpg')而不是save添加完整的方法please(包括参数)save不存在:BadMethodCallException在Macroable.php第74行我想这一行,您分配了$image=$I;完整代码@Frank provostry$image->move('paht/to/image/image.jpg')而不是save