relationship on a resource
I need a relationship on a resource, my main table is "employee", my secondary table is "employeeJob" this get "employee_id", what I try to do is that my form obtains the data from the "employeeJob" table, so that I can also edit them with the other records of "employee", its posible?.
try to do something like this: look picture
for saved the data, i use: protected function handleRecordCreation(array $data): Model
{
$employee = static::getModel()::create($data);
$current_date = Carbon::today();
$job = Job::where('id', $data['job_id'])->first();
$job = EmployeeJob::create([
'employee_id' => $employee->id,
'job_id' => $data['job_id'],
'title' => $job->name,
'type' => $data['type'],
'payment_amount' => $data['payment_amount'],
'payment_unit' => $data['payment_unit'],
'start_date' => $current_date
]);
return $employee;
}
7 Replies
Pretty sure you have to put it in a section or something similar
And then you can use the ->relationship() method
For a select element, you need to use
->relationship()
and the textinput?
As long as it is in the section it should work
thanks to all, i solved like this: Fieldset::make('')
->relationship('employeeJob')
->schema([...])
Filament
Getting started - Resources - Admin Panel - Filament
The elegant TALL stack admin panel for Laravel artisans.