lundi 1 février 2016

Eloquent model using multiple table query

I have two table Email (id,content,folder_id) Folder (id,name)

In model

public function folder() {
        return $this->belongsTo('App\Folder');
    }

 public function email() {
        return $this->hasMany('App\Email');
    }

In Controller, i want list all email for each folder from a request

public function mailbox ($foldername) {
$data=Email::with('folder')->orderBy('id','DESC')->where('??????',$foldername)->get()->toArray();
        return view('dashboard.mailbox.mailbox',compact('data'));
    }

The probalem is: how can i get name (with ???? in code below) from Folder table to where with input request ->

It's OK if i go with $id request, but i want a beatiful respon, so please help me



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire