update 20.10.2025
This commit is contained in:
parent
8c11130b5d
commit
a939cd51ef
616 changed files with 84821 additions and 4121 deletions
100
dev/app-bak/Models/Shipping.php
Normal file
100
dev/app-bak/Models/Shipping.php
Normal file
|
|
@ -0,0 +1,100 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* App\Models\Shipping
|
||||
*
|
||||
* @property int $id
|
||||
* @property string $name
|
||||
* @property array|null $trans_name
|
||||
* @property float|null $free
|
||||
* @property int $active
|
||||
* @property \Illuminate\Support\Carbon|null $created_at
|
||||
* @property \Illuminate\Support\Carbon|null $updated_at
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\ShippingCountry[] $countries
|
||||
* @property-read int|null $countries_count
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\ShippingPrice[] $prices
|
||||
* @property-read int|null $prices_count
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Shipping newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Shipping newQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Shipping query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Shipping whereActive($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Shipping whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Shipping whereFree($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Shipping whereId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Shipping whereName($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Shipping whereTransName($value)
|
||||
* @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 $fillable = [
|
||||
'name', 'active', 'free'
|
||||
];
|
||||
|
||||
public function _format_number($value){
|
||||
return preg_replace("/[^0-9,]/", "", $value);
|
||||
}
|
||||
|
||||
public function setFreeAttribute( $value ) {
|
||||
if($value == ""){
|
||||
$this->attributes['free'] = null;
|
||||
}else{
|
||||
$value = $this->_format_number($value);
|
||||
$this->attributes['free'] = floatval(str_replace(',', '.', $value));
|
||||
}
|
||||
}
|
||||
public function getFormattedFree()
|
||||
{
|
||||
if($this->free === null) {
|
||||
return "";
|
||||
}
|
||||
if(\App::getLocale() == "en"){
|
||||
return number_format($this->attributes['free'], 2, '.', ',');
|
||||
}
|
||||
return number_format($this->attributes['free'], 2, ',', '.');
|
||||
}
|
||||
|
||||
|
||||
public function countries(){
|
||||
return $this->hasMany('App\Models\ShippingCountry', 'shipping_id', 'id');
|
||||
}
|
||||
|
||||
public function prices(){
|
||||
return $this->hasMany('App\Models\ShippingPrice', 'shipping_id', 'id');
|
||||
}
|
||||
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