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

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/ts.corals.io/corals-api/Corals/core/Foundation/Transformers/BaseTransformer.php
<?php

namespace Corals\Foundation\Transformers;

use Illuminate\Support\Arr;
use League\Fractal\TransformerAbstract;

class BaseTransformer extends TransformerAbstract
{
    protected $resource_url;
    protected $resource_route;
    protected $extras = null;

    public function __construct($extras = [])
    {
        $this->extras = $extras;
    }

    /**
     * @param $model
     * @param null $id
     * @return string
     */
    public function generateCheckboxElement($model, $id = null)
    {

        if (is_null($id)) {
            $modelHashedId = $model->hashed_id;
        } else {
            $modelHashedId = $id;
        }

        return '<div class="custom-control custom-checkbox">
               <input type="checkbox" class="datatable-row-checkbox custom-control-input" name="bulk_selected[]" 
               value="' . $modelHashedId . '" id="' . $modelHashedId . '_checkbox" />
               <label class="custom-control-label" for="' . $modelHashedId . '_checkbox"> </label>
               </div>';
    }

    /**
     * @param $model
     * @param array $actions
     * @return array|string
     * @throws \Throwable
     */
    protected function actions($model, array $actions = [])
    {
        if (\Arr::has($this->extras, 'include-action') && !\Arr::get($this->extras, 'include-action')) {
            return '';
        }

        $modelActions = $model->getActions(true);

        $actions = array_merge(empty($modelActions) ? [] : $modelActions, $actions);

        $actions = collect($actions)->filter(function ($action) {
            return !empty($action);
        });

        if (view()->exists('components.item_actions')) {
            return view('components.item_actions', ['actions' => $actions->toArray()])->render();
        } else {
            return '';
        }
    }

    /**
     * @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 (!Arr::has($transformedArray, 'identifier') && $model) {
            $transformedArray['identifier'] = user() && user()->can('view', $model) ? HtmlElement('a',
                ['href' => $model->getShowURL()], $model->getIdentifier()) : $model->getIdentifier();
        }

        return $transformedArray;
    }
}

Spamworldpro Mini