Spamworldpro Mini Shell
Spamworldpro


Server : Apache
System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64
User : corals ( 1002)
PHP Version : 7.4.33
Disable Function : exec,passthru,shell_exec,system
Directory :  /home/corals/ts.corals.io/corals-api/Corals/modules/Utility/Traits/Schedules/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/ts.corals.io/corals-api/Corals/modules/Utility/Traits/Schedules/Scheduleable.php
<?php

namespace Corals\Modules\Utility\Traits\Schedules;

use Corals\Modules\Utility\Models\Schedule\Schedule;
use Illuminate\Database\Eloquent\Model;
use Corals\Modules\Utility\Models\Schedule\Schedule as ScheduleModel;
use Carbon\Carbon;

trait Scheduleable
{
    public static function bootScheduleable()
    {
        static::deleted(function (Model $deletedModel) {

            $deletedModel->schedules()->delete();

        });
    }

    public function schedules()
    {
        return $this->morphMany(Schedule::class, 'scheduleable');
    }

    public function isOpen()
    {
        $dayOfWeek = Carbon::now()->format('l');

        $today = substr($dayOfWeek, 0, 3);

        $currentTime = date('h:i:s');

        $open = ScheduleModel::query()->where('day_of_the_week', $today)
            ->where('scheduleable_id', $this->id)
            ->where(function ($parent) use ($currentTime) {
                $parent->where('start_time', '<=', $currentTime)
                    ->Where('end_time', '>=', $currentTime);
            })->first();

        if ($open) {

            return true;
        } else {

            return false;
        }
    }


}

Spamworldpro Mini