%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /home/forge/api-takeaseat.eco-n-tech.co.uk/app/Http/Resources/
Upload File :
Create Path :
Current File : //home/forge/api-takeaseat.eco-n-tech.co.uk/app/Http/Resources/MessageResource.php

<?php

namespace App\Http\Resources;

use Illuminate\Http\Resources\Json\JsonResource;
use Illuminate\Contracts\Encryption\DecryptException;
use Illuminate\Support\Facades\Crypt;

class MessageResource extends JsonResource
{
    /**
     * Transform the resource into an array.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return array
     */
    public function toArray($request)
    {
        try {
            $decrypted = Crypt::decryptString($this->message);
        } catch (DecryptException $e) {
            $decrypted = $e->getMessage();
        }

        return [
            'id' => $this->id,
            'photo' => asset('images/user-placeholder.png'),
            'user' => new UserResource($this->whenLoaded('user')),
            'name' => $this->name,
            'email' => $this->email,
            'phone' => $this->phone,
            'message' => $decrypted,
            'read' => $this->read,
            'created_at' => $this->created_at->format('d/m/Y H:i:s')
        ];
    }
}

Zerion Mini Shell 1.0