Initial refactoring work
This commit is contained in:
31
app/Models/Product.php
Normal file
31
app/Models/Product.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?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;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user