简体   繁体   中英

Call to undefined method Illuminate\Database\Eloquent\Builder::save()

So, what i`m trying to do here is to save an image to an specific user that is logged in. and it gives me this error

<?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);
    }
}

i want to use this database table to fill the 'image' using the id provided from table users as uid in this table

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

Use

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

or

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

Laravel Where Clauses

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM