main system

This commit is contained in:
Kevin Adametz 2021-01-15 18:16:31 +01:00
parent 0baac018a2
commit a96d7d5c77
115 changed files with 4589 additions and 557 deletions

111
app/Models/Setting.php Normal file
View file

@ -0,0 +1,111 @@
<?php
/**
* Created by Reliese Model.
*/
namespace App\Models;
use Carbon\Carbon;
use Cviebrock\EloquentSluggable\Sluggable;
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 $content
* @property int $status
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
*
* @package App\Models
*/
class Setting extends Model
{
use Sluggable;
protected $table = 'settings';
protected $casts = [
'referenz' => 'int',
'status' => 'int',
'object' => 'array'
];
protected $fillable = [
'identifier',
'slug',
'referenz',
'action',
'object',
'full_text',
'text',
'status',
'type'
];
protected static $types = [
'object' => 'Object',
'full_text' => 'Full Text',
'text' => 'Text',
];
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;
}
}
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;
break;
case 'full_text':
$content->full_text = $value;
break;
case 'text':
$content->text = $value;
break;
}
$content->save();
return $content;
}
}