xxxxxxxxxx
// Just call $this->withoutWrapping() before returning the array in
// toArray method of resource
class AccountabilityExpensesResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
*/
public function toArray($request)
{
$this->withoutWrapping();
return [
'uuid' => $this->uuid,
'voucher_path' => $this->voucher_path,
'expense_type' => $this->expense_type,
'expense_date' => $this->expense_date,
'company' => $this->company,
'value' => $this->value,
'justification' => $this->justification
];
}
}
xxxxxxxxxx
/**
* Makes it so that data is not wrapped in a 'data' property
*/
public static $wrap = null;