08 2024
This commit is contained in:
parent
04d677d37a
commit
bfa3bb1df4
1191 changed files with 637397 additions and 10619 deletions
|
|
@ -30,16 +30,14 @@ use Illuminate\Database\Eloquent\Model;
|
|||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Shipping whereUpdatedAt($value)
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\ShippingPrice[] $shipping_prices
|
||||
* @property-read int|null $shipping_prices_count
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\TransShipping> $translations
|
||||
* @property-read int|null $translations_count
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class Shipping extends Model
|
||||
{
|
||||
protected $table = 'shippings';
|
||||
|
||||
protected $casts = [
|
||||
'trans_name' => 'array',
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'name', 'active', 'free'
|
||||
];
|
||||
|
|
@ -78,4 +76,25 @@ class Shipping extends Model
|
|||
public function shipping_prices(){
|
||||
return $this->hasMany('App\Models\ShippingPrice', 'shipping_id', 'id');
|
||||
}
|
||||
|
||||
public function translations()
|
||||
{
|
||||
return $this->hasMany(TransShipping::class, 'shipping_id');
|
||||
}
|
||||
|
||||
public function getLang($key)
|
||||
{
|
||||
$lang = \App::getLocale();
|
||||
if ($lang == 'de') {
|
||||
return $this->{$key};
|
||||
}
|
||||
$trans = $this->getTrans($key, $lang);
|
||||
return $trans != '' ? $trans : $this->{$key};
|
||||
}
|
||||
|
||||
public function getTrans($key, $lang)
|
||||
{
|
||||
$trans = $this->translations->where('language','=', $lang)->where('key', $key)->first();
|
||||
return $trans ? $trans->value : '';
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue