lundi 20 juin 2016

Laravel 5 File::exists not working

I have a function to determine whether a user has an avatar or not based on the existence of a file named with his ID.jpg .

    public function hasAvatar()
    {
        if (File::exists(url('/media/avatars/' . $this->id . '.jpg')))
            return true;
        else
            return false;
    }

for some reason, even though the file exists, the function always returns false.

Of course I got this at the head of the file:

use Illuminate\Support\Facades\File;



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire