diff --git a/app/Filament/Resources/CategorieOddResource.php b/app/Filament/Resources/CategorieOddResource.php index 658e5c5..0e07755 100644 --- a/app/Filament/Resources/CategorieOddResource.php +++ b/app/Filament/Resources/CategorieOddResource.php @@ -33,6 +33,9 @@ public static function form(Form $form): Form Forms\Components\TextInput::make('intitule') ->required() ->maxLength(255), + Forms\Components\TextInput::make('name_en') + ->required() + ->maxLength(255), Forms\Components\Select::make('id_odd') ->relationship('odd', 'name') ->required(), @@ -47,6 +50,8 @@ public static function table(Table $table): Table ->searchable(), Tables\Columns\TextColumn::make('intitule') ->searchable(), + Tables\Columns\TextColumn::make('name_en') + ->searchable(), Tables\Columns\TextColumn::make('id_odd') ->numeric() ->sortable(), @@ -107,6 +112,11 @@ public static function getEloquentQuery(): Builder ]); } + public static function shouldRegisterNavigation(): bool + { + return auth()->user()->role == 1; + } + public static function getNavigationBadge(): ?string { return static::getModel()::count(); diff --git a/app/Filament/Resources/OddResource.php b/app/Filament/Resources/OddResource.php index 6a60f69..d246fab 100644 --- a/app/Filament/Resources/OddResource.php +++ b/app/Filament/Resources/OddResource.php @@ -37,6 +37,9 @@ public static function form(Form $form): Form Forms\Components\TextInput::make('name') ->required() ->maxLength(255), + Forms\Components\TextInput::make('name_en') + ->required() + ->maxLength(255), Forms\Components\TextInput::make('number') ->required() ->maxLength(255), @@ -56,6 +59,8 @@ public static function table(Table $table): Table ->columns([ Tables\Columns\TextColumn::make('name') ->searchable(), + Tables\Columns\TextColumn::make('name_en') + ->searchable(), Tables\Columns\TextColumn::make('number') ->searchable(), Tables\Columns\TextColumn::make('number_categorie') @@ -127,6 +132,11 @@ public static function getEloquentQuery(): Builder ]); } + public static function shouldRegisterNavigation(): bool + { + return auth()->user()->role == 1; + } + public static function getNavigationBadge(): ?string { return static::getModel()::count(); diff --git a/app/Filament/Resources/OscResource.php b/app/Filament/Resources/OscResource.php index bbef838..6f83e95 100644 --- a/app/Filament/Resources/OscResource.php +++ b/app/Filament/Resources/OscResource.php @@ -46,7 +46,7 @@ public static function form(Form $form): Form 'Cameroun' => 'Cameroun', 'Senegal' => 'Senegal', 'Cote d\'ivoire' => 'Cote d\'ivoire', - 'Tanzanie' => 'Tanzanie', + 'Tanzania' => 'Tanzania', ]), Forms\Components\DatePicker::make('date_fondation'), Forms\Components\Textarea::make('description'), @@ -108,29 +108,32 @@ public static function table(Table $table): Table ->columns([ Tables\Columns\TextColumn::make('name') ->sortable() - ->searchable(), + ->searchable(query: function (Builder $query, string $search): Builder { + return $query + ->where('name', 'like', "%{$search}%"); + }), Tables\Columns\TextColumn::make('abbreviation') - ->searchable(), + , Tables\Columns\TextColumn::make('pays') ->sortable() - ->searchable(), + , Tables\Columns\TextColumn::make('date_fondation') ->date() ->sortable(), Tables\Columns\TextColumn::make('reference') - ->searchable(), + , Tables\Columns\TextColumn::make('personne_contact') - ->searchable(), + , Tables\Columns\TextColumn::make('telephone') - ->searchable(), + , Tables\Columns\TextColumn::make('email_osc') - ->searchable(), + , Tables\Columns\TextColumn::make('site_web') - ->searchable(), + , Tables\Columns\TextColumn::make('longitude') - ->searchable(), + , Tables\Columns\TextColumn::make('latitude') - ->searchable(), + , Tables\Columns\IconColumn::make('active') ->sortable() ->boolean(), @@ -147,7 +150,6 @@ public static function table(Table $table): Table ->sortable() ->toggleable(isToggledHiddenByDefault: true), ]) - ->filters([ Tables\Filters\TrashedFilter::make(), ]) @@ -194,7 +196,7 @@ public static function getEloquentQuery(): Builder ]); } if( auth()->user()->role == 4) { - return parent::getEloquentQuery()->where('pays', 'Benin') + return parent::getEloquentQuery()->where('pays', 'Benin')->orWhere('pays', 'Bénin') ->withoutGlobalScopes([ SoftDeletingScope::class, ]); @@ -206,19 +208,19 @@ public static function getEloquentQuery(): Builder ]); } if( auth()->user()->role == 6) { - return parent::getEloquentQuery()->where('pays', 'Senegal') + return parent::getEloquentQuery()->where('pays', 'Senegal')->orWhere('pays', 'Sénégal') ->withoutGlobalScopes([ SoftDeletingScope::class, ]); } if( auth()->user()->role == 7) { - return parent::getEloquentQuery()->where('pays', 'Cote d\'ivoire') + return parent::getEloquentQuery()->where('pays', 'Cote d\'ivoire')->orWhere('pays', 'Côte d\'ivoire') ->withoutGlobalScopes([ SoftDeletingScope::class, ]); } if( auth()->user()->role == 8) { - return parent::getEloquentQuery()->where('pays', 'Tanzanie') + return parent::getEloquentQuery()->where('pays', 'Tanzania') ->withoutGlobalScopes([ SoftDeletingScope::class, ]); @@ -232,6 +234,42 @@ public static function getEloquentQuery(): Builder public static function getNavigationBadge(): ?string { + if( auth()->user()->role == 3) { + + $country = parent::getEloquentQuery()->where('pays', 'Togo'); + return $country->count(); + } + + if( auth()->user()->role == 4) { + + $country = parent::getEloquentQuery()->where('pays', 'Benin')->orWhere('pays', 'Bénin'); + return $country->count(); + } + + if( auth()->user()->role == 5) { + + $country = parent::getEloquentQuery()->where('pays', 'Cameroun'); + return $country->count(); + } + + if( auth()->user()->role == 6) { + + $country = parent::getEloquentQuery()->where('pays', 'Senegal')->orWhere('pays', 'Sénégal'); + return $country->count(); + } + + if( auth()->user()->role == 7) { + + $country = parent::getEloquentQuery()->where('pays', 'Cote d\'ivoire')->orWhere('pays', 'Côte d\'ivoire'); + return $country->count(); + } + + if( auth()->user()->role == 8) { + + $country = parent::getEloquentQuery()->where('pays', 'Tanzania'); + return $country->count(); + } + return static::getModel()::count(); } } diff --git a/app/Filament/Resources/UserResource.php b/app/Filament/Resources/UserResource.php index 9700463..ddc4948 100644 --- a/app/Filament/Resources/UserResource.php +++ b/app/Filament/Resources/UserResource.php @@ -51,7 +51,7 @@ public static function form(Form $form): Form '5' => 'User Cameroun', '6' => 'User Senegal', '7' => 'User Cote d\'ivoire', - '8' => 'User Tanzanie', + '8' => 'User Tanzania', ]) ->required(), ]); diff --git a/app/Http/Controllers/Api/CategorieOddController.php b/app/Http/Controllers/Api/CategorieOddController.php index 1c9230d..5f7d349 100644 --- a/app/Http/Controllers/Api/CategorieOddController.php +++ b/app/Http/Controllers/Api/CategorieOddController.php @@ -39,6 +39,7 @@ public function index() * @header Content-Type application/json * @bodyParam category_number string required the number of the categorieOdd. Example:12.1 * @bodyParam intitule string required the title of the categorieOdd. Example: Faim + * @bodyParam name_en string required the english name of the category odd. Example: Eat * @bodyParam id_odd int required the id of the odd. Example: 1 * @responseFile storage/responses/addcategorieodd.json */ @@ -47,6 +48,7 @@ public function store(Request $request) $validator = Validator::make($request->all(), [ 'category_number' => 'required', 'intitule' => 'required', + 'name_en' => 'required', 'id_odd' => 'required', ]); @@ -88,6 +90,7 @@ public function show($id) * @urlParam id required The ID of the CategorieOdd. Example: 1 * @bodyParam category_number string required the number of the categorieOdd. Example:12.2 * @bodyParam intitule string required the title of the categorieOdd. Example: Faim + * @bodyParam name_en string required the english name of the category odd. Example: Eat * @bodyParam id_odd int required the id of the odd. Example: 1 * @responseFile storage/responses/updatecategorieodd.json */ @@ -97,6 +100,7 @@ public function update(Request $request, $id) $validator = Validator::make($request->all(), [ 'category_number' => 'required', 'intitule' => 'required', + 'name_en' => 'required', 'id_odd' => 'required', ]); diff --git a/app/Http/Controllers/Api/OddController.php b/app/Http/Controllers/Api/OddController.php index 50ef4c0..c400d0e 100644 --- a/app/Http/Controllers/Api/OddController.php +++ b/app/Http/Controllers/Api/OddController.php @@ -41,6 +41,7 @@ public function index() * @authenticated * @header Content-Type application/json * @bodyParam name string required the name of the odd. Example: Faim + * @bodyParam name_en string required the english name of the odd. Example: Eat * @bodyParam number int required the number of the odd. Example: 12 * @bodyParam number_categorie int required number of categories contained in this odd. Example: 2 * @bodyParam logo_odd string required the url of the logo of the odd. Example: http://www.logo.com @@ -51,6 +52,7 @@ public function store(Request $request) { $validator = Validator::make($request->all(), [ 'name' => 'required', + 'name_en' => 'required', 'number' => 'required', 'number_categorie' => 'required', 'logo_odd' => 'required', @@ -97,7 +99,8 @@ public function show($id) * @authenticated * @header Content-Type application/json * @urlParam id int required the id of the odd. Example: 2 - * @bodyParam name string required the name of the odd. Example: Faim + * @bodyParam name string the name of the odd. Example: Faim + * @bodyParam name_en string the english name of the odd. Example: Eat * @bodyParam number int required the number of the odd. Example: 12 * @bodyParam number_categorie int required number of categories contained in this odd. Example: 2 * @bodyParam logo_odd string required the url of the logo of the odd. Example: http://www.logo.com @@ -113,6 +116,7 @@ public function update(Request $request, $id) DB::beginTransaction(); $odd->name = $request->name ?? $odd->name; + $odd->name_en = $request->name_en ?? $odd->name_en; $odd->number = $request->number ?? $odd->number; $odd->number_categorie = $request->number_categorie ?? $odd->number_categorie; $odd->logo_odd = $request->logo_odd ?? $odd->logo_odd; diff --git a/app/Models/CategorieOdd.php b/app/Models/CategorieOdd.php index 6b8ce35..605f900 100644 --- a/app/Models/CategorieOdd.php +++ b/app/Models/CategorieOdd.php @@ -40,7 +40,7 @@ class CategorieOdd extends Model protected $fillable = [ 'category_number', - 'intitule', 'id_odd', + 'intitule', 'name_en', 'id_odd', ]; protected $hidden = [ diff --git a/app/Models/Odd.php b/app/Models/Odd.php index 0f399c8..4feb22e 100644 --- a/app/Models/Odd.php +++ b/app/Models/Odd.php @@ -44,6 +44,7 @@ class Odd extends Model protected $fillable = [ 'name', + 'name_en', 'number', 'number_categorie', 'logo_odd', 'color' ]; diff --git a/database/migrations/2023_11_22_112345_add_name_en_to_odds_table.php b/database/migrations/2023_11_22_112345_add_name_en_to_odds_table.php new file mode 100644 index 0000000..17bca37 --- /dev/null +++ b/database/migrations/2023_11_22_112345_add_name_en_to_odds_table.php @@ -0,0 +1,28 @@ +string('name_en')->nullable(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('odds', function (Blueprint $table) { + // + }); + } +}; diff --git a/database/migrations/2023_11_22_112555_add_name_en_to_categorie_odds_table.php b/database/migrations/2023_11_22_112555_add_name_en_to_categorie_odds_table.php new file mode 100644 index 0000000..43b28b5 --- /dev/null +++ b/database/migrations/2023_11_22_112555_add_name_en_to_categorie_odds_table.php @@ -0,0 +1,28 @@ +text('name_en')->nullable(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('categorie_odds', function (Blueprint $table) { + // + }); + } +};