vendredi 19 février 2016

how to implement One to many relationship in laravel5.1

I have a table

Leadsheet

---leadcode

Deal

-- leadcode(foreign key)

Now the model for leadsheet is as follow

class leadsheet extends Model
{
       protected $table = 'leadsheet';

       /**
     * Get the callbacks for the blog post.
     */
    public function callback()
    {
        return $this->hasMany('App\callback');      
    }

 public function Deal()
    {
        return $this->hasOne('App\Deal','leadcode', 'leadcode');    
    }
} 

I want to get only those lead that have deals in deal table , Using Eloquent

Thanks



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire