Monday, March 13, 2017

Get image url through User Model in laravel

I am trying to create a rule inside the user model, to check the user image is exist, and if it is exist return back the complete image url, I am doing this way but not working in foreach($users as $user) loop.

    public function Image(){
    $image = $this->user->image;
    if(empty($image)){
    $image = asset('images/profile/no-image.png');
    }else{
    $image = asset('images/profile/no-image.png');
    }
    return $image;
    }



via mehran gh

Advertisement