I have simply two table and models : photos and venues.
there is a polymorphic relationship between these two classes.
A venue has a special kind of photo which is a header photo, and there should exist at most one of those photos for each venue.(a venue can have none of it)
now How I can point that specif photo from from venues?
my photos table:
Schema::create('photos', function (Blueprint $table) {
$table->increments('id');
$table->string('path');
$table->string('filename');
$table->string('mime');
$table->string('original_filename');
$table->integer('imageable_id');
$table->string('imageable_type');
$table->timestamps();
});
I see two options, whether a foreign key on venues table pointing to a photos record or adding an attribute called is_header_photo to photos table.
for me, the first option seems right but I'm a bit confused how I'm I'm supposed to change image_id on venues table to point to the right id.
How can I update this field? and if you have a better solution I would be glad to be shared.
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1ikLPTB
via IFTTT
Aucun commentaire:
Enregistrer un commentaire