Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

check image exist or not in laravel

// User Model
public function photo()
{
    if (file_exists( public_path() . '/images/photos/account/' . $this->account_id . '.png')) {
        return '/images/photos/account/' . $this->account_id .'.png';
    } else {
        return '/images/photos/account/default.png';
    }     
}

// Blade Template
<img src="{!! Auth::user()->photo() !!}" alt="">
 
PREVIOUS NEXT
Tagged: #check #image #exist #laravel
ADD COMMENT
Topic
Name
8+4 =