2

I want to get the path of an image using mutators or helper function for example this is My request :

 "placeType": {
        "id": 1,
        "name": "Kenya Wyman",
        "image_name": "1574668070.png",
        "status": 1,
}
}

I want it to appear like this :

 "placeType": {
        "id": 1,
        "name": "Kenya Wyman",
        "image_name": "www.mydomain.com/photos/1574668070.png",
        "status": 1,
}
}

Fateh Alrabeai
  • 660
  • 3
  • 17
  • 35

3 Answers3

3

Try This

$user->image_name = url('public/Your path ' . $user->image_name);

OR

In your Model Add this

public function getImageNameAttribute($value)
{

        return public_path($value);
}
VIKAS KATARIYA
  • 5,867
  • 3
  • 17
  • 34
1

Try to use this code :

asset('photos/1574668070.png');

0

Try to use this code :

$data->image_name = URL::to('/') . '/public/imageFolder/' . $placeType->image_name;