Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?php
namespace App\Http\Resources;
use App\Models\Device;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
/**
* Class PostResource
* @package App\Http\Resources
* @mixin Post
*/
class PostResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param Request $request
* @return array
*/
public function toArray($request)
{
return [
"id" => $this->id,
"title" => $this->title,
"tags" => $this->whenLoaded("tags")->makeHidden('pivot'), // <-- ¡fíjate en esto!
];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment