Skip to content

Commit

Permalink
Merge pull request #205 from GeOsmFamily:dev
Browse files Browse the repository at this point in the history
translate ODD in english
  • Loading branch information
BorisGautier authored Nov 23, 2023
2 parents 35b3db8 + fbe9c38 commit f92ad41
Show file tree
Hide file tree
Showing 10 changed files with 142 additions and 19 deletions.
10 changes: 10 additions & 0 deletions app/Filament/Resources/CategorieOddResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand All @@ -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(),
Expand Down Expand Up @@ -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();
Expand Down
10 changes: 10 additions & 0 deletions app/Filament/Resources/OddResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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')
Expand Down Expand Up @@ -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();
Expand Down
70 changes: 54 additions & 16 deletions app/Filament/Resources/OscResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down Expand Up @@ -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(),
Expand All @@ -147,7 +150,6 @@ public static function table(Table $table): Table
->sortable()
->toggleable(isToggledHiddenByDefault: true),
])

->filters([
Tables\Filters\TrashedFilter::make(),
])
Expand Down Expand Up @@ -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,
]);
Expand All @@ -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,
]);
Expand All @@ -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();
}
}
2 changes: 1 addition & 1 deletion app/Filament/Resources/UserResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
]);
Expand Down
4 changes: 4 additions & 0 deletions app/Http/Controllers/Api/CategorieOddController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand All @@ -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',
]);

Expand Down Expand Up @@ -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
*/
Expand All @@ -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',
]);

Expand Down
6 changes: 5 additions & 1 deletion app/Http/Controllers/Api/OddController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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',
Expand Down Expand Up @@ -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
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion app/Models/CategorieOdd.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class CategorieOdd extends Model

protected $fillable = [
'category_number',
'intitule', 'id_odd',
'intitule', 'name_en', 'id_odd',
];

protected $hidden = [
Expand Down
1 change: 1 addition & 0 deletions app/Models/Odd.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class Odd extends Model

protected $fillable = [
'name',
'name_en',
'number',
'number_categorie', 'logo_odd', 'color'
];
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('odds', function (Blueprint $table) {
$table->string('name_en')->nullable();
});
}

/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('odds', function (Blueprint $table) {
//
});
}
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('categorie_odds', function (Blueprint $table) {
$table->text('name_en')->nullable();
});
}

/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('categorie_odds', function (Blueprint $table) {
//
});
}
};

0 comments on commit f92ad41

Please sign in to comment.