Skip to content
Open
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
4 changes: 2 additions & 2 deletions app/Http/Controllers/UsersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function store(): RedirectResponse
'email' => ['required', 'max:50', 'email', Rule::unique('users')],
'password' => ['nullable'],
'owner' => ['required', 'boolean'],
'photo' => ['nullable', 'image'],
'photo' => ['nullable', 'mimes:jpg,jpeg,png,gif,bmp,webp'],
]);

Auth::user()->account->users()->create([
Expand Down Expand Up @@ -89,7 +89,7 @@ public function update(User $user): RedirectResponse
'email' => ['required', 'max:50', 'email', Rule::unique('users')->ignore($user->id)],
'password' => ['nullable'],
'owner' => ['required', 'boolean'],
'photo' => ['nullable', 'image'],
'photo' => ['nullable', 'mimes:jpg,jpeg,png,gif,bmp,webp'],
]);

$user->update(Request::only('first_name', 'last_name', 'email', 'owner'));
Expand Down
2 changes: 1 addition & 1 deletion resources/js/Pages/Users/Create.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<option :value="true">Yes</option>
<option :value="false">No</option>
</select-input>
<file-input v-model="form.photo" :error="form.errors.photo" class="pb-8 pr-6 w-full lg:w-1/2" type="file" accept="image/*" label="Photo" />
<file-input v-model="form.photo" :error="form.errors.photo" class="pb-8 pr-6 w-full lg:w-1/2" accept="image/*" label="Photo" />
</div>
<div class="flex items-center justify-end px-8 py-4 bg-gray-50 border-t border-gray-100">
<loading-button :loading="form.processing" class="btn-indigo" type="submit">Create User</loading-button>
Expand Down
2 changes: 1 addition & 1 deletion resources/js/Pages/Users/Edit.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<option :value="true">Yes</option>
<option :value="false">No</option>
</select-input>
<file-input v-model="form.photo" :error="form.errors.photo" class="pb-8 pr-6 w-full lg:w-1/2" type="file" accept="image/*" label="Photo" />
<file-input v-model="form.photo" :error="form.errors.photo" class="pb-8 pr-6 w-full lg:w-1/2" accept="image/*" label="Photo" />
</div>
<div class="flex items-center px-8 py-4 bg-gray-50 border-t border-gray-100">
<button v-if="!user.deleted_at" class="text-red-600 hover:underline" tabindex="-1" type="button" @click="destroy">Delete User</button>
Expand Down
9 changes: 3 additions & 6 deletions resources/js/Shared/FileInput.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<div>
<label v-if="label" class="form-label">{{ label }}:</label>
<div class="form-input p-0" :class="{ error: errors.length }">
<div class="form-input p-0" :class="{ error: error }">
<input ref="file" type="file" :accept="accept" class="hidden" @change="change" />
<div v-if="!modelValue" class="p-2">
<button type="button" class="px-4 py-1 text-white text-xs font-medium bg-gray-500 hover:bg-gray-700 rounded-sm" @click="browse">Browse</button>
Expand All @@ -13,7 +13,7 @@
<button type="button" class="px-4 py-1 text-white text-xs font-medium bg-gray-500 hover:bg-gray-700 rounded-sm" @click="remove">Remove</button>
</div>
</div>
<div v-if="errors.length" class="form-error">{{ errors[0] }}</div>
<div v-if="error" class="form-error">{{ error }}</div>
</div>
</template>

Expand All @@ -23,10 +23,7 @@ export default {
modelValue: File,
label: String,
accept: String,
errors: {
type: Array,
default: () => [],
},
error: String,
},
emits: ['update:modelValue'],
watch: {
Expand Down