2018-04-12 09:01:41 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Resources;
|
|
|
|
|
2020-03-23 21:31:35 +08:00
|
|
|
use App\Contracts\Resource;
|
2018-04-12 09:01:41 +08:00
|
|
|
|
|
|
|
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,
|
2021-06-09 05:46:15 +08:00
|
|
|
'name' => $this->user->name_private,
|
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
|
|
|
}
|
|
|
|
}
|