(string) $this->encodePrimaryKey($bank_transaction_rule->id), 'name' => (string) $bank_transaction_rule->name, 'rules' => $bank_transaction_rule->rules ?: (array) [], 'auto_convert' => (bool) $bank_transaction_rule->auto_convert, 'matches_on_all' => (bool) $bank_transaction_rule->matches_on_all, 'applies_to' => (string) $bank_transaction_rule->applies_to, 'client_id' => $this->encodePrimaryKey($bank_transaction_rule->client_id) ?: '', 'vendor_id' => $this->encodePrimaryKey($bank_transaction_rule->vendor_id) ?: '', 'category_id' => $this->encodePrimaryKey($bank_transaction_rule->category_id) ?: '', 'is_deleted' => (bool) $bank_transaction_rule->is_deleted, 'created_at' => (int) $bank_transaction_rule->created_at, 'updated_at' => (int) $bank_transaction_rule->updated_at, 'archived_at' => (int) $bank_transaction_rule->deleted_at, ]; } public function includeCompany(BankTransactionRule $bank_transaction_rule) { $transformer = new CompanyTransformer($this->serializer); return $this->includeItem($bank_transaction_rule->company, $transformer, Company::class); } public function includeClient(BankTransactionRule $bank_transaction_rule) { $transformer = new ClientTransformer($this->serializer); if(!$bank_transaction_rule->client) return null; return $this->includeItem($bank_transaction_rule->expense, $transformer, Client::class); } public function includeVendor(BankTransactionRule $bank_transaction_rule) { $transformer = new VendorTransformer($this->serializer); if(!$bank_transaction_rule->vendor) return null; return $this->includeItem($bank_transaction_rule->vendor, $transformer, Vendor::class); } public function includeExpenseCategory(BankTransactionRule $bank_transaction_rule) { $transformer = new ExpenseCategoryTransformer($this->serializer); if(!$bank_transaction_rule->expense_cateogry) return null; return $this->includeItem($bank_transaction_rule->expense_category, $transformer, ExpenseCategory::class); } }