travel guide
This commit is contained in:
parent
346a7427a5
commit
a1ca534f55
26 changed files with 5788 additions and 3191 deletions
63
app/Models/TravelPageGuide.php
Normal file
63
app/Models/TravelPageGuide.php
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class TravelPageGuide extends Model
|
||||
{
|
||||
protected $connection = 'mysql_stern';
|
||||
|
||||
protected $table = 'page';
|
||||
|
||||
protected $fillable = [
|
||||
'slug',
|
||||
'status',
|
||||
'show_in_navi',
|
||||
'order',
|
||||
'title',
|
||||
'pagetitle',
|
||||
'description',
|
||||
'keywords',
|
||||
'content_new',
|
||||
'travel_guide_content_id',
|
||||
];
|
||||
|
||||
|
||||
private static $pages = [];
|
||||
|
||||
public static function getPageGuides($setKey = false){
|
||||
$values = self::where('model', 'travel_guide')->where('lvl', 1)->orderBy('order')->get();
|
||||
|
||||
foreach ($values as $value){
|
||||
self::$pages[] = $value;
|
||||
|
||||
$value->checkChilds();
|
||||
if($childs = $value->getChilds()){
|
||||
foreach ($childs as $child){
|
||||
$ret[] = $child;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return self::$pages;
|
||||
}
|
||||
|
||||
public function checkChilds(){
|
||||
if($childs = $this->getChilds()){
|
||||
foreach ($childs as $child){
|
||||
self::$pages[] = $child;
|
||||
$child->checkChilds();
|
||||
}
|
||||
}
|
||||
}
|
||||
public function getChilds(){
|
||||
return TravelPageGuide::where('parent_id', $this->id)->where('lvl', ($this->lvl+1))->orderBy('order')->get();
|
||||
}
|
||||
|
||||
public function getContentNewAttribute()
|
||||
{
|
||||
return isset($this->attributes['content_new']) ? $this->attributes['content_new'] : $this->attributes['content'];
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue