Urufu
Urufu
FFilament
Created by namrata on 3/15/2024 in #❓┊help
Import Action
Traducción al inglés: Hi, thanks for replying. In the CSV, I have information for both tables, Employee and Payment. I wanted to first register the employee data with
$employee = $this->createOrUpdateEmployee();
$employee = $this->createOrUpdateEmployee();
, and then register their payments with $payment = $this->createOrUpdatePayment($employee); Each row in the CSV has this information. In summary, I need to insert into both tables for each row that is processed.
20 replies
FFilament
Created by namrata on 3/15/2024 in #❓┊help
Import Action
Hi, I'm trying to import a CSV file that contains Employee, Payment and Detail data, I've been trying to do this the following way, but I always get the error:
[previous exception] [object] (PDOException(code: 42S22): SQLSTATE[42S22]: Column not found: 1054 Unknown column 'dni' in 'field list' at D:\\LaravelVemto\\cpagos-filament-l11\\vendor\\laravel\\framework\\src\\Illuminate\\Database\\Connection.php:592)
[previous exception] [object] (PDOException(code: 42S22): SQLSTATE[42S22]: Column not found: 1054 Unknown column 'dni' in 'field list' at D:\\LaravelVemto\\cpagos-filament-l11\\vendor\\laravel\\framework\\src\\Illuminate\\Database\\Connection.php:592)
However, the 'dni' field (which is the first in ImportColum), is in the Employee model and it seems that it wants to insert it into Payment, any suggestions? I also tried with the hooks and it gives me the same result, my current code is:
public function resolveRecord(): ?Payment
{
$employee = $this->createOrUpdateEmployee();
$payment = $this->createOrUpdatePayment($employee);
return $payment;
}

protected function createOrUpdateEmployee(): Employee
{
return Employee::updateOrCreate(
['dni' => $this->data['dni']],
[
'name' => $this->data['name'],
]
);
}

protected function createOrUpdatePayment(Employee $employee): Payment
{
[$year, $month] = $this->parsePeriod($this->data['periodo']);

$payment = Payment::updateOrCreate(
[
'employee_id' => $employee->id,
'year' => $year,
'month' => $month,
],
[
'user_id' => auth()->id(),
'total_haber' => $this->data['total_haber'],

'pension_type' => $this->data['pension_type'],

]
);
return $payment;
}
public function resolveRecord(): ?Payment
{
$employee = $this->createOrUpdateEmployee();
$payment = $this->createOrUpdatePayment($employee);
return $payment;
}

protected function createOrUpdateEmployee(): Employee
{
return Employee::updateOrCreate(
['dni' => $this->data['dni']],
[
'name' => $this->data['name'],
]
);
}

protected function createOrUpdatePayment(Employee $employee): Payment
{
[$year, $month] = $this->parsePeriod($this->data['periodo']);

$payment = Payment::updateOrCreate(
[
'employee_id' => $employee->id,
'year' => $year,
'month' => $month,
],
[
'user_id' => auth()->id(),
'total_haber' => $this->data['total_haber'],

'pension_type' => $this->data['pension_type'],

]
);
return $payment;
}
I hope you can give me some ideas, thanks.
20 replies
FFilament
Created by Peagah on 7/26/2023 in #❓┊help
How to consume an external API with Filament Tables
thanks so much
70 replies
FFilament
Created by Peagah on 7/26/2023 in #❓┊help
How to consume an external API with Filament Tables
i think the new link is this https://filamentphp.com/community/how-to-consume-an-external-api-with-filament-tables , but can u show me your code please
70 replies
FFilament
Created by Peagah on 7/26/2023 in #❓┊help
How to consume an external API with Filament Tables
Hi, did Saloon work for you? Could you show an example of how you used it?
70 replies