Tree Travel Guide

This commit is contained in:
Kevin Adametz 2019-07-20 15:55:00 +02:00
parent a1ca534f55
commit 1f340e96fa
78 changed files with 4133 additions and 1027 deletions

View file

@ -0,0 +1,86 @@
<?php
namespace App\Models;
use Cviebrock\EloquentSluggable\Sluggable;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Support\Str;
/**
* App\Models\IQContentTree
*
* @property int $id
* @property string $name
* @property string $identifier
* @property string $slug
* @property string|null $description
* @property array|null $settings
* @property int $pos
* @property int $active
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @property \Illuminate\Support\Carbon|null $deleted_at
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\IQContentTreeNode[] $iq_content_tree_nodes
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\IQContentTree findSimilarSlugs($attribute, $config, $slug)
* @method static bool|null forceDelete()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\IQContentTree newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\IQContentTree newQuery()
* @method static \Illuminate\Database\Query\Builder|\App\Models\IQContentTree onlyTrashed()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\IQContentTree query()
* @method static bool|null restore()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\IQContentTree whereActive($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\IQContentTree whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\IQContentTree whereDeletedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\IQContentTree whereDescription($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\IQContentTree whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\IQContentTree whereIdentifier($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\IQContentTree whereName($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\IQContentTree wherePos($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\IQContentTree whereSettings($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\IQContentTree whereSlug($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\IQContentTree whereUpdatedAt($value)
* @method static \Illuminate\Database\Query\Builder|\App\Models\IQContentTree withTrashed()
* @method static \Illuminate\Database\Query\Builder|\App\Models\IQContentTree withoutTrashed()
* @mixin \Eloquent
*/
class IQContentTree extends Model
{
use Sluggable;
use SoftDeletes;
protected $connection = 'mysql_stern';
protected $dates = ['deleted_at'];
protected $table = 'i_q_content_trees';
protected $fillable = [
'name', 'identifier', 'description', 'settings', 'pos', 'active',
];
protected $casts = ['settings' => 'array'];
public function sluggable()
{
return [
'slug' => [
'source' => 'name'
]
];
}
public function iq_content_tree_nodes()
{
return $this->hasMany('App\Models\IQContentTreeNode', 'tree_id', 'id')->orderBy('pos');
}
public function setIdentifierAttribute( $value ) {
if(!isset($value) || $value == ""){
$this->attributes['identifier'] = Str::slug(pre_slug($this->name), '-');
}else{
$this->attributes['identifier'] = Str::slug(pre_slug($value), '-');
}
}
}