phpvms/app/Http/Resources/PirepComment.php

40 lines
814 B
PHP
Raw Normal View History

<?php
namespace App\Http\Resources;
use App\Contracts\Resource;
/**
* @mixin \App\Models\PirepComment
*/
class PirepComment extends Resource
{
/**
* Transform the resource into an array.
*
2018-08-27 00:40:04 +08:00
* @param \Illuminate\Http\Request $request
*
* @return array
*/
public function toArray($request)
{
if (!$this->user) {
return [];
}
$user = $this->user;
return [
'id' => $this->id,
'comment' => $this->comment,
'created_at' => $this->created_at,
'user' => [
'id' => $user->id,
'pilot_id' => $user->pilot_id,
'ident' => $user->ident,
'name' => $user->name,
],
];
}
}