diff --git a/app/Http/Controllers/Admin/CustomerController.php b/app/Http/Controllers/Admin/CustomerController.php index b2afa2e..c9a6d38 100644 --- a/app/Http/Controllers/Admin/CustomerController.php +++ b/app/Http/Controllers/Admin/CustomerController.php @@ -10,6 +10,7 @@ use App\Models\Credit; use App\Models\Customer; use Illuminate\Http\Request; use App\Helper; +use Spatie\Image\Image; use function App\Helpers\hasCreateRoute; class CustomerController extends XController @@ -50,6 +51,8 @@ class CustomerController extends XController public function save($customer, $request) { +// dd($request->all()); + $customer->name = $request->input('name'); if ($customer->credit != $request->input('credit') && $customer->id != null){ $diff = $request->input('credit') - $customer->credit; @@ -67,11 +70,43 @@ class CustomerController extends XController $customer->email = $request->input('email'); } $customer->mobile = $request->input('mobile'); + $customer->sex = $request->input('sex'); + if ($request->has('height') && trim($request->input('height')) != '') { + $customer->height = $request->input('height',null); + } + if ($request->has('weight') && trim($request->input('weight')) != '') { + $customer->weight = $request->input('weight', null); + } $customer->description = $request->input('description'); if (trim($request->input('password')) != '') { $customer->password = bcrypt($request->input('password')); } + + if ($request->has('dob') && $request->dob != ''){ + $customer->dob = date('Y-m-d',floor($request->dob)); + }else{ + $customer->dob = null; + } + + if ($request->hasFile('avatar')) { + $name = time() . '.' . request()->avatar->getClientOriginalExtension(); + $customer->avatar = $name; + $request->file('avatar')->storeAs('public/customers', $name); + $format = $request->file('avatar')->guessExtension(); + $format = 'webp'; + $key = 'avatar'; + + $i = Image::load($request->file($key)->getPathname()) + ->optimize() + ->width(500) + ->height(500) + ->crop(500, 500) +// ->nonQueued() + ->format($format); + $i->save(storage_path() . '/app/public/customers/'. $customer->avatar); + } + $customer->colleague = $request->has('colleague'); $customer->save(); return $customer; diff --git a/app/Http/Controllers/CustomerController.php b/app/Http/Controllers/CustomerController.php index 86408d6..5f786e7 100644 --- a/app/Http/Controllers/CustomerController.php +++ b/app/Http/Controllers/CustomerController.php @@ -11,6 +11,10 @@ use chillerlan\QRCode\QRCode; use chillerlan\QRCode\QROptions; use Illuminate\Http\Request; use Illuminate\Validation\Rules\In; +use Spatie\Image\Enums\AlignPosition; +use Spatie\Image\Enums\Fit; +use Spatie\Image\Enums\Unit; +use Spatie\Image\Image; class CustomerController extends Controller { @@ -62,16 +66,59 @@ class CustomerController extends Controller 'name' => ['required', 'string', 'max:255'], 'email' => ['required', 'string', 'email', 'max:255'], 'mobile' => ['required', 'string', 'max:255'], + 'height' => ['nullable', 'numeric'], + 'weight' => ['nullable', 'numeric'], 'password' => ['nullable', 'string', 'min:8', 'confirmed'], + 'sex' => ['required', 'in:MALE,FEMALE'], + 'dob' => ['nullable', 'date'], + 'avatar' => ['nullable', 'image', 'mimes:jpeg','max:2048'], ]); +// dd($request->all()); $customer = auth('customer')->user(); $customer->name = $request->name; $customer->email = $request->email; + $customer->sex = $request->input('sex'); + if ($request->has('height') && trim($request->input('height')) != '') { + $customer->height = $request->input('height', null); + } + if ($request->has('weight') && trim($request->input('weight')) != '') { + $customer->weight = $request->input('weight', null); + } + $customer->description = $request->input('description'); + + if (trim($request->input('password')) != '') { + $customer->password = bcrypt($request->input('password')); + } + + if ($request->has('dob') && $request->dob != '') { + $customer->dob = date('Y-m-d', floor($request->dob)); + } else { + $customer->dob = null; + } + // $customer->mobile = $request->mobile; if ($request->has('password') && trim($request->input('password')) != '') { $customer->password = bcrypt($request->password); } + + if ($request->hasFile('avatar')) { + $name = time() . '.' . request()->avatar->getClientOriginalExtension(); + $customer->avatar = $name; + $request->file('avatar')->storeAs('public/customers', $name); + $format = $request->file('avatar')->guessExtension(); + $format = 'webp'; + $key = 'avatar'; + + $i = Image::load($request->file($key)->getPathname()) + ->optimize() + ->width(500) + ->height(500) + ->crop(500, 500) +// ->nonQueued() + ->format($format); + $i->save(storage_path() . '/app/public/customers/'. $customer->avatar); + } $customer->save(); return redirect()->route('client.profile')->with('message', __('Profile updated successfully')); } @@ -87,13 +134,13 @@ class CustomerController extends Controller $subtitle = __("Invoice ID:") . ' ' . $invoice->hash; $options = new QROptions([ - 'version' => 5, + 'version' => 5, 'outputType' => QRCode::OUTPUT_MARKUP_SVG, - 'eccLevel' => QRCode::ECC_L, + 'eccLevel' => QRCode::ECC_L, // 'imageTransparent' => true, ]); $qr = new QRCode($options); - return view('client.invoice', compact('area', 'title', 'subtitle','invoice','qr')); + return view('client.invoice', compact('area', 'title', 'subtitle', 'invoice', 'qr')); } diff --git a/app/Http/Requests/CustomerSaveRequest.php b/app/Http/Requests/CustomerSaveRequest.php index 6da8477..dfff1eb 100644 --- a/app/Http/Requests/CustomerSaveRequest.php +++ b/app/Http/Requests/CustomerSaveRequest.php @@ -27,6 +27,11 @@ class CustomerSaveRequest extends FormRequest 'email' => ['required', 'string', 'email', 'max:255', 'unique:customers,email,'.$this->id], 'password' => ['nullable', 'string', 'min:6', 'confirmed'], 'mobile'=> ['required', 'string', 'min:10'], + 'height' => ['nullable', 'numeric'], + 'weight' => ['nullable', 'numeric'], + 'sex' => ['required', 'in:MALE,FEMALE'], + 'dob' => ['nullable', 'date'], + 'avatar' => ['nullable', 'image', 'mimes:jpeg','max:2048'], ]; } } diff --git a/app/Models/Customer.php b/app/Models/Customer.php index d52d5ba..75767dd 100644 --- a/app/Models/Customer.php +++ b/app/Models/Customer.php @@ -69,4 +69,14 @@ class Customer extends Authenticatable } + public function avatar(){ + if ($this->avatar == null || trim($this->avatar) == ''){ + return asset('assets/default/unknown.svg'); + } + + + return \Storage::url('customers/' . $this->avatar); + } + + } diff --git a/database/migrations/2024_05_07_125920_create_customers_table.php b/database/migrations/2024_05_07_125920_create_customers_table.php index 911485a..1bd9e9c 100644 --- a/database/migrations/2024_05_07_125920_create_customers_table.php +++ b/database/migrations/2024_05_07_125920_create_customers_table.php @@ -25,6 +25,10 @@ return new class extends Migration $table->boolean('colleague')->default(false); $table->text('description')->default(null)->nullable(); $table->bigInteger('credit')->default(0); + $table->enum('sex',['MALE','FEMALE'])->nullable()->default(null); + $table->integer('height')->nullable()->default(null); + $table->decimal('weight')->nullable()->default(null); + $table->string('avatar')->nullable()->default(null); $table->json('card')->default(null)->nullable(); $table->rememberToken(); $table->timestamps(); diff --git a/resources/js/client-custom/assetsNode.js b/resources/js/client-custom/assetsNode.js index 165eca6..c06ee81 100644 --- a/resources/js/client-custom/assetsNode.js +++ b/resources/js/client-custom/assetsNode.js @@ -32,6 +32,10 @@ import RateInput from "../client-vue/RateInput.vue"; app.component('rate-input', RateInput); +import vdp from "../client-vue/vueDateTimePickerClient.vue"; +app.component('vue-datetime-picker-input', vdp); + + app.use(ToastPlugin); app.use(store); app.mount('#app'); diff --git a/resources/js/client-vue/vueDateTimePickerClient.vue b/resources/js/client-vue/vueDateTimePickerClient.vue new file mode 100644 index 0000000..3f165b7 --- /dev/null +++ b/resources/js/client-vue/vueDateTimePickerClient.vue @@ -0,0 +1,1219 @@ + + + + + diff --git a/resources/sass/panel/_common.scss b/resources/sass/panel/_common.scss index 95e8cf7..afb981a 100644 --- a/resources/sass/panel/_common.scss +++ b/resources/sass/panel/_common.scss @@ -166,6 +166,10 @@ a.btn,a.action-btn,a.circle-btn{ } } +#avatar-input{ + display: none; +} + .ol-sortable { padding-right: 1rem; @@ -330,3 +334,4 @@ a.btn,a.action-btn,a.circle-btn{ transform: rotate(360deg); } } + diff --git a/resources/views/admin/customers/customer-form.blade.php b/resources/views/admin/customers/customer-form.blade.php index d77daed..7d4fe59 100644 --- a/resources/views/admin/customers/customer-form.blade.php +++ b/resources/views/admin/customers/customer-form.blade.php @@ -24,6 +24,14 @@ @if(isset($item)) +
+

+ + {{__("Avatar")}} +

+ + +

@@ -89,6 +97,44 @@

+
+
+ + +
+
+
+ + +
+
+ + +
+
+ + +
+ minlength="10"/>
@@ -128,7 +174,7 @@ type="checkbox" id="colleague" name="colleague" @if (isset($item) && $item->colleague) checked - @endif> + @endif>
diff --git a/resources/views/segments/customer/AvisaCustomer/AvisaCustomer.blade.php b/resources/views/segments/customer/AvisaCustomer/AvisaCustomer.blade.php index 45665a2..bfbd557 100644 --- a/resources/views/segments/customer/AvisaCustomer/AvisaCustomer.blade.php +++ b/resources/views/segments/customer/AvisaCustomer/AvisaCustomer.blade.php @@ -2,7 +2,7 @@
- [avatar] + [avatar]
{{__("Welcome back")}}
@@ -227,7 +227,8 @@ @if( in_array($inv->status, ['PENDING', 'CANCELED', 'FAILED'] ) && $inv->created_at->timestamp > (time() - 3600) ) - + {{__("Pay now")}} @@ -242,7 +243,7 @@
{{__("If you want to change the password, choose both the same. Otherwise, leave the password field blank.")}}
-
+ @csrf
@@ -279,7 +280,50 @@ min-length="10"/>
-
+
+
+ + +
+
+
+ + +
+
+ + +
+
+ + +
+
-
+
+
+
+ + +
+