Answer the question
In order to leave comments, you need to log in
Laravel implicit relationship M:M?
Good afternoon! Please tell me how correct my decision is and what should be changed here, and is it worth changing?
The site has 2 pages
1. Locations (List of decorated "corners" for photosets)_
2. Models (Photo models)
You can create galleries in the admin panel. Once created, they are not tied to any page.
Further, when creating any model or location, you can attach any number of any galleries.
gallery table
Id, title, name, folder(path to the folder with the gallery relative to the public folder)
locations
Id, title,
thumbnail
table
gallery_id
In the models, I do not create links, but simply in the controllers I create an instance of the attached_gallery class. To what extent is this the correct, concise way?
And for example, I want to get the id of all galleries attached to a specific location, then this line
$gallery_ids = Attached_gallery::where ('type_id', $id )->get();
I select all the galleries attached to this page (locations, photo models)
I get a multidimensional array and if I write like this
$gallery = gallery::where($gallery_ids['gallery_id'])->get();
then I'll get Undefined index: gallery_id
how to correctly build a query to select all galleries whose id's are in $gallery_ids['gallery_id'] . Thank you very much!
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question