I would like your advice in the implementation of the following.
There is an Activity model and a activities table in my project, an activity can have multiple 'tips', and I need to store those tips somewhere.
Each tip has only a text description, if I wasn't using Laravel, I would simply create a table like activity_tips where I would store the id of the activity and the description of the tip, each row been one tip belonging to one activity, maybe an id incremental, but nothing more (at least what I planned).
Now, Laravel comes with this beauty called relationships, but it must be between two models.
I know I can't use something like this because it needs the Tip model (and table).
public function tips(){
return $this->hasMany('App\Tip', 'id_activity', 'id')
->select('id', 'id_activity', 'tip');
}
I could create a Tip model and table, but it doesn't feel right because the Tip table would be useless.
Is there any Laravel feature than can help me with that? Also by keeping everything in the model? Maybe use raw sql statements to only have the activity_tips
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire