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/medad.corals.io/Corals/modules/Medad/Transformers/API/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/medad.corals.io/Corals/modules/Medad/Transformers/API/CommonAPIBaseTransformer.php
<?php

namespace Corals\Modules\Medad\Transformers\API;

use Corals\Foundation\Transformers\APIBaseTransformer;
use Illuminate\Support\Arr;
use Illuminate\Support\Str;

class CommonAPIBaseTransformer extends APIBaseTransformer
{
    protected $userAttributes = ['id', 'full_name', 'email', 'phone_number', 'phone_country_code'];
    protected $companyAttributes = ['id', 'name'];
    protected $branchAttributes = ['id', 'name'];
    protected $locationAttributes = ['id', 'name'];
    protected $purchaseOrderAttributes = ['id', 'code', 'address', 'lat', 'long', 'project'];
    protected $commentAttributes = ['id', 'body', 'status', 'author_id'];

    public function presentAPIModel($model, $modelPresenter)
    {
        if (!$model) {
            return null;
        }

        $presenter = $model->setPresenter($modelPresenter)->presenter();

        $attrMethod = Str::camel(class_basename($model)) . 'Attributes';
        if (property_exists($this, $attrMethod)) {
            return Arr::only($presenter, $this->{$attrMethod});
        }

        return $presenter;
    }

    protected function getAttachmentsList($model)
    {
        return $model->media->map(function ($media) {
            $data = Arr::only($media->toArray(), [
                'id',
                'file_name',
                'mime_type',
            ]);

            if (Str::startsWith($media->mime_type, 'image')) {
                $icon = 'image';
            } elseif (Str::startsWith($media->mime_type, 'video')) {
                $icon = 'video';
            } elseif (Str::startsWith($media->mime_type, 'audio')) {
                $icon = 'audio';
            } elseif (Str::contains($media->mime_type, 'pdf')) {
                $icon = 'pdf';
            } else {
                $icon = 'document';
            }

            $data['thumbnail'] = asset('assets/corals/images/' . $icon . '.png');
            $data['url'] = url('api/v1/media/' . $media->id);
            $data['description'] = $media->getCustomProperty('description');
            $data['created_at'] = format_date_time($media->created_at);

            return $data;
        });
    }
}

Spamworldpro Mini