* * This source file is subject to the MIT license that is bundled * with this source code in the file LICENSE. */ namespace App\Http\Resources\News; use Illuminate\Http\Resources\Json\JsonResource; class MessageResource extends JsonResource { public function toArray($request) { $model = $this; return [ 'id' => (int)$model->id, 'message' => $model->message, 'type' => $model->type, 'resource' => $model->type == 2 ? $model->resource : null, 'resource_type' => $model->resource_type, 'resource_id' => $model->resource_id, 'is_read' => $model->is_read, 'created_at' => $model->created_at->format("Y-m-d H:i:s"), ]; } }