orchidsoftware / platform

Orchid is a @laravel package that allows for rapid application development of back-office applications, admin/user panels, and dashboards.
https://orchid.software
MIT License
4.26k stars 631 forks source link

Closures for fromModel #2833

Open misog opened 1 month ago

misog commented 1 month ago

Hi, consider this:

Relation::make('account')->fromModel(Account::class, 'first_name')->title('Account'),

I would like to do something like this:

Relation::make('account')->fromModel(Account::class, fn ($model) => $model->first_name . ' ' . $model->last_name)->title('Account'),

Or this:

Relation::make('account')->fromModel(Account::class, fn ($model) => $model->getFullName())->title('Account'),

I do not want to use model attributes.