1234567891011121314151617181920212223242526272829303132 |
- <?php
- /*
- * This file is part of the Jiannei/lumen-api-starter.
- *
- * (c) Jiannei <longjian.huang@foxmail.com>
- *
- * 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"),
- ];
- }
- }
|