1
votes

I get this error:

Symfony\Component\Debug\Exception\FatalThrowableError (E_ERROR) Call to undefined method Illuminate\Auth\AuthManager::user()

Code in ImageGalleryController

{
    $this->validate($request, [
        'title' => 'required',
        'image' => 'required|image|mimes:jpeg,png,jpg,gif,svg|max:2048',
        ]);

    $input['image'] = time().'.'.$request->image->getClientOriginalExtension();
    $request->image->move(public_path('images'), $input['image']);

    $input['title'] = $request->title;
    $input['uid'] = Auth()::user()->id;
    ImageGallery::create($input);

    return back()
    ->with('success','Image Uploaded successfully.');
}

/**
 * Remove Image function
 *
 * @return \Illuminate\Http\Response
 */
public function destroy($id)
{
    ImageGallery::find($id)->delete();
    return back()
}
1
The piece of code you posted from ImageGalleryController is not precise. It looks like you forgot the part before (I don't see the method signature) and the part after (I don't see any closing bracket). Can you complete it?louisfischer
thanks but problem resolved by using ($image->uid=Auth::user()->id;)Himani
You could post an answer and accept your own answer. This way other Stack Overflow users will this question as solved.louisfischer

1 Answers

0
votes

Change the code from

    $input['uid'] = Auth()::user()->id;

to

    $input['uid'] = Auth::id();