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): make thumbnail required if visible #113

Merged
merged 6 commits into from
Feb 15, 2025
Merged
Show file tree
Hide file tree
Changes from 2 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
9 changes: 8 additions & 1 deletion app/Http/Controllers/ProfileController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use App\Models\Profile;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Storage;
use Illuminate\Validation\Rule;
use Intervention\Image\ImageManager;
use Intervention\Image\Drivers\Gd\Driver;
use ZipArchive;
Expand Down Expand Up @@ -91,10 +92,16 @@ public function update(Request $request, Profile $profile) {}

public function destroy(Profile $profile) {}

public static function getValidations()
public static function getValidations(Request $request)
{
return [
"profile_hidden" => [
'prohibited_unless:applicationType,share'
],
"image_thumbnail" => [
Rule::requiredIf(fn() => empty($request->user()?->application?->profile?->image_thumbnail) &&
($request->input('applicationType') === 'dealer' ||
($request->input('applicationType') === 'share' && !$request->has('profile_hidden')))),
'image',
'mimes:jpeg,png',
'max:1024',
Expand Down
5 changes: 3 additions & 2 deletions app/Http/Requests/ApplicationRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@
use App\Models\Application;
use Carbon\Carbon;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Validation\Rule;
use Illuminate\Validation\Rules\RequiredIf;

class ApplicationRequest extends FormRequest
{
public function rules(): array
public function rules(Request $request): array
{
/**
* This is a multi request, it is accessed in the following circumstances
Expand Down Expand Up @@ -83,7 +84,7 @@ public function rules(): array
],
];

$profileValidations = ProfileController::getValidations();
$profileValidations = ProfileController::getValidations($request);

if (Carbon::parse(config('convention.reg_end_date'))->isFuture()) {
return array_merge($appValidations, $profileValidations);
Expand Down
104 changes: 52 additions & 52 deletions resources/views/forms/profile.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,51 @@
</label>
@endif
<div id="dd-profile" class="mt-2">
<div class="row mb-3">
<div class="row mt-4">
<label for="image_thumbnail" class="col-sm-2 col-form-label fw-bold required">Thumb&shy;nail</label>
<div class="col-sm-10">
<input id="image_thumbnail" type="file"
class="form-control @error('image_thumbnail') is-invalid @enderror" name="image_thumbnail"
accept="image/jpeg, image/png"
onchange="document.getElementById('image_thumbnail_preview').src = window.URL.createObjectURL(this.files[0]); document.getElementById('image_thumbnail_preview_large').src = window.URL.createObjectURL(this.files[0]);">
<div id="image_thumbnailHelp" class="form-text">Upload an image to be shown next to your name in
the dealer list. This image should have a size of 60&times;60 pixels (max file size is 1 MB).
</div>
@error('image_thumbnail')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror

<img id='image_thumbnail_preview' class="mx-auto mb-2" data-bs-toggle="modal"
data-bs-target="#imageThumbnailModal"
src="{{ Storage::disk('public')->url("$profile?->image_thumbnail") }}" alt=""
style="height: 100px;">

<!-- Modal -->
<div class="modal fade" id="imageThumbnailModal" tabindex="-1"
aria-labelledby="imageThumbnailModalLabel" aria-hidden="true">
<div class="modal-dialog modal-sm">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="btn-close" data-bs-dismiss="modal"
aria-label="Close"></button>
</div>
<div class="modal-body">
<img id='image_thumbnail_preview_large'class="mx-auto d-block w-100"
src="{{ Storage::disk('public')->url("$profile?->image_thumbnail") }}"
alt="">
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary"
data-bs-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="row mb-1">
<label class="col-sm-2 col-form-label fw-bold">Attend&shy;ance</label>
</div>
<div class="row mb-1">
Expand Down Expand Up @@ -84,51 +128,7 @@
</div>
</div>
</div>
<div class="row mb-1 mt-5">
<label for="image_thumbnail" class="col-sm-2 col-form-label fw-bold">Thumb&shy;nail</label>
<div class="col-sm-10">
<input id="image_thumbnail" type="file"
class="form-control @error('image_thumbnail') is-invalid @enderror" name="image_thumbnail"
accept="image/jpeg, image/png"
onchange="document.getElementById('image_thumbnail_preview').src = window.URL.createObjectURL(this.files[0]); document.getElementById('image_thumbnail_preview_large').src = window.URL.createObjectURL(this.files[0]);">
<div id="image_thumbnailHelp" class="form-text">Upload an image to be shown next to your name in
the dealer list. This image should have a size of 60&times;60 pixels (max file size is 1 MB).
</div>
@error('image_thumbnail')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror

<img id='image_thumbnail_preview' class="mx-auto mb-5" data-bs-toggle="modal"
data-bs-target="#imageThumbnailModal"
src="{{ Storage::disk('public')->url("$profile?->image_thumbnail") }}" alt=""
style="height: 100px;">

<!-- Modal -->
<div class="modal fade" id="imageThumbnailModal" tabindex="-1"
aria-labelledby="imageThumbnailModalLabel" aria-hidden="true">
<div class="modal-dialog modal-sm">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="btn-close" data-bs-dismiss="modal"
aria-label="Close"></button>
</div>
<div class="modal-body">
<img id='image_thumbnail_preview_large'class="mx-auto d-block w-100"
src="{{ Storage::disk('public')->url("$profile?->image_thumbnail") }}"
alt="">
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary"
data-bs-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="row mb-3">
<div class="row mb-3 mt-5">
<label for="short_desc" class="col-sm-2 col-form-label fw-bold">Short De&shy;scrip&shy;tion</label>
<div class="col-sm-10">
<textarea rows="5" type="text" name="short_desc"
Expand All @@ -141,7 +141,7 @@ class="form-control @error('short_desc') is-invalid @enderror" id="short_desc">{
</div>
</div>
</div>
<div class="row mb-1 mt-5">
<div class="row mb-1 mt-3">
<label for="image_artist" class="col-sm-2 col-form-label fw-bold">Profile Header</label>
<div class="col-sm-10">

Expand All @@ -158,7 +158,7 @@ class="form-control @error('image_artist') is-invalid @enderror" name="image_art
<strong>{{ $message }}</strong>
</span>
@enderror
<img id='image_artist_preview' class="mx-auto mb-5" data-bs-toggle="modal"
<img id='image_artist_preview' class="mx-auto mb-2" data-bs-toggle="modal"
data-bs-target="#imageArtistModal"
src="{{ Storage::disk('public')->url("$profile?->image_artist") }}" alt=""
style="height: 100px;">
Expand Down Expand Up @@ -199,7 +199,7 @@ class="form-control @error('artist_desc') is-invalid @enderror" id="artist_desc"
</div>
</div>
</div>
<div class="row mb-1 mt-5">
<div class="row mb-1 mt-3">
<label for="image_art" class="col-sm-2 col-form-label fw-bold">Show&shy;case Image</label>
<div class="col-sm-10">
<input id="image_art" type="file"
Expand All @@ -217,7 +217,7 @@ class="form-control @error('image_art') is-invalid @enderror" name="image_art"
<strong>{{ $message }}</strong>
</span>
@enderror
<img id='image_art_preview' class="mx-auto mb-5" data-bs-toggle="modal"
<img id='image_art_preview' class="mx-auto mb-2" data-bs-toggle="modal"
data-bs-target="#imageArtModal"
src="{{ Storage::disk('public')->url("$profile?->image_art") }}" alt=""
style="height: 100px;">
Expand Down Expand Up @@ -274,7 +274,7 @@ class="form-control @error('art_preview_caption') is-invalid @enderror" id="art_
</div>
</div>
</div>
<div class="row mb-3">
<div class="row mb-3 mt-5">
<label for="profile_website" class="col-sm-2 col-form-label fw-bold">Web&shy;site</label>
<div class="col-sm-10">
<input type="text" name="profile_website" placeholder="https://yourprofile.example.com/itsme"
Expand Down Expand Up @@ -373,7 +373,7 @@ class="form-control @error('discord') is-invalid @enderror" id="discord"
</div>
</div>
</div>
<div class="row mb-3">
<div class="row mb-3 mt-5">
<label for="tweet" class="col-sm-2 col-form-label fw-bold">Ad&shy;ver&shy;tise&shy;ment
text</label>
<div class="col-sm-10">
Expand Down
Loading