Reiseland Kontaktdaten, Rabatt API
This commit is contained in:
parent
8f29c15a2b
commit
70704be1ea
30 changed files with 471 additions and 95 deletions
88
app/Models/Sym/CmsContent.php
Normal file
88
app/Models/Sym/CmsContent.php
Normal file
|
|
@ -0,0 +1,88 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models\Sym;
|
||||
|
||||
use Cviebrock\EloquentSluggable\Sluggable;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
|
||||
/**
|
||||
* App\Models\Sym\CmsContent
|
||||
*
|
||||
* @property int $id
|
||||
* @property string $name
|
||||
* @property string $slug
|
||||
* @property string $field
|
||||
* @property string|null $text
|
||||
* @property string|null $full_text
|
||||
* @property int|null $integer
|
||||
* @property float|null $decimal
|
||||
* @property string|null $created_at
|
||||
* @property string|null $updated_at
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Sym\CmsContent newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Sym\CmsContent newQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Sym\CmsContent query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Sym\CmsContent whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Sym\CmsContent whereDecimal($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Sym\CmsContent whereField($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Sym\CmsContent whereFullText($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Sym\CmsContent whereId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Sym\CmsContent whereInteger($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Sym\CmsContent whereName($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Sym\CmsContent whereSlug($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Sym\CmsContent whereText($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Sym\CmsContent whereUpdatedAt($value)
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class CmsContent extends Model
|
||||
{
|
||||
|
||||
use Sluggable;
|
||||
|
||||
protected $connection = 'mysql';
|
||||
|
||||
protected $table = 'cms_contents';
|
||||
|
||||
protected $fillable = [
|
||||
'name', 'slug', 'field', 'text', 'full_text', 'integer', 'decimal',
|
||||
];
|
||||
|
||||
public $timestamps = false;
|
||||
|
||||
public function sluggable()
|
||||
{
|
||||
return [
|
||||
'slug' => [
|
||||
'source' => 'name'
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
public function _format_number($value){
|
||||
return preg_replace("/[^0-9,]/", "", $value);
|
||||
}
|
||||
|
||||
public function setDecimalAttribute($value)
|
||||
{
|
||||
$value = $this->_format_number($value);
|
||||
$value = substr($value, -13);
|
||||
$this->attributes['decimal'] = floatval(str_replace(',', '.', $value));
|
||||
}
|
||||
|
||||
public function getDecimalAttribute()
|
||||
{
|
||||
if(isset($this->attributes['decimal'])){
|
||||
// 2 = decimal places | '.' = decimal seperator | ',' = thousand seperator
|
||||
return number_format(($this->attributes['decimal']), 2, ',', '.');
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public function setIntegerAttribute($value)
|
||||
{
|
||||
$value = $this->_format_number($value);
|
||||
$value = substr($value, -10);
|
||||
$this->attributes['integer'] = intval($value);
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue