KinBH
Salve multiple relation
I was able to figure out the problem. It was necessary to make the fields nullable because Filament saves null first and then updates, so it was generating the error. With this problem solved, now I have another lol. When I use MULTIPLE os athlets, POST form comes as an array: update teams set athlete_id = ["2","1"], teams.updated_at = 2024-05-17 14:14:31 where id = 6 ... However, the field is a bigInt due to the relationship. How do I make Filament save this array line by line?
competicoe_id | atlhet_id
13 replies
Salve multiple relation
nothing change after change hasMany. QLSTATE[HY000]: General error: 1364 Field 'atleta_id' doesn't have a default value:
INSERT INTO equipes (competicoe_id, updated_at, created_at) VALUES....
"atleta_id" not show on query
"atleta_id" not show on query
13 replies
Salve multiple relation
yes, both:
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
class Equipes extends Model
{
use HasFactory;
use SoftDeletes;
protected $guarded = [];
protected $fillable = ['atleta_id', 'competicoe_id'];
protected $dates = ['created_at', 'updated_at', 'deleted_at'];
public function atletas()
{
return $this->belongsTo(Atleta::class, 'atleta_id');
}
public function competicoes()
{
return $this->belongsTo(Competicoe::class, 'competicoe_id');
}
}
13 replies