MeniV
MeniV
FFilament
Created by MeniV on 10/21/2023 in #❓┊help
Counting relations in infolist
Thanks!
6 replies
FFilament
Created by MeniV on 10/11/2023 in #❓┊help
Value in Select component
No description
4 replies
FFilament
Created by MeniV on 9/1/2023 in #❓┊help
Pivot table with extra json column
12 replies
FFilament
Created by MeniV on 9/1/2023 in #❓┊help
Pivot table with extra json column
Can't find any documentation on a pivotmodel... So I created a 'pivot model' named DocumentPersoon.php
class DocumentPersoon extends Model
{
protected $table = 'document_persoon';
protected $fillable = ['rollen'];
protected $casts = ['rollen' => 'json'];
}
class DocumentPersoon extends Model
{
protected $table = 'document_persoon';
protected $fillable = ['rollen'];
protected $casts = ['rollen' => 'json'];
}
How to use it in the relationmanager?
12 replies
FFilament
Created by MeniV on 9/1/2023 in #❓┊help
Pivot table with extra json column
maybe a bug? or not yet implemented?
12 replies
FFilament
Created by MeniV on 9/1/2023 in #❓┊help
Pivot table with extra json column
yes, gives the same error
12 replies
FFilament
Created by MeniV on 9/1/2023 in #❓┊help
Pivot table with extra json column
12 replies
FFilament
Created by MeniV on 9/1/2023 in #❓┊help
Pivot table with extra json column
PersoonRelationManager.php:
->schema([
Forms\Components\TextInput::make('voornaam')->label('Voornaam'),
Forms\Components\TextInput::make('achternaam')->label('Achternaam'),
Forms\Components\TextInput::make('alias')->label('Alias'),
Forms\Components\TagsInput::make('rollen')->label('Rol'), // the json column
]),
->schema([
Forms\Components\TextInput::make('voornaam')->label('Voornaam'),
Forms\Components\TextInput::make('achternaam')->label('Achternaam'),
Forms\Components\TextInput::make('alias')->label('Alias'),
Forms\Components\TagsInput::make('rollen')->label('Rol'), // the json column
]),
Persoon.php:
class Persoon extends Model
{
protected $fillable = ['voornaam', 'achternaam','alias', 'rollen'];

protected $casts = ['rollen' => 'json',];

public function documents(): \Illuminate\Database\Eloquent\Relations\BelongsToMany
{
return $this->belongsToMany(\App\Models\Document::class, 'document_persoon', 'document_id', 'persoon_id')
->withPivot(['rollen'])->withTimestamps();
}
}
class Persoon extends Model
{
protected $fillable = ['voornaam', 'achternaam','alias', 'rollen'];

protected $casts = ['rollen' => 'json',];

public function documents(): \Illuminate\Database\Eloquent\Relations\BelongsToMany
{
return $this->belongsToMany(\App\Models\Document::class, 'document_persoon', 'document_id', 'persoon_id')
->withPivot(['rollen'])->withTimestamps();
}
}
Document.php:
protected $fillable = [
'name', 'descr', 'link', 'details',
];

protected $casts = [
'details' => 'json',
'rollen' => 'json',
];


public function persoons(): BelongsToMany
{
return $this->belongsToMany(Persoon::class, 'document_persoon', 'persoon_id', 'document_id')
->withPivot(['rollen'])->withTimestamps();
}


}
protected $fillable = [
'name', 'descr', 'link', 'details',
];

protected $casts = [
'details' => 'json',
'rollen' => 'json',
];


public function persoons(): BelongsToMany
{
return $this->belongsToMany(Persoon::class, 'document_persoon', 'persoon_id', 'document_id')
->withPivot(['rollen'])->withTimestamps();
}


}
Migrations:
Schema::create('document_persoon', function (Blueprint $table) {
$table->bigIncrements('id');
$table->foreignIdFor(Persoon::class);
$table->foreignIdFor(Document::class);
$table->json('rollen')->nullable();
$table->timestamps();
Schema::create('document_persoon', function (Blueprint $table) {
$table->bigIncrements('id');
$table->foreignIdFor(Persoon::class);
$table->foreignIdFor(Document::class);
$table->json('rollen')->nullable();
$table->timestamps();
12 replies
FFilament
Created by MeniV on 8/28/2023 in #❓┊help
mutateFormDataBeforeSave doesn't initially save to.
Thanks!
5 replies