调用未定义的方法Illuminate \ Database \ Eloquent \ Builder :: save()

时间:2019-05-12 10:12:15

标签: php laravel eloquent

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

<?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',
    ];

2 个答案:

答案 0 :(得分:0)

使用

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

$employee = ProfileEmployee::find(Auth::user()->id);

Laravel Where Clauses

答案 1 :(得分:0)

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

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