How I can pass args to Laravel Eloquent API Resources constructor and get it to conditional data returning on response?
What I tried:
Controller
$user = User::find(1);
return new UserResource($user, $shortData = true);
API Resource:
public function toArray($request, $shortData)
{
if($short) {
return $shortData;
} else {
return $fullData;
}
}