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)
|
|
|
|
{
|
2019-07-16 03:14:40 +08:00
|
|
|
$res = parent::toArray($request);
|
|
|
|
$res['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
|
|
|
];
|
|
|
|
|
2019-07-16 03:14:40 +08:00
|
|
|
return $res;
|
2018-04-12 09:01:41 +08:00
|
|
|
}
|
|
|
|
}
|