Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(profile): allow shares to hide profile #30 #50

Merged
merged 1 commit into from
Feb 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions app/Filament/Resources/ProfileResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand All @@ -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'),
Expand Down
3 changes: 2 additions & 1 deletion app/Http/Controllers/ProfileController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -197,7 +198,7 @@ public static function getValidations()
"attends_sat" => [
'exclude_if:applicationType,assistant',
'required_without_all:attends_thu,attends_fri',
]
],
];
}

Expand Down
4 changes: 4 additions & 0 deletions app/Models/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 2 additions & 0 deletions app/Models/Profile.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
1 change: 1 addition & 0 deletions database/factories/ProfileFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
28 changes: 28 additions & 0 deletions database/migrations/2024_02_01_001244_add_is_hidden_to_profile.php
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('profiles', function (Blueprint $table) {
$table->boolean('is_hidden')->default(false);
});
}

/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('profiles', function (Blueprint $table) {
$table->dropColumn('is_hidden');
});
}
};
Loading
Loading