serializer); return $this->includeItem($product->user, $transformer, User::class); } /** * @param Product $product * * @return \League\Fractal\Resource\Collection */ public function includeCompany(Product $product) { $transformer = new CompanyTransformer($this->serializer); return $this->includeItem($product->company, $transformer, Company::class); } public function transform(Product $product) { return [ 'id' => $this->encodePrimaryKey($product->id), 'product_key' => $product->product_key ?: '', 'notes' => $product->notes ?: '', 'cost' => (float) $product->cost ?: 0, 'price' => (float) $product->price ?: 0, 'quantity' => (float) ($product->quantity ?: 0.0), 'tax_name1' => $product->tax_name1 ?: '', 'tax_rate1' => (float) $product->tax_rate1 ?: 0, 'tax_name2' => $product->tax_name2 ?: '', 'tax_rate2' => (float) $product->tax_rate2 ?: 0, 'updated_at' => $product->updated_at, 'archived_at' => $product->deleted_at, 'custom_value1' => $product->custom_value1 ?: '', 'custom_value2' => $product->custom_value2 ?: '', 'custom_value3' => $product->custom_value3 ?: '', 'custom_value4' => $product->custom_value4 ?: '', 'is_deleted' => (bool) $product->is_deleted, ]; } }