osb/app/Models/Product.php
2018-08-01 17:09:38 +10:00

37 lines
637 B
PHP

<?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);
}
public function getProductIdAttribute()
{
return sprintf('#%04s',$this->id);
}
/**
* Get the language name
*
* @param Language $lo
* @return string Product Name
*/
public function name(Language $lo)
{
return $this->descriptions->where('language_id',$lo->id)->first()->name;
}
}