riz
riz
FFilament
Created by riz on 1/6/2024 in #❓┊help
Can't use FileUpload with multiple
if I use hasMany in the model I get this error. ERROR:
Filament\Forms\Components\Section::getRelationship(): Return value must be of type Illuminate\Database\Eloquent\Relations\BelongsTo|Illuminate\Database\Eloquent\Relations\HasOne|Illuminate\Database\Eloquent\Relations\MorphOne|null, Illuminate\Database\Eloquent\Relations\HasMany returned
Filament\Forms\Components\Section::getRelationship(): Return value must be of type Illuminate\Database\Eloquent\Relations\BelongsTo|Illuminate\Database\Eloquent\Relations\HasOne|Illuminate\Database\Eloquent\Relations\MorphOne|null, Illuminate\Database\Eloquent\Relations\HasMany returned
If I understand it correctly from this https://filamentphp.com/docs/3.x/forms/advanced#saving-data-to-relationships thats how I use the FileUpload inside the component Section with relationship. I thought hasOne will work, since multiple in FileUpload will store an array of multiple filename( in my case: attachment_path) in a column. I was expecting my database would store the record like this if I use ->multiple()
id group_id attachment_path
1 34 [file1.png, file2.png]
id group_id attachment_path
1 34 [file1.png, file2.png]
if I use hasMany in the model I get this error. ERROR:
Filament\Forms\Components\Section::getRelationship(): Return value must be of type Illuminate\Database\Eloquent\Relations\BelongsTo|Illuminate\Database\Eloquent\Relations\HasOne|Illuminate\Database\Eloquent\Relations\MorphOne|null, Illuminate\Database\Eloquent\Relations\HasMany returned
Filament\Forms\Components\Section::getRelationship(): Return value must be of type Illuminate\Database\Eloquent\Relations\BelongsTo|Illuminate\Database\Eloquent\Relations\HasOne|Illuminate\Database\Eloquent\Relations\MorphOne|null, Illuminate\Database\Eloquent\Relations\HasMany returned
If I understand it correctly from this https://filamentphp.com/docs/3.x/forms/advanced#saving-data-to-relationships thats how I use the FileUpload inside the component Section with relationship. I thought hasOne will work, since multiple in FileUpload will store an array of multiple filename( in my case: attachment_path) in a column. I was expecting my database would store the record like this if I use ->multiple()
id group_id attachment_path
1 34 [file1.png, file2.png]
id group_id attachment_path
1 34 [file1.png, file2.png]
4 replies
FFilament
Created by riz on 10/20/2023 in #❓┊help
afterCreate() function can't get the last saved record id, dd() show the error below:
using $this->record-refresh() inside the afterCreate(), i get an error: SQLSTATE[42S22]: Column not found: 1054 Unknown column '' in 'where clause',
8 replies
FFilament
Created by riz on 10/20/2023 in #❓┊help
afterCreate() function can't get the last saved record id, dd() show the error below:
if I declare the model like this: class Model extends Pivot then the protected function afterCreate(): void { dd($this->record->id); } shows null, if I check the database, a new record is already added with the id
8 replies
FFilament
Created by riz on 10/20/2023 in #❓┊help
afterCreate() function can't get the last saved record id, dd() show the error below:
dd($this->record); also shows below App\Models\Applicant {#2976 ▼ // app\Filament\Resources\ApplicantResource\Pages\CreateApplicant.php:23 #connection: "mysql" #table: "award_applicant"
8 replies
FFilament
Created by riz on 10/20/2023 in #❓┊help
afterCreate() function can't get the last saved record id, dd() show the error below:
dd($this->record->getKey()); is also null, but I can get $this->record->created_at and other fields except the record id
8 replies
FFilament
Created by riz on 10/20/2023 in #❓┊help
afterCreate() function can't get the last saved record id, dd() show the error below:
dd($this->record->id); shows null
8 replies
FFilament
Created by riz on 10/11/2023 in #❓┊help
Assign default value on a field during AttachAction
thank you, I will read more about this on the documentation
7 replies
FFilament
Created by riz on 10/11/2023 in #❓┊help
Assign default value on a field during AttachAction
What I want is emplement the AttachAction in a RelationManager and save the following fields on the db empl_id -- <w/ user interaction Section::make> assigned_by -- <w/ user interaction TextInput::make> status -- <w/o user interaction> just set the 'status' field to 'Pending' every time I click the attach button on a RM and save it to the DB... somewhere in Edit menu, that's where a user interaction for the 'status' field. so in my case I comment out the Select::make('status') part and add the line Hidden::make('status')->default('Pending'), this one work, but Im not sure if this is the proper way
7 replies
FFilament
Created by riz on 10/11/2023 in #❓┊help
Assign default value on a field during AttachAction
Updated the code but Im not sure if this is the correct way. // Select::make('status') // ->options([ // 'approve' => 'Approve', // 'disapprove' => 'Disapprove', // 'pending' => 'Pending', // 'on-process' => 'On process', // ])->required(), Hidden::make('status')->default('Pending'),
7 replies