problem with exel uploader

I have form like this image is. I'm using EightyNine ExcelImport framework to import exel file. this is pivot table like i have holding company table and pivot table for this holding company dircetors, one holding company may have many directors with active statuses, i want to write all this in my exel file and next import it. my code at this moment looks like that
\EightyNine\ExcelImport\ExcelImportAction::make()
->label('ექსელის ატვირთვა')
->sampleExcel(
sampleData: [
['internal_company_name', 'identification_code', 'holding_company_id', 'director_id', 'is_active'],
],
fileName: 'holding_companies_example.xlsx',
sampleButtonLabel: 'გადმოიწერე_მაგალითი',
customiseActionUsing: fn(Action $action) => $action->color('primary')
->icon('heroicon-m-clipboard')
->requiresConfirmation(),
)
->color('danger'),
\EightyNine\ExcelImport\ExcelImportAction::make()
->label('ექსელის ატვირთვა')
->sampleExcel(
sampleData: [
['internal_company_name', 'identification_code', 'holding_company_id', 'director_id', 'is_active'],
],
fileName: 'holding_companies_example.xlsx',
sampleButtonLabel: 'გადმოიწერე_მაგალითი',
customiseActionUsing: fn(Action $action) => $action->color('primary')
->icon('heroicon-m-clipboard')
->requiresConfirmation(),
)
->color('danger'),
its only adding internal_company_name and indefinitcation_code at this moment
No description
7 Replies
gigiloouu
gigiloouuOP7d ago
anyone? (
toeknee
toeknee7d ago
Check fillable on the model.
gigiloouu
gigiloouuOP7d ago
<?php namespace App\Models; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\HasMany; class HoldingCompany extends Model { use HasFactory; protected $fillable = ['internal_company_name', 'identification_code', 'director_id']; public function directors() { return $this->hasMany(Director::class, 'director_holding_company', 'holding_company_id', 'director_id'); } public function directorHoldingCompany(): HasMany { return $this->hasMany(directorHoldingCompany::class); } } this is my model of holdingcomapny also there is direcor model for pivot table
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class Director extends Model
{
use HasFactory;

protected $fillable = ['name', 'email', 'phone'];

public function holdingCompanies()
{
return $this->belongsToMany(HoldingCompany::class, 'directors_holding_companies', 'director_id', 'holding_company_id');
}
}
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class Director extends Model
{
use HasFactory;

protected $fillable = ['name', 'email', 'phone'];

public function holdingCompanies()
{
return $this->belongsToMany(HoldingCompany::class, 'directors_holding_companies', 'director_id', 'holding_company_id');
}
}
toeknee
toeknee7d ago
you are missing holding_company_id, is_active of the fillable array ?
gigiloouu
gigiloouuOP7d ago
ou wait i will try, may i need it in my holding company model yes its works now but its not adding directors in pivot table :(( what i should do to also add directors in pivot table?
toeknee
toeknee7d ago
I'm not sure how you handle the pvitor tables with. Eightngiths importer. Filamentphp's native importer uses definiton on the column: https://filamentphp.com/docs/3.x/actions/prebuilt-actions/import#importing-relationships
gigiloouu
gigiloouuOP7d ago
u mean use relationship? can u refactor my code ? how i should add it there ?
\EightyNine\ExcelImport\ExcelImportAction::make()
->label('ექსელის ატვირთვა')
->sampleExcel(
sampleData: [
['internal_company_name', 'identification_code', 'holding_company_id', 'director_id', 'is_active'],
],
fileName: 'holding_companies_example.xlsx',
sampleButtonLabel: 'გადმოიწერე_მაგალითი',
customiseActionUsing: fn(Action $action) => $action->color('primary')
->icon('heroicon-m-clipboard')
->requiresConfirmation(),
)
->color('danger'),
\EightyNine\ExcelImport\ExcelImportAction::make()
->label('ექსელის ატვირთვა')
->sampleExcel(
sampleData: [
['internal_company_name', 'identification_code', 'holding_company_id', 'director_id', 'is_active'],
],
fileName: 'holding_companies_example.xlsx',
sampleButtonLabel: 'გადმოიწერე_მაგალითი',
customiseActionUsing: fn(Action $action) => $action->color('primary')
->icon('heroicon-m-clipboard')
->requiresConfirmation(),
)
->color('danger'),

Did you find this page helpful?