<?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class Product extends Model { protected $table = 'ab_product'; protected $with = ['descriptions']; public function descriptions() { return $this->hasMany(ProductTranslate::class); } public function services() { return $this->hasMany(Service::class); } /** * Get the language name * * @param Language $lo */ public function name(Language $lo) { return $this->descriptions->where('language_id',$lo->id)->first()->name; } }