why use a relationship manager?
Hello, I've created a custom page but I can't make a ship relationship on my section. I get an error: Call to a member function quote() on null
What can I do?
<?php
namespace App\Filament\Resources\InvoiceResource\Pages;
use App\Filament\Resources\InvoiceResource;
use App\Models\Invoice;
use Filament\Forms\Components\Group;
use Filament\Forms\Components\Section;
use Filament\Forms\Components\Select;
use Filament\Resources\Pages\Page;
class ViewInvoice extends Page
{
protected static string $resource = InvoiceResource::class;
protected static string $view = 'filament.resources.invoice-resource.pages.view-invoice';
public ?Invoice $record = NULL;
public function getTitle(): string
{
return __('invoice-resource.viewInvoice.title');
}
protected function getFormSchema(): array
{
$tab = array();
// if ($this->record->method_payment == Invoice::BANK_TRANSFER) {
$tab = [
Group::make()
->schema([
Section::make(__('invoice-resource.section.invoice_information'))
->relationship('quote', 'this')
->schema([
Select::make('name')
->options(function () {
dd($this->record->quote);
return $record->quote;
})
->label(__('artist-resource.field.name')),
])
])
];
// }
return $tab;
}
}
<?php
namespace App\Filament\Resources\InvoiceResource\Pages;
use App\Filament\Resources\InvoiceResource;
use App\Models\Invoice;
use Filament\Forms\Components\Group;
use Filament\Forms\Components\Section;
use Filament\Forms\Components\Select;
use Filament\Resources\Pages\Page;
class ViewInvoice extends Page
{
protected static string $resource = InvoiceResource::class;
protected static string $view = 'filament.resources.invoice-resource.pages.view-invoice';
public ?Invoice $record = NULL;
public function getTitle(): string
{
return __('invoice-resource.viewInvoice.title');
}
protected function getFormSchema(): array
{
$tab = array();
// if ($this->record->method_payment == Invoice::BANK_TRANSFER) {
$tab = [
Group::make()
->schema([
Section::make(__('invoice-resource.section.invoice_information'))
->relationship('quote', 'this')
->schema([
Select::make('name')
->options(function () {
dd($this->record->quote);
return $record->quote;
})
->label(__('artist-resource.field.name')),
])
])
];
// }
return $tab;
}
}
0 Replies