Working on User profile

This commit is contained in:
David Bomba 2019-08-12 22:45:13 +10:00
parent 6b025296bd
commit 4a08414ca5
7 changed files with 251 additions and 90 deletions

View File

@ -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');
}
}

View File

@ -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)

View File

@ -0,0 +1,46 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com)
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2019. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
*/
namespace App\Http\Requests\ClientPortal;
use App\Http\Requests\Request;
use Zend\Diactoros\Response\JsonResponse;
class UpdateContactRequest extends Request
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize() : bool
{
return true;
}
public function rules()
{
return [
'first_name' => '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'
];
}
}

View File

@ -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",

View File

@ -0,0 +1,160 @@
@extends('portal.default.layouts.master')
@push('css')
<link href="/vendors/css/select2.min.css" rel="stylesheet">
<link href="/vendors/css/select2-bootstrap4.css" rel="stylesheet">
<style>
select {border: 1px solid !important;}
.select2-container--bootstrap4 .select2-selection--single
{
border: 1px solid #e4e7ea !important;
}
</style>
@endpush
@section('body')
<main class="main">
<div class="container-fluid">
<div class="row" style="padding-top: 30px;">
<div class="col-sm-3" style="padding-bottom: 10px;">
{!! Former::framework('TwitterBootstrap4'); !!}
{!! Former::horizontal_open()
->id('update_contact')
->route('client.profile.update', auth()->user()->hashed_id)
->method('PUT'); !!}
<div class="card">
<div class="card-header">
<strong>{{ ctrans('texts.avatar') }}</strong>
</div>
<div class="card-body">
</div>
</div>
</div>
<div class="col-sm-9" style="padding-bottom: 10px;">
<div class="card">
<div class="card-header">
<strong> {{ ctrans('texts.client_information') }}</strong>
</div>
<div class="card-body">
{!! 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') !!}
</div>
</div>
<div class="card">
<div class="card-header">
<strong> {{ ctrans('texts.user_details') }}</strong>
</div>
<div class="card-body">
{!! 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('') !!}
</div>
</div>
{!! Former::close() !!}
</div>
</div>
</div>
</main>
</body>
@endsection
@push('scripts')
<script src="/vendors/js/select2.min.js"></script>
@endpush
@section('footer')
<script>
$(document).ready(function() {
$('#shipping_country_id').select2({
placeholder: "{{ ctrans('texts.country') }}",
//allowClear: true,
theme: "bootstrap4",
}).on('change', function() {
});
$('#country_id').each(function () {
$(this).select2({
placeholder: "{{ ctrans('texts.country') }}",
theme: 'bootstrap4',
width: 'style',
allowClear: Boolean($(this).data('allow-clear')),
});
});
});
</script>
@endsection

View File

@ -13,6 +13,7 @@
@endpush
@section('body')
<main class="main">
<div class="container-fluid">
<div class="row" style="padding-top: 30px;">
@ -25,16 +26,35 @@
->id('update_contact')
->route('client.profile.update', auth()->user()->hashed_id)
->method('PUT'); !!}
@csrf
<div class="card">
<div class="card-header">
<strong>{{ ctrans('texts.avatar') }}</strong>
</div>
<div class="card-body">
<div class="card-body align-items-center">
@if(auth()->user()->avatar)
<img src="{{ auth()->user()->avatar }}">
@else
<i class="fa fa-user fa-5x"></i>
@endif
{!! Former::file('avatar')
->max(2, 'MB')
->accept('image')
->label(trans('texts.avatar'))
->inlineHelp(trans('texts.logo_help')) !!}
</div>
<div class="card-footer">
</div>
@ -43,54 +63,8 @@
</div>
<div class="col-sm-9" style="padding-bottom: 10px;">
<div class="col-sm-6" style="padding-bottom: 10px;">
<div class="card">
<div class="card-header">
<strong> {{ ctrans('texts.client_information') }}</strong>
</div>
<div class="card-body">
{!! 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') !!}
</div>
</div>
<div class="card">
<div class="card-header">
@ -101,17 +75,25 @@
<div class="card-body">
{!! 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('') !!}
</div>
<div class="card-footer">
<button class="btn btn-primary pull-right">Save</button>
</div>
</div>
@ -122,39 +104,8 @@
</div>
</div>
</main>
</body>
@endsection
@push('scripts')
<script src="/vendors/js/select2.min.js"></script>
@endpush
@section('footer')
<script>
$(document).ready(function() {
$('#shipping_country_id').select2({
placeholder: "{{ ctrans('texts.country') }}",
//allowClear: true,
theme: "bootstrap4",
}).on('change', function() {
});
$('#country_id').each(function () {
$(this).select2({
placeholder: "{{ ctrans('texts.country') }}",
theme: 'bootstrap4',
width: 'style',
allowClear: Boolean($(this).data('allow-clear')),
});
});
});
</script>
@endsection

View File

@ -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');