I'm trying to use settable() method and get the data from relashionship. Here are my Models:
class Order extends Model
{
public function list(){
return $this->hasMany('App\Models\List');
}
}
class List extends Model
{
public function order(){
return $this->belongsTo('App\Models\Order', 'order_id');
}
}
In the Controller, I set the table before the select:
$this->list->setTable("user_".auth()->user()->id."_lists");
$users = $this->list->where('order_id', $id)->with('Order')->get();
The problem is: the setTable() method can set the list table correctly, but how can I set the orders table correctly, since the with() method only gets the default orders table? Example: the orders table should be user_{$id}orders and the lists table shoud be user{$id}_lists