Fetch data from another table from a hasMany result set?
Hello. I have three tables. ItemOrders, Orders and Items. In my Orders model I have the following:
namespace App;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\DB;
use App\Item;
// MODEL
class Order extends Model
{
public function getItems()
{
return $this->hasMany('App\ItemOrder')->select('id');
}
}
I am trying to get the names of the items from the hasMany result. How would I achieve something like this? With standard SQL I know how I'd be able to do it, but Eloquent is kinda confusing to me as I'm new at this. Any help or a pointer where/what to look/read would be appreciated.