travel guide
This commit is contained in:
parent
346a7427a5
commit
a1ca534f55
26 changed files with 5788 additions and 3191 deletions
|
|
@ -21,23 +21,23 @@ use Illuminate\Database\Eloquent\Model;
|
|||
* @property int $active
|
||||
* @property \Illuminate\Support\Carbon|null $created_at
|
||||
* @property \Illuminate\Support\Carbon|null $updated_at
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelMagazine findSimilarSlugs($attribute, $config, $slug)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelMagazine whereActive($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelMagazine whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelMagazine whereFullText($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelMagazine whereId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelMagazine whereMetaDescription($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelMagazine whereMetaKeywords($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelMagazine whereMetaTitle($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelMagazine whereName($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelMagazine wherePos($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelMagazine whereScope($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelMagazine whereSlug($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelMagazine whereText($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelMagazine whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelGuide findSimilarSlugs($attribute, $config, $slug)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelGuide whereActive($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelGuide whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelGuide whereFullText($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelGuide whereId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelGuide whereMetaDescription($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelGuide whereMetaKeywords($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelGuide whereMetaTitle($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelGuide whereName($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelGuide wherePos($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelGuide whereScope($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelGuide whereSlug($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelGuide whereText($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelGuide whereUpdatedAt($value)
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class TravelMagazine extends Model
|
||||
class TravelGuide extends Model
|
||||
{
|
||||
|
||||
use Sluggable;
|
||||
|
|
@ -46,7 +46,7 @@ class TravelMagazine extends Model
|
|||
//use the connection to sec. Datebase sterntours
|
||||
protected $connection = 'mysql_stern';
|
||||
|
||||
protected $table = 'travel_magazines';
|
||||
protected $table = 'travel_guides';
|
||||
|
||||
|
||||
protected static $scopes = [
|
||||
|
|
@ -76,6 +76,7 @@ class TravelMagazine extends Model
|
|||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public function getScopeName($key = 0){
|
||||
return isset(self::$scopes[$key]) ? self::$scopes[$key] : '';
|
||||
}
|
||||
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'];
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
namespace App\Models;
|
||||
|
||||
use Carbon;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Storage;
|
||||
use App\Services\Util;
|
||||
|
|
@ -397,6 +397,30 @@ class TravelUserBookingFewo extends Model
|
|||
return number_format(($total_pay - $first_pay + $this->getPriceDepositRaw()), 2, ',', '.');
|
||||
}
|
||||
|
||||
public function getPriceTravelTotalPay(){
|
||||
if($this->attributes['price_travel'] == 0){
|
||||
return 0;
|
||||
}
|
||||
$total_pay = ($this->getPriceTravelTotalRaw() + $this->getPriceServiceRaw());
|
||||
return number_format(($total_pay + $this->getPriceDepositRaw()), 2, ',', '.');
|
||||
}
|
||||
|
||||
public function getDepartureInDays()
|
||||
{
|
||||
if(isset($this->attributes['from_date'])){
|
||||
return Carbon::now()->diffInDays(Carbon::parse($this->attributes['from_date']), false);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function isFromDateAfterDays($days = 30){
|
||||
if(($this->getDepartureInDays() - $days) > 0){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function getBookingDateYear(){
|
||||
return Carbon::parse($this->booking_date)->format('Y');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue