CMS Info for Header, dyn. Tage, API

This commit is contained in:
Kevin Adametz 2019-12-28 20:15:25 +01:00
parent 7294ccc1d0
commit bed91c4f4a
49 changed files with 3476 additions and 1562 deletions

View file

@ -86,6 +86,8 @@ use Illuminate\Database\Eloquent\Model;
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Booking newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Booking newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Booking query()
* @property-read int|null $arrangements_count
* @property-read int|null $booking_draft_items_count
*/
class Booking extends Model
{

View file

@ -160,6 +160,7 @@ class CMSInfo extends Model
'type' => $type,
]);
}
$content->type = $type;
switch ($content->type){
case 'text':
$content->text = $value;

View file

@ -2,6 +2,8 @@
namespace App\Models;
use App\Services\HTMLHelper;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
/**
@ -27,6 +29,10 @@ use Illuminate\Database\Eloquent\Model;
* @mixin \Eloquent
* @property int $wday
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CMSInfoAvailable whereWday($value)
* @property int|null $special
* @property string|null $date
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CMSInfoAvailable whereDate($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CMSInfoAvailable whereSpecial($value)
*/
class CMSInfoAvailable extends Model
{
@ -34,21 +40,78 @@ class CMSInfoAvailable extends Model
protected $table = 'c_m_s_info_availables';
protected $fillable = [
'type', 'wday', 'active', 'from', 'to'
'type', 'wday', 'active', 'from', 'to', 'special', 'date'
];
protected $casts = [
'active' => 'bool',
'special' => 'bool',
];
protected static $days;
public static function getContentBySlug($type, $wday){
return CMSInfoAvailable::whereType($type)->whereWday($wday)->first();
public function getDateAttribute()
{
return isset($this->attributes['date']) ? Carbon::parse($this->attributes['date'])->format('d.m.Y') : '';
}
public static function setContentBySlug($type, $wday, $values){
public function setDateAttribute($value)
{
if (!$value) {
$this->attributes['date'] = null;
} else {
$this->attributes['date'] = Carbon::parse($value)->format('Y-m-d');
}
}
$content = CMSInfoAvailable::whereType($type)->whereWday($wday)->first();
public static function getWeekWithDate($wday = false)
{
if(!self::$days){
self::createWeekWithDate();
}
if($wday){
return self::$days[$wday];
}
return self::$days;
}
public static function createWeekWithDate(){
$days = HTMLHelper::getDeDays();
$now = \Carbon::now();
$day_of = $now->dayOfWeekIso;
//days after now
for ($i = $day_of; $i<=7; $i++){
$days[$i] = [
'name'=>$days[$i],
'date'=>$now->format("d.m.Y"),
];
$now->modify('+1 day');
}
//days before now
for ($i = 1; $i<$day_of; $i++) {
$days[$i] = [
'name'=>$days[$i],
'date'=>$now->format("d.m.Y"),
];
$now->modify('+1 day');
}
//add
self::$days = $days;
}
public static function getContentBySlug($type, $wday, $special = false){
$model = CMSInfoAvailable::whereType($type)->whereWday($wday)->whereSpecial($special)->first();
if($model){
return $model;
}
return new CMSInfoAvailable();
}
public static function setContentBySlug($type, $wday, $values, $special = false){
$content = CMSInfoAvailable::whereType($type)->whereWday($wday)->whereSpecial($special)->first();
if(!$content) {
$content = CMSInfoAvailable::create([
'type' => $type,
@ -59,4 +122,46 @@ class CMSInfoAvailable extends Model
$content->save();
return $content;
}
public static function getSpecialsBy($type){
return CMSInfoAvailable::whereType($type)->whereSpecial(true)->get();
}
public static function getNextSpecialDateBy($type, $wday){
$content = CMSInfoAvailable::whereType($type)->whereWday($wday)->whereSpecial(true)->orderBy('date', 'DESC')->first();
$now = \Carbon::now();
$week = 7;
if($content){
$now = \Carbon::parse($content->date);
}
$day_of = $now->dayOfWeekIso;
$week += ($wday - $day_of);
$now->modify('+'.$week.' days');
return $now;
}
public function fromMinutes (){
if(strpos($this->from, ":")){
$from = explode(":", $this->from);
$hours = isset($from[0]) ? (int) $from[0] : 0;
$minute = isset($from[1]) ? (int) $from[1] : 0;
return $hours * 60 + $minute;
}
return 0;
}
public function toMinutes (){
if(strpos($this->to, ":")){
$to = explode(":", $this->to);
$hours = isset($to[0]) ? (int) $to[0] : 0;
$minute = isset($to[1]) ? (int) $to[1] : 0;
return $hours * 60 + $minute;
}
return 0;
}
}

View file

@ -23,6 +23,8 @@ use Illuminate\Database\Eloquent\Model;
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Draft newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Draft newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Draft query()
* @property-read int|null $draft_items_count
* @property-read int|null $travel_program_drafts_count
*/
class Draft extends Model
{

View file

@ -26,6 +26,7 @@ use Illuminate\Database\Eloquent\Model;
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\DraftType query()
* @property int|null $pos
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\DraftType wherePos($value)
* @property-read int|null $draft_items_count
*/
class DraftType extends Model
{

View file

@ -100,6 +100,11 @@ use HTMLHelper;
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Feedback newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Feedback query()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Feedback whereTravelGuideContentId($value)
* @property string|null $title_short
* @property string|null $before_title
* @property-read int|null $children_count
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Feedback whereBeforeTitle($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Feedback whereTitleShort($value)
*/
class Feedback extends Page
{

View file

@ -58,6 +58,11 @@ use Reliese\Database\Eloquent\Model as Eloquent;
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\FewoLodging whereSingleName($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\FewoLodging whereTypeId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\FewoLodging whereZipCode($value)
* @property-read int|null $fewo_lodging_images_count
* @property-read int|null $fewo_prices_count
* @property-read int|null $fewo_reservations_count
* @property-read int|null $pages_count
* @property-read int|null $travel_user_booking_fewos_count
*/
class FewoLodging extends Model
{

View file

@ -23,6 +23,8 @@ use Illuminate\Database\Eloquent\Model;
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\FewoLodgingGroup query()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\FewoLodgingGroup whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\FewoLodgingGroup whereName($value)
* @property-read int|null $fewo_lodging_group_images_count
* @property-read int|null $fewo_lodgings_count
*/
class FewoLodgingGroup extends Model
{

View file

@ -22,6 +22,7 @@ use Illuminate\Database\Eloquent\Model;
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\FewoLodgingType query()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\FewoLodgingType whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\FewoLodgingType whereName($value)
* @property-read int|null $fewo_lodgings_count
*/
class FewoLodgingType extends Model
{

View file

@ -32,6 +32,7 @@ use Illuminate\Database\Eloquent\Model;
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\FewoSeason whereName($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\FewoSeason whereOnlyWeekday($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\FewoSeason whereToDate($value)
* @property-read int|null $fewo_prices_count
*/
class FewoSeason extends Model
{

View file

@ -47,6 +47,7 @@ use Illuminate\Support\Str;
* @property int|null $root_id
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\IQContentTree wherePageId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\IQContentTree whereRootId($value)
* @property-read int|null $iq_content_tree_nodes_count
*/
class IQContentTree extends Model
{

View file

@ -53,6 +53,8 @@ use Illuminate\Support\Str;
* @mixin \Eloquent
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\IQContentSite[] $iq_content_site
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\IQContentSite[] $iq_content_sites
* @property-read int|null $iq_content_sites_count
* @property-read int|null $iq_content_tree_node_childs_count
*/
class IQContentTreeNode extends Model
{

View file

@ -97,6 +97,10 @@ use Illuminate\Database\Eloquent\Model;
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Page newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Page query()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Page whereTravelGuideContentId($value)
* @property string|null $title_short
* @property string|null $before_title
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Page whereBeforeTitle($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Page whereTitleShort($value)
*/
class Page extends Model
{

View file

@ -17,6 +17,7 @@ use Illuminate\Database\Eloquent\Model;
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Sym\ArrangementTemplate newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Sym\ArrangementTemplate newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Sym\ArrangementTemplate query()
* @property-read int|null $arrangements_count
*/
class ArrangementTemplate extends Model
{

View file

@ -26,6 +26,7 @@ use Illuminate\Database\Eloquent\Model;
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelBookingFewoChannel whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelBookingFewoChannel whereName($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelBookingFewoChannel whereUpdatedAt($value)
* @property-read int|null $travel_user_booking_fewos_count
*/
class TravelBookingFewoChannel extends Model
{

View file

@ -28,6 +28,7 @@ use Illuminate\Database\Eloquent\Model;
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelClass newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelClass newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelClass query()
* @property-read int|null $travel_program_drafts_count
*/
class TravelClass extends Model
{

View file

@ -57,6 +57,7 @@ use Illuminate\Support\Str;
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelCountry whereTextBefore($value)
* @property array|null $contact_lands
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelCountry whereContactLands($value)
* @property-read int|null $travel_nationality_requirements_count
*/
class TravelCountry extends Model
{

View file

@ -47,6 +47,7 @@ use Illuminate\Database\Eloquent\Model;
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\IQContentSite[] $iq_content_sites
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelGuide whereBoxImageUrl($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelGuide whereCountryId($value)
* @property-read int|null $iq_content_sites_count
*/
class TravelGuide extends Model
{

View file

@ -97,6 +97,10 @@ use Illuminate\Database\Eloquent\Model;
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelPageGuide whereTreeRoot($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelPageGuide whereUpdatedAt($value)
* @mixin \Eloquent
* @property string|null $title_short
* @property string|null $before_title
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelPageGuide whereBeforeTitle($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelPageGuide whereTitleShort($value)
*/
class TravelPageGuide extends Model
{

View file

@ -109,6 +109,8 @@ use Illuminate\Database\Eloquent\Model;
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelProgram newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelProgram newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelProgram query()
* @property-read int|null $classes_count
* @property-read int|null $travel_program_drafts_count
*/
class TravelProgram extends Model
{

View file

@ -66,6 +66,7 @@ use Illuminate\Database\Eloquent\Model;
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelUser whereTravelNationalityId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelUser whereUpdatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelUser whereZipcode($value)
* @property-read int|null $travel_user_booking_fewos_count
*/
class TravelUser extends Model
{