phpvms/app/Http/Resources/News.php

30 lines
516 B
PHP
Raw Normal View History

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)
{
$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
];
return $res;
2018-04-12 09:01:41 +08:00
}
}