Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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',
    ];
like image 509
Paul Catalin Agighioleanu Avatar asked May 12 '19 10:05

Paul Catalin Agighioleanu


1 Answers

Add first() to your query or use find:

$employee = ProfileEmployee::where('uid', Auth::user()->id)->first();
like image 183
Rouhollah Mazarei Avatar answered Oct 24 '22 10:10

Rouhollah Mazarei