* * This source file is subject to the MIT license that is bundled * with this source code in the file LICENSE. */ namespace App\Http\Resources\CMS; use Illuminate\Http\Resources\Json\JsonResource; class ArticleResource extends JsonResource { public function toArray($request) { $model = $this; return [ 'id' => (int)$model->id, 'title' => $model->title, 'category_id' => $model->category_id, 'category_name' => $model->category ? $model->category->name : '--', 'cover_resource' => $model->cover_resource, 'short_description' => $model->short_description, 'tags' => $model->tags, 'slug' => $model->slug, 'body' => $model->body, 'organization_id' => $model->organization_id, 'organization' => $model->organization ? $model->organization : [], 'view_count' => $model->view_count, 'good_count' => $model->good_count, 'created_at' => $model->created_at->format("Y/m/d"), 'state' => $model->state, ]; } }