From 8512232fa101cc66004cc8cd163939a551e04129 Mon Sep 17 00:00:00 2001 From: Fenrikur <3359222+Fenrikur@users.noreply.github.com> Date: Fri, 2 Feb 2024 00:42:18 +0100 Subject: [PATCH] feat(profile): allow shares to hide profile --- app/Filament/Resources/ProfileResource.php | 5 + app/Http/Controllers/ProfileController.php | 3 +- app/Models/Application.php | 4 + app/Models/Profile.php | 2 + database/factories/ProfileFactory.php | 1 + ..._02_01_001244_add_is_hidden_to_profile.php | 28 + resources/views/forms/profile.blade.php | 642 +++++++++--------- 7 files changed, 375 insertions(+), 310 deletions(-) create mode 100644 database/migrations/2024_02_01_001244_add_is_hidden_to_profile.php diff --git a/app/Filament/Resources/ProfileResource.php b/app/Filament/Resources/ProfileResource.php index bff0897..b6594c9 100644 --- a/app/Filament/Resources/ProfileResource.php +++ b/app/Filament/Resources/ProfileResource.php @@ -68,6 +68,9 @@ public static function form(Form $form): Form ]), Forms\Components\Group::make()->schema([ + Forms\Components\Fieldset::make('Profile')->inlineLabel()->columns(1)->schema([ + Forms\Components\Toggle::make('is_hidden'), + ]), Forms\Components\Fieldset::make('Attendance')->inlineLabel()->columns(1)->schema([ Forms\Components\Toggle::make('attends_thu'), Forms\Components\Toggle::make('attends_fri'), @@ -82,6 +85,8 @@ public static function table(Table $table): Table return $table ->columns([ Tables\Columns\TextColumn::make('application_id'), + Tables\Columns\IconColumn::make('is_hidden') + ->boolean(), Tables\Columns\TextColumn::make('short_desc'), Tables\Columns\TextColumn::make('artist_desc'), Tables\Columns\TextColumn::make('art_desc'), diff --git a/app/Http/Controllers/ProfileController.php b/app/Http/Controllers/ProfileController.php index f288e77..aafcfb7 100644 --- a/app/Http/Controllers/ProfileController.php +++ b/app/Http/Controllers/ProfileController.php @@ -39,6 +39,7 @@ public static function createOrUpdate(Request $request, int $applicationId): Pro "attends_thu" => $request->input('attends_thu') === "on", "attends_fri" => $request->input('attends_fri') === "on", "attends_sat" => $request->input('attends_sat') === "on", + "is_hidden" => $request->input('profile_hidden') === "on", ]; // Keep old images if no new data is sent with the request @@ -197,7 +198,7 @@ public static function getValidations() "attends_sat" => [ 'exclude_if:applicationType,assistant', 'required_without_all:attends_thu,attends_fri', - ] + ], ]; } diff --git a/app/Models/Application.php b/app/Models/Application.php index c6c5f3c..ba871f1 100644 --- a/app/Models/Application.php +++ b/app/Models/Application.php @@ -469,6 +469,10 @@ public static function getAllApplicationsForAppExport() $query->where('type', ApplicationType::Dealer) ->orWhere('type', ApplicationType::Share); }) + ->where(function (Builder $query) { + $query->where('profiles.is_hidden', '=', '0') + ->orWhere('type', ApplicationType::Dealer); + }) ->get(); return json_decode(json_encode($applications), true); } diff --git a/app/Models/Profile.php b/app/Models/Profile.php index f735601..772d0ad 100644 --- a/app/Models/Profile.php +++ b/app/Models/Profile.php @@ -15,12 +15,14 @@ class Profile extends Model "attends_thu" => "boolean", "attends_fri" => "boolean", "attends_sat" => "boolean", + "is_hidden" => "boolean", ]; protected $attributes = [ "attends_thu" => true, "attends_fri" => true, "attends_sat" => true, + "is_hidden" => false, ]; public function application() diff --git a/database/factories/ProfileFactory.php b/database/factories/ProfileFactory.php index 8612803..a13b176 100644 --- a/database/factories/ProfileFactory.php +++ b/database/factories/ProfileFactory.php @@ -30,6 +30,7 @@ public function definition(): array 'attends_thu' => $this->faker->boolean(), 'attends_fri' => $this->faker->boolean(), 'attends_sat' => $this->faker->boolean(), + 'is_hidden' => $this->faker->boolean(), 'created_at' => Carbon::now(), 'updated_at' => Carbon::now(), 'application_id' => Application::factory(), diff --git a/database/migrations/2024_02_01_001244_add_is_hidden_to_profile.php b/database/migrations/2024_02_01_001244_add_is_hidden_to_profile.php new file mode 100644 index 0000000..66fc5f6 --- /dev/null +++ b/database/migrations/2024_02_01_001244_add_is_hidden_to_profile.php @@ -0,0 +1,28 @@ +boolean('is_hidden')->default(false); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('profiles', function (Blueprint $table) { + $table->dropColumn('is_hidden'); + }); + } +}; diff --git a/resources/views/forms/profile.blade.php b/resources/views/forms/profile.blade.php index ea001ce..19852c0 100644 --- a/resources/views/forms/profile.blade.php +++ b/resources/views/forms/profile.blade.php @@ -1,3 +1,9 @@ + +