I have an Ionic application that communicates with my Laravel api. I'm trying to get the product details and image from the api and display that data in my Ionic app. I have the images stored on the local disk and also have a db table that contains the path name for each image. But when the Ionic app gets this data back, it just gets a json object that contains the mainImage with a path to the local disk, which of course, I can't use as an img src. My question is, how do I pass the mainImage as a file rather than a json object?
Here is my Laravel function:
public function api_get_non_disliked_for_user($categoryId)
{
$allProducts = Product::with('mainImage')
->where('subSubCategoryId', "=", $categoryId)->orderBy('title')->get();
return $allProducts;
}
In Product Model:
public function mainImage(){
return $this->hasOne('App\MainImage', 'productId');
}
In MainImage Model:
public function product(){
return $this->belongsTo('App\Product', 'productId');
}