I am trying to make a site where i can list the name of products and when those name are clicked it will take to its detail page. On detail page it will show its description along with the images(more than 2) uploaded during posting. I did up to storing images by using relationship. For this i have made two tables named, "Product" and "ProductsPhoto" and established relationship in their model. It uploads image but it stores image in storage base folder of laravel. Controller for this is:
public function uploadSubmit(UploadRequest $request)
{
// Coming soon...
$product = Product::create($request->all());
foreach ($request->photos as $photo) {
$filename = $photo->store('photos');
ProductsPhoto::create([
'product_id' => $product->id,
'filename' => $filename
]);
}
return redirect('/upload/{id}');;
}
My route for it is:
Route::get('/upload', 'UploadController@uploadForm');
Route::post('/upload', 'UploadController@uploadSubmit');
Route::get('/upload/{id}','UploadController@show');
And I am being unable to show the images in detail page.Actually I did all these by following a tutorial. I don't know it nicely. So can you teach me to upload multiple images for one particular post and show them in their detail page either by establishing eloquent relationship or any by favorable methods. I just need is to upload many images for one post and show those all images for that post in detail page.
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2lRj8Rb
via IFTTT
Aucun commentaire:
Enregistrer un commentaire