2018-04-12 09:01:41 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Resources;
|
|
|
|
|
|
|
|
use Illuminate\Http\Resources\Json\Resource;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Class Response
|
|
|
|
*/
|
|
|
|
class News extends Resource
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Transform the resource into an array.
|
|
|
|
*
|
2018-08-27 00:40:04 +08:00
|
|
|
* @param \Illuminate\Http\Request $request
|
|
|
|
*
|
2018-04-12 09:01:41 +08:00
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function toArray($request)
|
|
|
|
{
|
|
|
|
$resp = parent::toArray($request);
|
|
|
|
$resp['user'] = [
|
2018-08-27 00:40:04 +08:00
|
|
|
'id' => $this->user->id,
|
|
|
|
'name' => $this->user->name,
|
2018-04-12 09:01:41 +08:00
|
|
|
];
|
|
|
|
|
|
|
|
return $resp;
|
|
|
|
}
|
|
|
|
}
|