diff --git a/README.md b/README.md index d92b68f076..170bb9bffc 100644 --- a/README.md +++ b/README.md @@ -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 +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')); } } diff --git a/src/Http/Livewire/PermissionCreate.php b/src/Http/Livewire/PermissionCreate.php index fd1392ebdc..d119497fbc 100644 --- a/src/Http/Livewire/PermissionCreate.php +++ b/src/Http/Livewire/PermissionCreate.php @@ -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 diff --git a/src/Http/Livewire/PermissionEdit.php b/src/Http/Livewire/PermissionEdit.php index ef783fb32f..e3da9d4cfe 100644 --- a/src/Http/Livewire/PermissionEdit.php +++ b/src/Http/Livewire/PermissionEdit.php @@ -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() diff --git a/src/Http/Livewire/RoleCreate.php b/src/Http/Livewire/RoleCreate.php index cd585ee7b4..eaf0fd9ff7 100644 --- a/src/Http/Livewire/RoleCreate.php +++ b/src/Http/Livewire/RoleCreate.php @@ -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 diff --git a/src/Http/Livewire/RoleEdit.php b/src/Http/Livewire/RoleEdit.php index fde08969ec..4e9fa417e9 100644 --- a/src/Http/Livewire/RoleEdit.php +++ b/src/Http/Livewire/RoleEdit.php @@ -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() diff --git a/src/Http/Livewire/UserCreate.php b/src/Http/Livewire/UserCreate.php index 061ce1a6de..890b9f20d1 100644 --- a/src/Http/Livewire/UserCreate.php +++ b/src/Http/Livewire/UserCreate.php @@ -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 diff --git a/src/Http/Livewire/UserEdit.php b/src/Http/Livewire/UserEdit.php index aee5c25155..ae1f4c0e3a 100644 --- a/src/Http/Livewire/UserEdit.php +++ b/src/Http/Livewire/UserEdit.php @@ -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() diff --git a/src/Traits/FilamentUser.php b/src/Traits/FilamentUser.php index 97c9b6e123..85bc22a309 100644 --- a/src/Traits/FilamentUser.php +++ b/src/Traits/FilamentUser.php @@ -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. diff --git a/src/Traits/Livewire/HasForm.php b/src/Traits/HasForm.php similarity index 96% rename from src/Traits/Livewire/HasForm.php rename to src/Traits/HasForm.php index 47e98741a6..589c2a8743 100644 --- a/src/Traits/Livewire/HasForm.php +++ b/src/Traits/HasForm.php @@ -1,6 +1,6 @@ model = $model; $this->form_data = $this->model->toArray();