From 2524e514b901261fe237f3f61a5b02527476f70a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9ia=20Bohner?= Date: Mon, 11 Sep 2023 14:14:32 -0300 Subject: [PATCH] Update README and survey resource --- README.md | 71 +++++++++++++++++++++----------- src/Resources/SurveyResource.php | 3 -- 2 files changed, 46 insertions(+), 28 deletions(-) diff --git a/README.md b/README.md index e3ed5e8..db14b4a 100644 --- a/README.md +++ b/README.md @@ -5,8 +5,9 @@ A Filament plugin for [Laravel Survey](https://github.com/matt-daneshvar/laravel This package provides Filament resources for [Laravel Survey](https://github.com/matt-daneshvar/laravel-survey). ## Requirements -- PHP 8.1 -- [Filament 3](https://github.com/laravel-filament/filament) +- PHP 8.1+ +- Laravel 10.0+ +- [Filament 3.0+](https://github.com/laravel-filament/filament) ## Dependencies - [maatwebsite/excel](https://github.com/SpartnerNL/Laravel-Excel) @@ -15,17 +16,48 @@ This package provides Filament resources for [Laravel Survey](https://github.com ## Installation -This plugin uses [Spatie translatable](https://spatie.be/docs/laravel-translatable/v6/installation-setup), [Spatie translatable plugin](https://filamentphp.com/plugins/filament-spatie-translatable), and [Laravel Excel](https://github.com/SpartnerNL/Laravel-Excel), and [Eloquent Sortable](https://github.com/spatie/eloquent-sortable) packages. +### Installing the required package (Laravel Survey) -First install and configure these packages, then proceed to the plugin installation instructions below. +This plugin uses a modifed version of [Laravel Survey](https://github.com/matt-daneshvar/laravel-survey) package: https://github.com/tappnetwork/laravel-survey/tree/translatable that adds translatable and sortable fields to the survey models. More details in this PR: [matt-daneshvar/laravel-survey#39](https://github.com/matt-daneshvar/laravel-survey/pull/39). -> **Note** -> It also uses a modifed version of [Laravel Survey](https://github.com/matt-daneshvar/laravel-survey): -> https://github.com/tappnetwork/laravel-survey/tree/translatable that adds translatable and sortable fields to the survey models. -> More details in this PR: https://github.com/matt-daneshvar/laravel-survey/pull/39 +So you must install this version instead of requiring `matt-daneshvar/laravel-survey`. In order to do so, add to your project's `composer.json`: + +```json +"require": { +    ... +    "matt-daneshvar/laravel-survey": "dev-translatable", +}, +"repositories": [ +    ... +    { +        "type": "vcs", +        "url": "https://github.com/TappNetwork/laravel-survey" +    } +], +``` -You can install the plugin via Composer: +Install it using Composer + +```bash +composer update +``` + +Publish the package migrations + +```bash +php artisan vendor:publish --provider="MattDaneshvar\Survey\SurveyServiceProvider" --tag="migrations" +``` + +Run the migrations + +```bash +php artisan migrate +``` + +### Installing the Filament Survey plugin + +Install the plugin via Composer: ```bash composer require tapp/filament-survey:"^3.0" @@ -34,6 +66,8 @@ composer require tapp/filament-survey:"^3.0" > **Note** > For **Filament 2.x** check the **[2.x](https://github.com//TappNetwork/filament-survey/tree/2.x)** branch +#### Optional: Publish the plugin's views, translations, and config + You can publish the view file with: ```bash @@ -54,22 +88,7 @@ php artisan vendor:publish --tag="filament-survey-config" ### Adding the plugin to a panel -Add this plugin to a panel on `plugins()`method. E.g. in `app/Providers/Filament/AdminPanelProvider.php`: - -```php -use Tapp\FilamentSurvey\FilamentSurveyPlugin; - -public function panel(Panel $panel): Panel -{ - return $panel - // ... - ->plugins([ - FilamentSurveyPlugin::make(), - //... - ]); -} -``` - +Add this plugin to a panel on `plugins()` method (e.g. in `app/Providers/Filament/AdminPanelProvider.php`). This plugin requires the Spatie Translatable plugin, so it should also be added on a panel like so: ```php @@ -87,3 +106,5 @@ public function panel(Panel $panel): Panel ]); } ``` + +That's it! Now the surveys, sections, questions, answers, and entries resources will be displayed in the left sidebar in your Filament admin panel. diff --git a/src/Resources/SurveyResource.php b/src/Resources/SurveyResource.php index 0b306a4..67cec1c 100644 --- a/src/Resources/SurveyResource.php +++ b/src/Resources/SurveyResource.php @@ -68,9 +68,6 @@ public static function table(Table $table): Table ->columns([ Tables\Columns\TextColumn::make('name') ->label('Name (English)'), - Tables\Columns\TextColumn::make('name_en_es') - ->label(__('Name (En, Es)')) - ->formatStateUsing(fn (Survey $record): string => implode(', ', $record->getTranslations('name'))), Tables\Columns\TextColumn::make('settings'), Tables\Columns\TextColumn::make('created_at') ->dateTime(),