mardi 19 février 2019

one to many relationship query

I have two tables. These are client and project. Each client has many projects and each project related with one client. I want to output all the projects in the view template which is related with each client. Please help me

Project Model

public function client()
    {
        return $this->belongsTo('App\Model\Admin\Client');
    }

Client model

 public function projects()
    {
        return $this->hasMany('App\Model\Admin\Project');
    }

I want to output like below in the blade template:

id -| Client_name |- client_company |- contact_number-|- project_list
----|-------------|-----------------|-----------------|-----------------
  1 |  x          |  x@.com         |xxxxxxxxxxxxxxx  |  first project
    |             |                 |                 |  second project
    |             |                 |                 |  Third project
  ----------------|-----------------|-----------------|--------------------  
  2 |  y          |  y@.com         |xxxxxxxxxxxxxxx  |  first project
                                    |                 |  second project
                                                      |  Third project 



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire