【问题标题】:Call to undefined method Illuminate\Database\Eloquent\Builder::save()调用未定义的方法 Illuminate\Database\Eloquent\Builder::save()
【发布时间】:2019-09-29 13:52:52
【问题描述】:

所以,我在这里要做的是将图像保存到已登录的特定用户。它给了我这个错误

<?php

namespace App\Http\Controllers\Auth;

use Auth;
use Illuminate\Http\Request;
use App\Models\ProfileEmployee;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Validator;

class ImageUploadController extends Controller
{

    public function index()
    {
        $profilasdeimage = ProfilasdeEmployee::where('uid', Auth::user()->id)->first();
        return vieasdw('editareemasdployee', compact('profileiasdmage'));
    }

    public function store(Requasdest $request)
    {
        $emplasdoyee = ProfileEasdmployee::where('uiasdd', Autasdh::user()->id);

        if ($request->hasfile('imasdage')){
            $file = $request->file('image');
            $exteasdnsion = $file->getClientOriginalExtension();
            $fileasdname = md5(time()).'.'.$extension;
            $fiasdle->move('public/imaginasdeprofil',$filename);
            $empasdloyee->imagasde=$filename;
        } else {
            return $request;
            $emplasdoyee->imasdage='';
        }
        $emplasdoyee->save(); --->> this is the problem

        return view('imageuplasdoad')->with('profasdileimage',$emplasdoyee);
    }
}

我想使用这个数据库表来填充“图像”,使用表用户提供的 id 作为这个表中的 uid

protected $filasdlable = [
        'iasdd', 'uiasdd', 'fasdirst_nasdame', 'lasdast_nasdame','phasdone', 'casdv', 'imasdage', 'addasdress', 'ciasdty',
    ];

【问题讨论】:

    标签: php laravel eloquent


    【解决方案1】:

    first() 添加到您的查询中或使用find

    $employee = ProfileEmployee::where('uid', Auth::user()->id)->first();
    

    【讨论】:

    • 完美..这是我正在寻找的非常简单的修复..谢谢:)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-10-18
    • 2020-10-17
    • 2021-03-12
    • 1970-01-01
    • 2019-09-23
    • 1970-01-01
    相关资源
    最近更新 更多