F
Filament10mo ago
KinBH

How to get return from model to $form

App/Models/Jogo class Jogo extends Model { use HasFactory, SoftDeletes; protected $dates = ['deleted_at']; public function generateslug() { $slug = Str::random(6); if (self::where('slug', $slug)->count() > 0) self::generateslug(); return $slug; } } I want get this slug to put on my form JogoResource public static function form(Form $form): Form { return $form ->schema([ Forms\Components\Hidden::make('slug') ->disabled() ->default($slug_from_model_here),
3 Replies
KinBH
KinBH10mo ago
I use for id, but how to implement for my case? protected function mutateFormDataBeforeCreate(array $data): array { $data['user_id'] = auth()->id(); return $data; }
LeandroFerreira
LeandroFerreira10mo ago
$data['slug'] = Str::random(6);
$data['slug'] = Str::random(6);
?
Want results from more Discord servers?
Add your server