Update Framework, Invoices
This commit is contained in:
parent
cc5c147c27
commit
9b0b5feb7e
174 changed files with 28356 additions and 8093 deletions
144
app/Models/Setting.php
Normal file
144
app/Models/Setting.php
Normal file
|
|
@ -0,0 +1,144 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Created by Reliese Model.
|
||||
*/
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* Class Setting
|
||||
*
|
||||
* @property int $id
|
||||
* @property string|null $identifier
|
||||
* @property string $slug
|
||||
* @property int $referenz
|
||||
* @property string|null $action
|
||||
* @property string|null $object
|
||||
* @property string|null $full_text
|
||||
* @property string|null $text
|
||||
* @property int|null $int
|
||||
* @property int $status
|
||||
* @property string|null $type
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @package App\Models
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Setting newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Setting newQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Setting query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Setting whereAction($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Setting whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Setting whereFullText($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Setting whereId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Setting whereIdentifier($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Setting whereInt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Setting whereObject($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Setting whereReferenz($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Setting whereSlug($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Setting whereStatus($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Setting whereText($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Setting whereType($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Setting whereUpdatedAt($value)
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class Setting extends Model
|
||||
{
|
||||
protected $table = 'settings';
|
||||
|
||||
protected $casts = [
|
||||
'referenz' => 'int',
|
||||
'status' => 'int',
|
||||
'int' => 'int',
|
||||
'object' => 'array'
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'identifier',
|
||||
'slug',
|
||||
'referenz',
|
||||
'action',
|
||||
'object',
|
||||
'full_text',
|
||||
'text',
|
||||
'int',
|
||||
'status',
|
||||
'type'
|
||||
];
|
||||
|
||||
protected static $types = [
|
||||
'object' => 'Object',
|
||||
'full_text' => 'Full Text',
|
||||
'text' => 'Text',
|
||||
'int' => 'Zahl',
|
||||
'bool' => 'Bool',
|
||||
|
||||
|
||||
];
|
||||
|
||||
public function sluggable()
|
||||
{
|
||||
return [
|
||||
'slug' => [
|
||||
'source' => 'name'
|
||||
]
|
||||
];
|
||||
}
|
||||
public static function getContentBySlug($slug){
|
||||
$content = self::whereSlug(trim($slug))->first();
|
||||
if($content){
|
||||
switch ($content->type){
|
||||
case 'object':
|
||||
return $content->object;
|
||||
break;
|
||||
case 'full_text':
|
||||
return $content->full_text;
|
||||
break;
|
||||
case 'text':
|
||||
return $content->text;
|
||||
break;
|
||||
case 'int':
|
||||
return $content->int;
|
||||
break;
|
||||
case 'bool':
|
||||
return $content->int === 1 ? true : false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function setContentBySlug($slug, $value, $type = "full_text"){
|
||||
|
||||
$content = self::whereSlug(trim($slug))->first();
|
||||
if(!$content) {
|
||||
$content = self::create([
|
||||
'slug' => $slug,
|
||||
'type' => $type,
|
||||
]);
|
||||
}
|
||||
$content->type = $type;
|
||||
switch ($content->type){
|
||||
case 'object':
|
||||
$content->object = $value ? $value : null;;
|
||||
break;
|
||||
case 'full_text':
|
||||
$content->full_text = $value ? $value : null;;
|
||||
break;
|
||||
case 'text':
|
||||
$content->text = $value ? $value : null;;
|
||||
break;
|
||||
case 'int':
|
||||
$content->int = (int) $value;
|
||||
break;
|
||||
case 'bool':
|
||||
$content->int = $value ? 1 : 0;
|
||||
break;
|
||||
}
|
||||
|
||||
$content->save();
|
||||
return $content;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue