I have a table to store all emails sended by laravel. I can fire events and store different information together with type (for example post, user, ...) and and id (id of the type). So when i send an email from post 4 i write into the storage a row with type="post" and type_id=4.
But how can i get this out of the database? I want to get all from email_storage (later with pagination) and if the type is post, i want to get from post with id=type_id... if it is user than get from user table with user_id=type_id ...
hope somebody can help me. My last code is:
public function post() { return $this->hasOne('App\Models\Post','id','type_id'); } $result = parent::with('post')->get();
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community