Error trying to log in with updated profile photo

Asked

Viewed 17 times

1

I made a user photo exchange system, when I change the photo, I undress and try to log in again, it comes back to me with this error:

inserir a descrição da imagem aqui

This is my line 11:

 <img src="images/uploads/avatars/{{ $user->avatar }}" alt="" class="circle responsive-img">

This is my controller:

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Auth;
use Image;
use Illuminate\Support\Facades\File;

class UserController extends Controller
{
    public function profile(){
        return view('partials.alunoform', array('user'=> Auth::user()) );
        
    }

	public function aluno(){
        return view('partials.aluno', array('user'=> Auth::user()) );
        
    }

    public function update_avatar(Request $request){

    	// Handle the user upload of avatar
    	if($request->hasFile('avatar')){
    		$avatar = $request->file('avatar');
    		$filename = time() . '.' . $avatar->getClientOriginalExtension();
    		Image::make($avatar->getRealPath())->resize(450, 450)->save( public_path('images/uploads/avatars/' . $filename ) );

    		$user = Auth::user();
    		$user->avatar = $filename;
    		$user->save();
    	}

    	return view('partials.alunoform', array('user'=> Auth::user()) );

    }
}

I read instead that it is necessary to check to see if the user is logged in, how can I do this "check"? If it’s not that, how can I fix that mistake?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.