mirror of
https://github.com/filamentphp/filament.git
synced 2026-09-24 15:42:09 +08:00
Initial setup for adding meta fields to fieldsets (via laravel-metable from @plank)
This commit is contained in:
@@ -18,10 +18,11 @@ The theme of this admin is "Light and Fast" – just enough to get you started a
|
||||
|
||||
- Setup tests (via [Testbench Component](https://github.com/orchestral/testbench)) and start creating them for existing features.
|
||||
- _I'm going to be very honest here, I don't know much about testing within a package, so this will be completely new to me and I would really appreciate some help on getting things setup for best practices etc._
|
||||
- Update the `User` model to implement [laravel-metable](https://github.com/plank/laravel-metable), allowing the addition of custom meta fields in a pretty flexible way beyond the core required schema.
|
||||
- Create new `Globals` feature for managing arbitrary app data.
|
||||
- Considering implementing [laravel-metable](https://github.com/plank/laravel-metable).
|
||||
- Entirely composed of [laravel-metable](https://github.com/plank/laravel-metable)
|
||||
- Create new `Resources` feature. Allowing a user to create a generic resource with schemaless attributes managed by custom fields.
|
||||
- Considering implementing [laravel-metable](https://github.com/plank/laravel-metable) in this feature as well, as it would allow custom fields in a pretty flexible way.
|
||||
- Implement [laravel-metable](https://github.com/plank/laravel-metable) in this feature as well, as it would allow the addition of custom meta fields in a pretty flexible way beyond the core required schema.
|
||||
- Create a `GraphQL` API using [Lighthouse](https://github.com/nuwave/lighthouse) and corresponding admin section (likely using [GraphiQL](https://github.com/graphql/graphiql)) for previewing the API. _This one is pretty opinionated_ and needs to be in the core (our team at [East Slope Studio](https://eastslope.studio) uses it extensively for our decoupled front-end web and app development projects (built with Eleventy, React, React Native etc.).
|
||||
|
||||
---
|
||||
@@ -40,11 +41,32 @@ composer dump-autoload
|
||||
php artisan db:seed --class=FilamentSeeder
|
||||
```
|
||||
|
||||
Add the necessary `Filament\Traits\FilamentUser` trait to your `App\User` model.
|
||||
## Filament User
|
||||
|
||||
---
|
||||
Before you can use Filament, you must add the necessary `Filament\Traits\FilamentUser` trait to your `App\User` model.
|
||||
|
||||
## Create a user
|
||||
Example:
|
||||
|
||||
```php
|
||||
<?php
|
||||
|
||||
namespace App;
|
||||
|
||||
use Illuminate\Contracts\Auth\MustVerifyEmail;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Filament\Traits\FilamentUser;
|
||||
|
||||
class User extends Authenticatable
|
||||
{
|
||||
use Notifiable;
|
||||
use FilamentUser;
|
||||
|
||||
// ...
|
||||
}
|
||||
```
|
||||
|
||||
### Create a user
|
||||
|
||||
```bash
|
||||
php artisan filament:user
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
"driesvints/blade-icons": "^2.1",
|
||||
"graham-campbell/markdown": "^12.0",
|
||||
"filament/field-file": "dev-master",
|
||||
"plank/laravel-metable": "^2.1",
|
||||
"laravel/ui": "^2.0",
|
||||
"league/glide-laravel": "^1.0",
|
||||
"livewire/livewire": "^1.0",
|
||||
|
||||
@@ -147,7 +147,7 @@ class FilamentServiceProvider extends ServiceProvider
|
||||
{
|
||||
if ($this->app->runningInConsole()) {
|
||||
$this->loadMigrationsFrom($this->app['filament']->basePath('database/migrations'));
|
||||
$this->loadMigrationsFrom(base_path('vendor/appstract/laravel-meta/database/migrations'));
|
||||
$this->loadMigrationsFrom(base_path('vendor/plank/laravel-metable/migrations'));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ namespace Filament\Http\Livewire;
|
||||
|
||||
use Livewire\Component;
|
||||
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
||||
use Filament\Traits\Livewire\HasForm;
|
||||
use Filament\Traits\HasForm;
|
||||
use Filament\Models\Permission;
|
||||
|
||||
class PermissionCreate extends Component
|
||||
|
||||
@@ -4,7 +4,7 @@ namespace Filament\Http\Livewire;
|
||||
|
||||
use Livewire\Component;
|
||||
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
||||
use Filament\Traits\Livewire\HasForm;
|
||||
use Filament\Traits\HasForm;
|
||||
use Filament\Models\Permission;
|
||||
|
||||
class PermissionEdit extends Component
|
||||
@@ -14,7 +14,7 @@ class PermissionEdit extends Component
|
||||
public function mount(Permission $permission)
|
||||
{
|
||||
$this->authorize('edit', $permission);
|
||||
$this->setupForm($permission);
|
||||
$this->initForm($permission);
|
||||
}
|
||||
|
||||
public function save()
|
||||
|
||||
@@ -4,7 +4,7 @@ namespace Filament\Http\Livewire;
|
||||
|
||||
use Livewire\Component;
|
||||
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
||||
use Filament\Traits\Livewire\HasForm;
|
||||
use Filament\Traits\HasForm;
|
||||
use Filament\Models\Role;
|
||||
|
||||
class RoleCreate extends Component
|
||||
|
||||
@@ -4,7 +4,7 @@ namespace Filament\Http\Livewire;
|
||||
|
||||
use Livewire\Component;
|
||||
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
||||
use Filament\Traits\Livewire\HasForm;
|
||||
use Filament\Traits\HasForm;
|
||||
use Filament\Models\Role;
|
||||
|
||||
class RoleEdit extends Component
|
||||
@@ -14,7 +14,7 @@ class RoleEdit extends Component
|
||||
public function mount(Role $role)
|
||||
{
|
||||
$this->authorize('edit', $role);
|
||||
$this->setupForm($role);
|
||||
$this->initForm($role);
|
||||
}
|
||||
|
||||
public function save()
|
||||
|
||||
@@ -4,7 +4,7 @@ namespace Filament\Http\Livewire;
|
||||
|
||||
use Livewire\Component;
|
||||
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
||||
use Filament\Traits\Livewire\HasForm;
|
||||
use Filament\Traits\HasForm;
|
||||
use Filament\Contracts\User as UserContract;
|
||||
|
||||
class UserCreate extends Component
|
||||
|
||||
@@ -4,7 +4,7 @@ namespace Filament\Http\Livewire;
|
||||
|
||||
use Livewire\Component;
|
||||
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
||||
use Filament\Traits\Livewire\HasForm;
|
||||
use Filament\Traits\HasForm;
|
||||
use Filament\Fields\File\Traits\HasFileUploads;
|
||||
|
||||
class UserEdit extends Component
|
||||
@@ -19,7 +19,7 @@ class UserEdit extends Component
|
||||
public function mount($user)
|
||||
{
|
||||
$this->authorize('edit', $user);
|
||||
$this->setupForm($user);
|
||||
$this->initForm($user);
|
||||
}
|
||||
|
||||
public function success()
|
||||
|
||||
@@ -7,6 +7,7 @@ use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Arr;
|
||||
use Thomaswelton\LaravelGravatar\Facades\Gravatar;
|
||||
use Spatie\Permission\Traits\HasRoles;
|
||||
use Plank\Metable\Metable;
|
||||
use Filament\Traits\CastsAttributes;
|
||||
use Filament\Traits\FillsColumns;
|
||||
use Filament\Models\Media;
|
||||
@@ -14,7 +15,7 @@ use Filament;
|
||||
|
||||
trait FilamentUser
|
||||
{
|
||||
use CastsAttributes, FillsColumns, HasRoles;
|
||||
use CastsAttributes, FillsColumns, HasRoles, Metable;
|
||||
|
||||
/**
|
||||
* Initialize the trait.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Filament\Traits\Livewire;
|
||||
namespace Filament\Traits;
|
||||
|
||||
use Illuminate\Support\Arr;
|
||||
use Filament\Contracts\Fieldset;
|
||||
@@ -12,12 +12,12 @@ trait HasForm
|
||||
public $fieldset;
|
||||
|
||||
/**
|
||||
* Setup our form, set the model and
|
||||
* corresponding form data as an array
|
||||
* Setup our form, sets the model and
|
||||
* corresponding data for the form.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setupForm($model)
|
||||
public function initForm($model)
|
||||
{
|
||||
$this->model = $model;
|
||||
$this->form_data = $this->model->toArray();
|
||||
Reference in New Issue
Block a user