diff --git a/app/Enums/OCBType.php b/app/Enums/OCBType.php index 1260359b..78bac573 100644 --- a/app/Enums/OCBType.php +++ b/app/Enums/OCBType.php @@ -5,25 +5,32 @@ namespace App\Enums; use Kwaadpepper\Enum\BaseEnumRoutable; /** - * @method static self egg() * @method static self rabbit() * @method static self poultry() */ final class OCBType extends BaseEnumRoutable { + /** + * Enum values + * + * @return array + */ protected static function values(): array { return [ - 'egg' => 0, 'rabbit' => 1, 'poultry' => 2 ]; } + /** + * Enum labels + * + * @return array + */ protected static function labels(): array { return [ - 'egg' => __('Oeuf'), 'rabbit' => __('Lapin'), 'poultry' => __('Volaille') ]; diff --git a/app/Http/Controllers/OCBController.php b/app/Http/Controllers/OCBController.php index 441cb1b8..169d9a69 100644 --- a/app/Http/Controllers/OCBController.php +++ b/app/Http/Controllers/OCBController.php @@ -77,17 +77,4 @@ class OCBController extends Controller ->inRandomOrder()->first(); return view('front.ocb.poultry', compact('breeder', 'ocbContents')); } - - /** - * Show ocb egg content - * - * @return \Illuminate\Contracts\View\View|\Illuminate\Contracts\View\Factory - */ - public function egg() - { - $ocbContents = OCBContent::where('type', OCBType::egg()) - ->orderBy('order') - ->where('status', true)->get(); - return view('front.ocb.egg', compact('ocbContents')); - } } diff --git a/app/Models/OCBBreeder.php b/app/Models/OCBBreeder.php index b268bbca..ab0b7c75 100644 --- a/app/Models/OCBBreeder.php +++ b/app/Models/OCBBreeder.php @@ -11,16 +11,25 @@ use Illuminate\Support\Facades\Storage; use Illuminate\Support\Str; use Kwaadpepper\Enum\Traits\CastsEnums; -// old Breeders class OCBBreeder extends BreederForGmap { use CastsEnums; + /** + * The attributes that should be cast. + * + * @var array + */ protected $casts = [ 'display' => 'boolean', 'inuavs' => 'array' ]; + /** + * The attributes that should be cast to Enums. + * + * @var array + */ protected $enumCasts = [ 'presentation_type' => PresentationType::class, 'ocbStatus' => EleveurOcbStatus::class, @@ -28,8 +37,18 @@ class OCBBreeder extends BreederForGmap 'geo_type' => GeoType::class ]; + /** + * The table associated with the model. + * + * @var string + */ protected $table = 'ocb_breeders'; + /** + * The attributes that are mass assignable. + * + * @var array + */ protected $fillable = [ 'breeder_code', 'first_name', @@ -51,6 +70,11 @@ class OCBBreeder extends BreederForGmap 'inuavs', ]; + /** + * Perform any actions required after the model boots. + * + * @return void + */ protected static function booted() { static::creating(function ($breeder) { @@ -96,11 +120,18 @@ class OCBBreeder extends BreederForGmap }); } + /** + * Get the route key for the model. + * + * @return string + */ public function getRouteKeyName() { return "slug"; } + // * METHODS + /** * Get ocb validated breeders query * @@ -111,28 +142,55 @@ class OCBBreeder extends BreederForGmap return static::where('ocbStatus', EleveurOcbStatus::yes()); } + + /** + * Getter picture attribute + * + * @return mixed + */ protected function getPictureAttribute() { return $this->pictureAttribute('picture'); } + /** + * Getter picture_1 attribute + * + * @return mixed + */ protected function getPicture1Attribute() { return $this->pictureAttribute('picture1'); } + /** + * Getter picture_2 attribute + * + * @return mixed + */ protected function getPicture2Attribute() { return $this->pictureAttribute('picture2'); } + /** + * Getter picture_3 attribute + * + * @return mixed + */ protected function getPicture3Attribute() { return $this->pictureAttribute('picture3'); } + /** + * Refactored picture attribute + * + * @param string $prop + * @return mixed + */ private function pictureAttribute(string $prop) { $p = $this->attributes[$prop]; - // For migrated urls from 2016 + // For migrated urls from 2016. if ( is_null($p) or !strlen($p) or diff --git a/app/Models/OCBContent.php b/app/Models/OCBContent.php index a7d75b75..0e773581 100644 --- a/app/Models/OCBContent.php +++ b/app/Models/OCBContent.php @@ -10,12 +10,27 @@ class OCBContent extends Model { use CastsEnums; + /** + * The attributes that should be cast to Enums. + * + * @var array + */ protected $enumCasts = [ 'type' => OCBType::class ]; + /** + * The table associated with the model. + * + * @var string + */ protected $table = 'ocb_content'; + /** + * The attributes that are mass assignable. + * + * @var array + */ protected $fillable = [ 'picture', 'content', @@ -24,6 +39,11 @@ class OCBContent extends Model 'status' ]; + /** + * Perform any actions required after the model boots. + * + * @return void + */ protected static function booted() { static::creating(function ($ocbContent) { diff --git a/app/Traits/GoogleMapSerialize.php b/app/Traits/GoogleMapSerialize.php index 9820c235..b031f734 100644 --- a/app/Traits/GoogleMapSerialize.php +++ b/app/Traits/GoogleMapSerialize.php @@ -27,9 +27,6 @@ trait GoogleMapSerialize case OCBType::poultry()->value: $ocbType = trans('Éleveur de volaille'); break; - case OCBType::egg()->value: - $ocbType = trans('Producteur d\'oeufs'); - break; case OCBType::rabbit()->value: $ocbType = trans('Éleveur de lapins'); break; diff --git a/database/migrations/2021_02_06_112145_migrate_old_data_base.php b/database/migrations/2021_02_06_112145_migrate_old_data_base.php index e7708da8..e6ab174a 100644 --- a/database/migrations/2021_02_06_112145_migrate_old_data_base.php +++ b/database/migrations/2021_02_06_112145_migrate_old_data_base.php @@ -269,8 +269,6 @@ class MigrateOldDataBase extends LeGaulois2016Migration case 'lapin': $model->ocbType = OCBType::rabbit(); break; - case 'oeuf': - $model->ocbType = OCBType::egg(); } } catch (Exception $e) { $model->ocbType = OCBType::poultry(); @@ -408,8 +406,6 @@ class MigrateOldDataBase extends LeGaulois2016Migration return OCBType::poultry(); case 'LAPIN': return OCBType::rabbit(); - case 'OEUF': - return OCBType::egg(); } }, 'name' => 'ocb_type', diff --git a/database/migrations/2021_05_18_175000_remigrate_ocb_breeders.php b/database/migrations/2021_05_18_175000_remigrate_ocb_breeders.php index a4ad7f8f..2637de3c 100644 --- a/database/migrations/2021_05_18_175000_remigrate_ocb_breeders.php +++ b/database/migrations/2021_05_18_175000_remigrate_ocb_breeders.php @@ -84,8 +84,6 @@ class RemigrateOcbBreeders extends LeGaulois2016Migration case 'lapin': $model->ocbType = OCBType::rabbit(); break; - case 'oeuf': - $model->ocbType = OCBType::egg(); } } catch (Exception $e) { $model->ocbType = OCBType::poultry(); diff --git a/database/migrations/2021_05_18_175000_remigrate_ocb_breeders2.php b/database/migrations/2021_05_18_175000_remigrate_ocb_breeders2.php index 14dbc322..2d992a56 100644 --- a/database/migrations/2021_05_18_175000_remigrate_ocb_breeders2.php +++ b/database/migrations/2021_05_18_175000_remigrate_ocb_breeders2.php @@ -78,8 +78,6 @@ class RemigrateOcbBreeders2 extends LeGaulois2016Migration case 'lapin': $model->ocbType = OCBType::rabbit(); break; - case 'oeuf': - $model->ocbType = OCBType::egg(); } } catch (Exception $e) { $model->ocbType = OCBType::poultry(); diff --git a/database/migrations/2023_06_26_152754_remove_ocb_egg.php b/database/migrations/2023_06_26_152754_remove_ocb_egg.php new file mode 100644 index 00000000..cc68d06e --- /dev/null +++ b/database/migrations/2023_06_26_152754_remove_ocb_egg.php @@ -0,0 +1,30 @@ +where('ocbType', 0)->delete(); + OCBBreeder::query()->where('ocbType', 0)->delete(); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + // * Wont undo this. + } +} diff --git a/database/migrations/LeGaulois2016Migration.php b/database/migrations/LeGaulois2016Migration.php index c1c41c72..aa03e110 100644 --- a/database/migrations/LeGaulois2016Migration.php +++ b/database/migrations/LeGaulois2016Migration.php @@ -30,8 +30,6 @@ use Symfony\Component\Console\Terminal; * return OCBType::poultry(); * case 'LAPIN': * return OCBType::rabbit(); - * case 'OEUF': - * return OCBType::egg(); * } * }, * 'name' => 'ocb_type', diff --git a/resources/assets/images/ocb/ocb_oeuf_x2.png b/resources/assets/images/ocb/ocb_oeuf_x2.png deleted file mode 100644 index 3ac99ca7..00000000 Binary files a/resources/assets/images/ocb/ocb_oeuf_x2.png and /dev/null differ diff --git a/resources/views/front/ocb/index.blade.php b/resources/views/front/ocb/index.blade.php index 5fe933ad..0d115bbc 100644 --- a/resources/views/front/ocb/index.blade.php +++ b/resources/views/front/ocb/index.blade.php @@ -24,11 +24,6 @@

Poulets
& Dindes

En savoir + -
- Oeuf - Le Gaulois -

Oeufs

- En savoir + -

diff --git a/resources/views/front/ocb/poultry.blade.php b/resources/views/front/ocb/poultry.blade.php index 2bcaa663..c6d1b960 100644 --- a/resources/views/front/ocb/poultry.blade.php +++ b/resources/views/front/ocb/poultry.blade.php @@ -21,10 +21,6 @@ 'ocbContents' => $ocbContents ])

-
@if ($breeder !== null && $breeder->picture !== null)
diff --git a/resources/views/layouts/bo.blade.php b/resources/views/layouts/bo.blade.php index 4ebd83b3..61da43d0 100644 --- a/resources/views/layouts/bo.blade.php +++ b/resources/views/layouts/bo.blade.php @@ -250,7 +250,6 @@