<?php

namespace [% namespace %];

use Illuminate\Http\Resources\Json\Resource;

class [% api_resource_class %] extends Resource
{
    /**
     * The response message
     *
     * @var mixed
     */
    protected $message;

    /**
     * Create a new resource instance.
     *
     * @param  mixed  $resource
     * @param  mixed  $message
     *
     * @return void
     */
    public function __construct($resource, $message = null)
    {
        parent::__construct($resource);

        $this->message = $message;
    }

    /**
     * Transform the resource into an array.
     *
     * @param \Illuminate\Http\Request $request
     *
     * @return array
     */
    public function toArray($request)
    {
        return [
[% model_api_array %]
        ];
    }

    /**
     * Get any additional data that should be returned with the resource array.
     *
     * @param \Illuminate\Http\Request $request
     *
     * @return array
     */
    public function with($request)
    {
        return [
            'success' => true,
            'message' => $this->message,
        ];
    }
}
