Comments & Discussion
Let's assume there is a PhotoController for polymorphic child resource
to manipulate Photo data.
Assuming Photo data is updated, then parent row,
either Project or Task, should be updated as well.
I see several options.
Option 1:
To create ProjectPhotoControler and TaskPhotoControler.
This way when inside ProjectPhotoControler,
$photo->photoable
is Project and may address Project fields by -> operator.
And same for Task.
In this case there is some code repetition,
yet dedicated controler may be more readable.
Option 2:
To create PhotoControler only,
yet will need if blocks to compare to photoable_type, like that
$if ($photo->photoable_type === Project::class){ ...}
$if ($photo->photoable_type === Task::class){ ...}
In this case, there is only one controler.
Yet, if there are more Owner Entities,
a lot of "if condition" blocks can make a code not readable.
Question: Can you please reccomend?
Hi, could you please share the repository link for this course?
can i receive source codes related to polymophic explanations ???
what about down in migration file ? how to drop it?
Personally, I don't use down() method for a long time, Taylor said it back in 2017: https://laraveldaily.com/post/still-need-migrations-taylor-says-no