From 4a08414ca55419599048902d67bd4b76005c0696 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 12 Aug 2019 22:45:13 +1000 Subject: [PATCH] Working on User profile --- .../ClientPortal/ProfileController.php | 8 +- .../ClientPortal/StoreDocumentRequest.php | 3 +- .../ClientPortal/UpdateContactRequest.php | 46 +++++ package.json | 1 + .../portal/default/client/edit.blade.php | 160 ++++++++++++++++++ .../portal/default/profile/index.blade.php | 121 ++++--------- routes/client.php | 2 +- 7 files changed, 251 insertions(+), 90 deletions(-) create mode 100644 app/Http/Requests/ClientPortal/UpdateContactRequest.php create mode 100644 resources/views/portal/default/client/edit.blade.php diff --git a/app/Http/Controllers/ClientPortal/ProfileController.php b/app/Http/Controllers/ClientPortal/ProfileController.php index aa13a6f2a9f2..474bd8973994 100644 --- a/app/Http/Controllers/ClientPortal/ProfileController.php +++ b/app/Http/Controllers/ClientPortal/ProfileController.php @@ -12,6 +12,7 @@ namespace App\Http\Controllers\ClientPortal; use App\Http\Controllers\Controller; +use App\Http\Requests\ClientPortal\UpdateContactRequest; use App\Models\ClientContact; use Illuminate\Http\Request; @@ -56,9 +57,12 @@ class ProfileController extends Controller * @param int $id * @return \Illuminate\Http\Response */ - public function update(Request $request, ClientContact $client_contact) + public function update(UpdateContactRequest $request, ClientContact $client_contact) { - dd($client_contact); + //dd($client_contact); + tap($client_contact)->update($request->all()); + + return view('portal.default.profile.index'); } } diff --git a/app/Http/Requests/ClientPortal/StoreDocumentRequest.php b/app/Http/Requests/ClientPortal/StoreDocumentRequest.php index eca3c4f2ef05..d69d69caa29d 100644 --- a/app/Http/Requests/ClientPortal/StoreDocumentRequest.php +++ b/app/Http/Requests/ClientPortal/StoreDocumentRequest.php @@ -29,12 +29,11 @@ class StoreDocumentRequest extends Request public function rules() { - //$this->sanitize(); return [ -// 'file' => 'required|max:10000|mimes:png,ai,svg,jpeg,tiff,pdf,gif,psd,txt,doc,xls,ppt,xlsx,docx,pptx' 'file' => 'required|max:10000|mimes:png,svg,jpeg,gif,jpg,bmp' ]; + } public function response(array $errors) diff --git a/app/Http/Requests/ClientPortal/UpdateContactRequest.php b/app/Http/Requests/ClientPortal/UpdateContactRequest.php new file mode 100644 index 000000000000..ef6b783fe033 --- /dev/null +++ b/app/Http/Requests/ClientPortal/UpdateContactRequest.php @@ -0,0 +1,46 @@ + 'required', + 'last_name' => 'required', + 'email' => 'required|email', + 'password' => 'sometimes|nullable|min:6|confirmed', + 'file' => 'sometimes|nullable|max:100000|mimes:png,svg,jpeg,gif,jpg,bmp' + ]; + + } + + + +} + diff --git a/package.json b/package.json index c5a3a91d564a..08c3ef51ccc0 100644 --- a/package.json +++ b/package.json @@ -13,6 +13,7 @@ "dependencies": { "@coreui/coreui": "^2.1.12", "@coreui/icons": "^0.3.0", + "@ttskch/select2-bootstrap4-theme": "^1.2.3", "bootstrap": "^4.3.1", "bootstrap-sweetalert": "^1.0.1", "cross-env": "^5.2.0", diff --git a/resources/views/portal/default/client/edit.blade.php b/resources/views/portal/default/client/edit.blade.php new file mode 100644 index 000000000000..ab5e975ae2ca --- /dev/null +++ b/resources/views/portal/default/client/edit.blade.php @@ -0,0 +1,160 @@ +@extends('portal.default.layouts.master') +@push('css') + + + +@endpush +@section('body') +
+
+ +
+ +
+ + {!! Former::framework('TwitterBootstrap4'); !!} + + {!! Former::horizontal_open() + ->id('update_contact') + ->route('client.profile.update', auth()->user()->hashed_id) + ->method('PUT'); !!} + +
+ +
+ + {{ ctrans('texts.avatar') }} +
+ +
+ + + +
+ +
+ +
+ +
+ +
+ +
+ + {{ ctrans('texts.client_information') }} + +
+ +
+ + {!! Former::text('name')->placeholder( ctrans('texts.first_name'))->label('') !!} + {!! Former::text('phone')->placeholder( ctrans('texts.phone'))->label('') !!} + {!! Former::text('website')->placeholder( ctrans('texts.website'))->label('') !!} + + {!! Former::text('address1')->placeholder( ctrans('texts.address1'))->label('') !!} + {!! Former::text('address2')->placeholder( ctrans('texts.address2'))->label('') !!} + {!! Former::text('city')->placeholder( ctrans('texts.city'))->label('') !!} + {!! Former::text('state')->placeholder( ctrans('texts.state'))->label('') !!} + {!! Former::text('postal_code')->placeholder( ctrans('texts.postal_code'))->label('') !!} + + + {!! Former::select('country_id') + ->addOption('','') + ->autocomplete('off') + ->label('') + ->fromQuery($countries, 'name', 'id') !!} + + + + {!! Former::text('shipping_address1')->placeholder( ctrans('texts.shipping_address1'))->label('') !!} + {!! Former::text('shipping_address2')->placeholder( ctrans('texts.shipping_address2'))->label('') !!} + {!! Former::text('shipping_city')->placeholder( ctrans('texts.shipping_city'))->label('') !!} + {!! Former::text('shipping_state')->placeholder( ctrans('texts.shipping_state'))->label('') !!} + {!! Former::text('shipping_postal_code')->placeholder( ctrans('texts.shipping_postal_code'))->label('') !!} + + {!! Former::select('shipping_country_id') + ->addOption('','') + ->autocomplete('off') + ->label('') + ->fromQuery($countries, 'name', 'id') !!} + +
+ + +
+ +
+ +
+ + {{ ctrans('texts.user_details') }} + +
+ +
+ + + {!! Former::text('first_name')->placeholder( ctrans('texts.first_name'))->label('') !!} + + {!! Former::text('last_name')->placeholder( ctrans('texts.last_name'))->label('') !!} + + {!! Former::text('email')->placeholder( ctrans('texts.email'))->label('') !!} + + {!! Former::text('phone')->placeholder( ctrans('texts.phone'))->label('') !!} + +
+ + +
+ + {!! Former::close() !!} + +
+ +
+ +
+
+ +@endsection +@push('scripts') + +@endpush + +@section('footer') + + + +@endsection \ No newline at end of file diff --git a/resources/views/portal/default/profile/index.blade.php b/resources/views/portal/default/profile/index.blade.php index ab5e975ae2ca..e7145b76d70b 100644 --- a/resources/views/portal/default/profile/index.blade.php +++ b/resources/views/portal/default/profile/index.blade.php @@ -13,6 +13,7 @@ @endpush @section('body')
+
@@ -25,16 +26,35 @@ ->id('update_contact') ->route('client.profile.update', auth()->user()->hashed_id) ->method('PUT'); !!} + + @csrf
{{ ctrans('texts.avatar') }} +
-
+
+ @if(auth()->user()->avatar) + + @else + + @endif + + + {!! Former::file('avatar') + ->max(2, 'MB') + ->accept('image') + ->label(trans('texts.avatar')) + ->inlineHelp(trans('texts.logo_help')) !!} + +
+ + @@ -43,54 +63,8 @@
-
+
-
- -
- - {{ ctrans('texts.client_information') }} - -
- -
- - {!! Former::text('name')->placeholder( ctrans('texts.first_name'))->label('') !!} - {!! Former::text('phone')->placeholder( ctrans('texts.phone'))->label('') !!} - {!! Former::text('website')->placeholder( ctrans('texts.website'))->label('') !!} - - {!! Former::text('address1')->placeholder( ctrans('texts.address1'))->label('') !!} - {!! Former::text('address2')->placeholder( ctrans('texts.address2'))->label('') !!} - {!! Former::text('city')->placeholder( ctrans('texts.city'))->label('') !!} - {!! Former::text('state')->placeholder( ctrans('texts.state'))->label('') !!} - {!! Former::text('postal_code')->placeholder( ctrans('texts.postal_code'))->label('') !!} - - - {!! Former::select('country_id') - ->addOption('','') - ->autocomplete('off') - ->label('') - ->fromQuery($countries, 'name', 'id') !!} - - - - {!! Former::text('shipping_address1')->placeholder( ctrans('texts.shipping_address1'))->label('') !!} - {!! Former::text('shipping_address2')->placeholder( ctrans('texts.shipping_address2'))->label('') !!} - {!! Former::text('shipping_city')->placeholder( ctrans('texts.shipping_city'))->label('') !!} - {!! Former::text('shipping_state')->placeholder( ctrans('texts.shipping_state'))->label('') !!} - {!! Former::text('shipping_postal_code')->placeholder( ctrans('texts.shipping_postal_code'))->label('') !!} - - {!! Former::select('shipping_country_id') - ->addOption('','') - ->autocomplete('off') - ->label('') - ->fromQuery($countries, 'name', 'id') !!} - -
- - -
-
@@ -101,17 +75,25 @@
+ {!! Former::text('first_name')->placeholder( ctrans('texts.first_name'))->label('')->value(auth()->user()->first_name)!!} - {!! Former::text('first_name')->placeholder( ctrans('texts.first_name'))->label('') !!} + {!! Former::text('last_name')->placeholder( ctrans('texts.last_name'))->label('')->value(auth()->user()->last_name) !!} - {!! Former::text('last_name')->placeholder( ctrans('texts.last_name'))->label('') !!} + {!! Former::text('email')->placeholder( ctrans('texts.email'))->label('')->value(auth()->user()->email) !!} - {!! Former::text('email')->placeholder( ctrans('texts.email'))->label('') !!} + {!! Former::text('phone')->placeholder( ctrans('texts.phone'))->label('')->value(auth()->user()->phone) !!} - {!! Former::text('phone')->placeholder( ctrans('texts.phone'))->label('') !!} + {!! Former::password('password')->placeholder( ctrans('texts.password'))->label('') !!} + + {!! Former::password('password_confirmed')->placeholder( ctrans('texts.confirm_password'))->label('') !!}
+
@@ -122,39 +104,8 @@
+
+ -@endsection -@push('scripts') - -@endpush - -@section('footer') - - - @endsection \ No newline at end of file diff --git a/routes/client.php b/routes/client.php index 68d13207ad47..d1d612da7232 100644 --- a/routes/client.php +++ b/routes/client.php @@ -17,7 +17,7 @@ Route::group(['middleware' => ['auth:contact'], 'prefix' => 'client', 'as' => 'c Route::get('dashboard', 'ClientPortal\DashboardController@index')->name('dashboard'); // name = (dashboard. index / create / show / update / destroy / edit Route::get('invoices', 'ClientPortal\InvoiceController@index')->name('invoices.index'); // name = (dashboard. index / create / show / update / destroy / edit Route::get('profile/{client_contact}/edit', 'ClientPortal\ProfileController@edit')->name('profile.edit'); - Route::put('profile/{client_contact}/edit', 'ClientPortal\ProfileController@update')->name('profile.update'); + Route::put('profile/{client_contact}', 'ClientPortal\ProfileController@update')->name('profile.update'); Route::post('document', 'ClientPortal\DocumentController@store')->name('document.store'); Route::delete('document', 'ClientPortal\DocumentController@destroy')->name('document.destroy');