Add Profile Information in MyAccountController [backpack-laravel]












0















I thought about adding a page, to change the profile of a user: name, surname, etc.



Bug report



File: MyAccountController.php



function: public function postAccountProfileForm(UpdateRequest $request)
the FormRequest, returns empty



What I did:



DB:
users->Profiles



File Controller: AppHttpControllersAuthMyAccountController



    namespace AppHttpControllersAuth;

use BackpackBaseappHttpControllersAuthMyAccountController as BaseMyAccountController;
use AppHttpRequestsAuthAccount_profileRequest as StoreRequest;
use AppHttpRequestsAuthAccount_profileRequest as UpdateRequest;
use Auth;
use AppModelsAuthAccount_profile;

class MyAccountController extends BaseMyAccountController
{
/**
* Show the user a form to change his personal information.
*/
public function getAccountProfileForm()
{
$user = Auth::user();
$this->data['title'] = trans('backpack::base.my_account');
$this->data['profile'] = Account_profile::getAccount_profilebyId($user->id);

return view('backpack::auth.account.update_profile', $this->data);
}

/**
* Save the modified personal information for a user.
*/
public function postAccountProfileForm(UpdateRequest $request)
{
//var_dump($request);
//die();
//$result = $this->guard()->user()->update($request->except(['_token']));
$result = Account_profile::getAccount_profilebyId($this->guard()->user()['id'])->update($request->except(['_token']));

if ($result) {
Alert::success(trans('backpack::base.account_updated'))->flash();
} else {
Alert::error(trans('backpack::base.error_saving'))->flash();
}

return redirect()->back();
}
}


File Request: AppHttpRequestsAuthAccount_profileRequest



    namespace AppHttpRequestsAuth;
use AppHttpRequestsRequest;
use IlluminateFoundationHttpFormRequest;

class Account_profileRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
// only allow updates if the user is logged in
return backpack_auth()->check();
}

/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
// 'name' => 'required|min:5|max:255'
'nome' => 'required|min:5|max:45',
'cognome' => 'required|min:5|max:45',
'sesso' => 'required|min:5|max:45',
'countrys_id' => 'required|numeric',
'regions_id' => 'required|numeric',
//'provinces_id' => 'required|numeric',
//'citys_id' => 'required|numeric',
'users_id' => 'required|numeric',
//'attivo' => 'required|boolean',
//'accetto_condizionigenerali' => 'required|boolean',
//'accetto_marketing' => 'required|boolean',
//'attivo_notifiche' => 'required|boolean'
//continue_13
];
}

/**
* Get the validation attributes that apply to the request.
*
* @return array
*/
public function attributes()
{
return [
//
];
}

/**
* Get the validation messages that apply to the request.
*
* @return array
*/
public function messages()
{
return [
//
];
}
}


File Models: AppModelsAuthAccount_profile



    namespace AppModelsAuth;

use IlluminateDatabaseEloquentModel;
use BackpackCRUDCrudTrait;

use AppModelsProfile;

class Account_profile extends Model
{
use CrudTrait;

/*
|--------------------------------------------------------------------------
| GLOBAL VARIABLES
|--------------------------------------------------------------------------
*/

/*
|--------------------------------------------------------------------------
| FUNCTIONS
|--------------------------------------------------------------------------
*/
public static function getAccount_profilebyId($id)
{
return Profile::find($id);
}

/*
|--------------------------------------------------------------------------
| RELATIONS
|--------------------------------------------------------------------------
*/

/*
|--------------------------------------------------------------------------
| SCOPES
|--------------------------------------------------------------------------
*/

/*
|--------------------------------------------------------------------------
| ACCESORS
|--------------------------------------------------------------------------
*/

/*
|--------------------------------------------------------------------------
| MUTATORS
|--------------------------------------------------------------------------
*/
}


File Route: RoutesbackpackCustom



    // --------------------------
// Custom Backpack Routes
// --------------------------
// This route file is loaded automatically by BackpackBase.
// Routes you generate using BackpackGenerators will be placed here.

Route::group([
'prefix' => config('backpack.base.route_prefix', 'admin'),
'middleware' => ['web', config('backpack.base.middleware_key', 'admin')],
'namespace' => 'AppHttpControllersAdmin',
], function () { // custom admin routes
}); // this should be the absolute last line of this file


Route::group(
[
'namespace' => 'AppHttpControllersAuth',
'middleware' => ['web', config('backpack.base.middleware_key', 'admin')],
'prefix' => config('backpack.base.route_prefix'),
],
function () {
// if not otherwise configured, setup the auth routes
if (config('backpack.base.setup_auth_routes')) {
// Authentication Routes...

}

// if not otherwise configured, setup the dashboard routes
if (config('backpack.base.setup_dashboard_routes')) {
Route::get('dashboard', 'AdminController@dashboard')->name('backpack.dashboard');
Route::get('/', 'AdminController@redirect')->name('backpack');
}

// if not otherwise configured, setup the "my account" routes
if (config('backpack.base.setup_my_account_routes')) {
Route::get('edit-account-profile', 'MyAccountController@getAccountProfileForm')->name('backpack.account.profile');
Route::post('edit-account-profile', 'MyAccountController@postAccountProfileForm');
}
});


File Blade: resourcesviewsvendorbackpackbaseauthaccountupdate_profile.blade.php



    @extends('backpack::layout')

@section('after_styles')
<style media="screen">
.backpack-profile-form .required::after {
content: ' *';
color: red;
}
</style>
@endsection

@section('header')
<section class="content-header">

<h1>
{{ trans('backpack::base.my_account') }}
</h1>

<ol class="breadcrumb">

<li>
<a href="{{ backpack_url() }}">{{ config('backpack.base.project_name') }}</a>
</li>

<li>
<a href="{{ route('backpack.account.info') }}">{{ trans('backpack::base.my_account') }}</a>
</li>

<li class="active">
{{ trans('backpack::base.update_account_info') }} Profile
</li>

</ol>

</section>
@endsection

@section('content')
<div class="row">
<div class="col-md-3">
@include('backpack::auth.account.sidemenu')
</div>
<div class="col-md-6">


<div class="box">
<div class="box-body backpack-profile-form">
{!! Form::open(array('route' => 'backpack.account.profile', 'method' => 'post')) !!}
<div class="form-group">
@php
$label = 'Nome';
$field = 'nome';
@endphp
{!! Form::label($field, $label, ['class' => 'required']) !!}
{!! Form::text($field, old($field) ? old($field) : $profile->$field, ['class' => 'form-control', 'required']) !!}
</div>
<div class="clearfix"></div>
<div class="form-group">
@php
$label = 'Cognome';
$field = 'cognome';
@endphp
{!! Form::label($field, $label, ['class' => 'required']) !!}
{!! Form::text($field, old($field) ? old($field) : $profile->$field, ['class' => 'form-control', 'required']) !!}
</div>
<div class="clearfix"></div>
<div class="form-group">
@php
$label = 'Sex';
$field = 'sesso';
@endphp
{!! Form::label($field, $label, ['class' => 'required']) !!}
{!! Form::select($field, array('M' => 'Male', 'F' => 'Female'), old($field) ? old($field) : $profile->$field, ['class' => 'form-control', 'required']) !!}
</div>
<div class="clearfix"></div>
<div class="box-footer">
@php
$field = 'id';
$label = '<span class="ladda-label"><i class="fa fa-save"></i>'.trans('backpack::base.save').'</span>';
@endphp
{!! Form::hidden($field, old($field) ? old($field) : $profile->$field) !!}
{!! Form::button($label, ['class' => 'btn btn-success', 'type' => 'submit']) !!}
<a href="{{ backpack_url() }}" class="btn btn-default"><span class="ladda-label">{{ trans('backpack::base.cancel') }}</span></a>
</div>
{!! Form::close() !!}
</div>
</div>


</div>
</div>
@endsection


What I expected to happen:



I expect that the form is validated



What happened:



when I submit, the request returns to me empty



What I've already tried to fix it:



Backpack, Laravel, PHP, DB version:



Laravel Framework 5.7.12
"php": "^7.1.3"
"backpack/backupmanager": "^1.4"
"backpack/crud": "^3.4"
"backpack/langfilemanager": "^1.0"
"backpack/logmanager": "^2.3"
"backpack/newscrud": "^2.1"
"backpack/pagemanager": "^1.1"
"backpack/permissionmanager": "^3.12"
"backpack/settings": "^2.1"
"barryvdh/laravel-elfinder": "^0.4.1"
"fideloper/proxy": "^4.0"
"laravel/framework": "5.7.*",
"laravel/tinker": "^1.0",
"laravelcollective/html": "^5.7",
"mews/purifier": "^2.1",
"tymon/jwt-auth": "^0.5.12"










share|improve this question























  • If you found a bug, then reporting it to the developers should probably be the best option you have. According to their documentation, they usually handle bug reports on Backpack for Laravel's Github. If you have some time left then, you can also read Stackoverflow's "What topics can I ask about here?".

    – P. Ellul
    Nov 21 '18 at 9:39


















0















I thought about adding a page, to change the profile of a user: name, surname, etc.



Bug report



File: MyAccountController.php



function: public function postAccountProfileForm(UpdateRequest $request)
the FormRequest, returns empty



What I did:



DB:
users->Profiles



File Controller: AppHttpControllersAuthMyAccountController



    namespace AppHttpControllersAuth;

use BackpackBaseappHttpControllersAuthMyAccountController as BaseMyAccountController;
use AppHttpRequestsAuthAccount_profileRequest as StoreRequest;
use AppHttpRequestsAuthAccount_profileRequest as UpdateRequest;
use Auth;
use AppModelsAuthAccount_profile;

class MyAccountController extends BaseMyAccountController
{
/**
* Show the user a form to change his personal information.
*/
public function getAccountProfileForm()
{
$user = Auth::user();
$this->data['title'] = trans('backpack::base.my_account');
$this->data['profile'] = Account_profile::getAccount_profilebyId($user->id);

return view('backpack::auth.account.update_profile', $this->data);
}

/**
* Save the modified personal information for a user.
*/
public function postAccountProfileForm(UpdateRequest $request)
{
//var_dump($request);
//die();
//$result = $this->guard()->user()->update($request->except(['_token']));
$result = Account_profile::getAccount_profilebyId($this->guard()->user()['id'])->update($request->except(['_token']));

if ($result) {
Alert::success(trans('backpack::base.account_updated'))->flash();
} else {
Alert::error(trans('backpack::base.error_saving'))->flash();
}

return redirect()->back();
}
}


File Request: AppHttpRequestsAuthAccount_profileRequest



    namespace AppHttpRequestsAuth;
use AppHttpRequestsRequest;
use IlluminateFoundationHttpFormRequest;

class Account_profileRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
// only allow updates if the user is logged in
return backpack_auth()->check();
}

/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
// 'name' => 'required|min:5|max:255'
'nome' => 'required|min:5|max:45',
'cognome' => 'required|min:5|max:45',
'sesso' => 'required|min:5|max:45',
'countrys_id' => 'required|numeric',
'regions_id' => 'required|numeric',
//'provinces_id' => 'required|numeric',
//'citys_id' => 'required|numeric',
'users_id' => 'required|numeric',
//'attivo' => 'required|boolean',
//'accetto_condizionigenerali' => 'required|boolean',
//'accetto_marketing' => 'required|boolean',
//'attivo_notifiche' => 'required|boolean'
//continue_13
];
}

/**
* Get the validation attributes that apply to the request.
*
* @return array
*/
public function attributes()
{
return [
//
];
}

/**
* Get the validation messages that apply to the request.
*
* @return array
*/
public function messages()
{
return [
//
];
}
}


File Models: AppModelsAuthAccount_profile



    namespace AppModelsAuth;

use IlluminateDatabaseEloquentModel;
use BackpackCRUDCrudTrait;

use AppModelsProfile;

class Account_profile extends Model
{
use CrudTrait;

/*
|--------------------------------------------------------------------------
| GLOBAL VARIABLES
|--------------------------------------------------------------------------
*/

/*
|--------------------------------------------------------------------------
| FUNCTIONS
|--------------------------------------------------------------------------
*/
public static function getAccount_profilebyId($id)
{
return Profile::find($id);
}

/*
|--------------------------------------------------------------------------
| RELATIONS
|--------------------------------------------------------------------------
*/

/*
|--------------------------------------------------------------------------
| SCOPES
|--------------------------------------------------------------------------
*/

/*
|--------------------------------------------------------------------------
| ACCESORS
|--------------------------------------------------------------------------
*/

/*
|--------------------------------------------------------------------------
| MUTATORS
|--------------------------------------------------------------------------
*/
}


File Route: RoutesbackpackCustom



    // --------------------------
// Custom Backpack Routes
// --------------------------
// This route file is loaded automatically by BackpackBase.
// Routes you generate using BackpackGenerators will be placed here.

Route::group([
'prefix' => config('backpack.base.route_prefix', 'admin'),
'middleware' => ['web', config('backpack.base.middleware_key', 'admin')],
'namespace' => 'AppHttpControllersAdmin',
], function () { // custom admin routes
}); // this should be the absolute last line of this file


Route::group(
[
'namespace' => 'AppHttpControllersAuth',
'middleware' => ['web', config('backpack.base.middleware_key', 'admin')],
'prefix' => config('backpack.base.route_prefix'),
],
function () {
// if not otherwise configured, setup the auth routes
if (config('backpack.base.setup_auth_routes')) {
// Authentication Routes...

}

// if not otherwise configured, setup the dashboard routes
if (config('backpack.base.setup_dashboard_routes')) {
Route::get('dashboard', 'AdminController@dashboard')->name('backpack.dashboard');
Route::get('/', 'AdminController@redirect')->name('backpack');
}

// if not otherwise configured, setup the "my account" routes
if (config('backpack.base.setup_my_account_routes')) {
Route::get('edit-account-profile', 'MyAccountController@getAccountProfileForm')->name('backpack.account.profile');
Route::post('edit-account-profile', 'MyAccountController@postAccountProfileForm');
}
});


File Blade: resourcesviewsvendorbackpackbaseauthaccountupdate_profile.blade.php



    @extends('backpack::layout')

@section('after_styles')
<style media="screen">
.backpack-profile-form .required::after {
content: ' *';
color: red;
}
</style>
@endsection

@section('header')
<section class="content-header">

<h1>
{{ trans('backpack::base.my_account') }}
</h1>

<ol class="breadcrumb">

<li>
<a href="{{ backpack_url() }}">{{ config('backpack.base.project_name') }}</a>
</li>

<li>
<a href="{{ route('backpack.account.info') }}">{{ trans('backpack::base.my_account') }}</a>
</li>

<li class="active">
{{ trans('backpack::base.update_account_info') }} Profile
</li>

</ol>

</section>
@endsection

@section('content')
<div class="row">
<div class="col-md-3">
@include('backpack::auth.account.sidemenu')
</div>
<div class="col-md-6">


<div class="box">
<div class="box-body backpack-profile-form">
{!! Form::open(array('route' => 'backpack.account.profile', 'method' => 'post')) !!}
<div class="form-group">
@php
$label = 'Nome';
$field = 'nome';
@endphp
{!! Form::label($field, $label, ['class' => 'required']) !!}
{!! Form::text($field, old($field) ? old($field) : $profile->$field, ['class' => 'form-control', 'required']) !!}
</div>
<div class="clearfix"></div>
<div class="form-group">
@php
$label = 'Cognome';
$field = 'cognome';
@endphp
{!! Form::label($field, $label, ['class' => 'required']) !!}
{!! Form::text($field, old($field) ? old($field) : $profile->$field, ['class' => 'form-control', 'required']) !!}
</div>
<div class="clearfix"></div>
<div class="form-group">
@php
$label = 'Sex';
$field = 'sesso';
@endphp
{!! Form::label($field, $label, ['class' => 'required']) !!}
{!! Form::select($field, array('M' => 'Male', 'F' => 'Female'), old($field) ? old($field) : $profile->$field, ['class' => 'form-control', 'required']) !!}
</div>
<div class="clearfix"></div>
<div class="box-footer">
@php
$field = 'id';
$label = '<span class="ladda-label"><i class="fa fa-save"></i>'.trans('backpack::base.save').'</span>';
@endphp
{!! Form::hidden($field, old($field) ? old($field) : $profile->$field) !!}
{!! Form::button($label, ['class' => 'btn btn-success', 'type' => 'submit']) !!}
<a href="{{ backpack_url() }}" class="btn btn-default"><span class="ladda-label">{{ trans('backpack::base.cancel') }}</span></a>
</div>
{!! Form::close() !!}
</div>
</div>


</div>
</div>
@endsection


What I expected to happen:



I expect that the form is validated



What happened:



when I submit, the request returns to me empty



What I've already tried to fix it:



Backpack, Laravel, PHP, DB version:



Laravel Framework 5.7.12
"php": "^7.1.3"
"backpack/backupmanager": "^1.4"
"backpack/crud": "^3.4"
"backpack/langfilemanager": "^1.0"
"backpack/logmanager": "^2.3"
"backpack/newscrud": "^2.1"
"backpack/pagemanager": "^1.1"
"backpack/permissionmanager": "^3.12"
"backpack/settings": "^2.1"
"barryvdh/laravel-elfinder": "^0.4.1"
"fideloper/proxy": "^4.0"
"laravel/framework": "5.7.*",
"laravel/tinker": "^1.0",
"laravelcollective/html": "^5.7",
"mews/purifier": "^2.1",
"tymon/jwt-auth": "^0.5.12"










share|improve this question























  • If you found a bug, then reporting it to the developers should probably be the best option you have. According to their documentation, they usually handle bug reports on Backpack for Laravel's Github. If you have some time left then, you can also read Stackoverflow's "What topics can I ask about here?".

    – P. Ellul
    Nov 21 '18 at 9:39
















0












0








0








I thought about adding a page, to change the profile of a user: name, surname, etc.



Bug report



File: MyAccountController.php



function: public function postAccountProfileForm(UpdateRequest $request)
the FormRequest, returns empty



What I did:



DB:
users->Profiles



File Controller: AppHttpControllersAuthMyAccountController



    namespace AppHttpControllersAuth;

use BackpackBaseappHttpControllersAuthMyAccountController as BaseMyAccountController;
use AppHttpRequestsAuthAccount_profileRequest as StoreRequest;
use AppHttpRequestsAuthAccount_profileRequest as UpdateRequest;
use Auth;
use AppModelsAuthAccount_profile;

class MyAccountController extends BaseMyAccountController
{
/**
* Show the user a form to change his personal information.
*/
public function getAccountProfileForm()
{
$user = Auth::user();
$this->data['title'] = trans('backpack::base.my_account');
$this->data['profile'] = Account_profile::getAccount_profilebyId($user->id);

return view('backpack::auth.account.update_profile', $this->data);
}

/**
* Save the modified personal information for a user.
*/
public function postAccountProfileForm(UpdateRequest $request)
{
//var_dump($request);
//die();
//$result = $this->guard()->user()->update($request->except(['_token']));
$result = Account_profile::getAccount_profilebyId($this->guard()->user()['id'])->update($request->except(['_token']));

if ($result) {
Alert::success(trans('backpack::base.account_updated'))->flash();
} else {
Alert::error(trans('backpack::base.error_saving'))->flash();
}

return redirect()->back();
}
}


File Request: AppHttpRequestsAuthAccount_profileRequest



    namespace AppHttpRequestsAuth;
use AppHttpRequestsRequest;
use IlluminateFoundationHttpFormRequest;

class Account_profileRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
// only allow updates if the user is logged in
return backpack_auth()->check();
}

/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
// 'name' => 'required|min:5|max:255'
'nome' => 'required|min:5|max:45',
'cognome' => 'required|min:5|max:45',
'sesso' => 'required|min:5|max:45',
'countrys_id' => 'required|numeric',
'regions_id' => 'required|numeric',
//'provinces_id' => 'required|numeric',
//'citys_id' => 'required|numeric',
'users_id' => 'required|numeric',
//'attivo' => 'required|boolean',
//'accetto_condizionigenerali' => 'required|boolean',
//'accetto_marketing' => 'required|boolean',
//'attivo_notifiche' => 'required|boolean'
//continue_13
];
}

/**
* Get the validation attributes that apply to the request.
*
* @return array
*/
public function attributes()
{
return [
//
];
}

/**
* Get the validation messages that apply to the request.
*
* @return array
*/
public function messages()
{
return [
//
];
}
}


File Models: AppModelsAuthAccount_profile



    namespace AppModelsAuth;

use IlluminateDatabaseEloquentModel;
use BackpackCRUDCrudTrait;

use AppModelsProfile;

class Account_profile extends Model
{
use CrudTrait;

/*
|--------------------------------------------------------------------------
| GLOBAL VARIABLES
|--------------------------------------------------------------------------
*/

/*
|--------------------------------------------------------------------------
| FUNCTIONS
|--------------------------------------------------------------------------
*/
public static function getAccount_profilebyId($id)
{
return Profile::find($id);
}

/*
|--------------------------------------------------------------------------
| RELATIONS
|--------------------------------------------------------------------------
*/

/*
|--------------------------------------------------------------------------
| SCOPES
|--------------------------------------------------------------------------
*/

/*
|--------------------------------------------------------------------------
| ACCESORS
|--------------------------------------------------------------------------
*/

/*
|--------------------------------------------------------------------------
| MUTATORS
|--------------------------------------------------------------------------
*/
}


File Route: RoutesbackpackCustom



    // --------------------------
// Custom Backpack Routes
// --------------------------
// This route file is loaded automatically by BackpackBase.
// Routes you generate using BackpackGenerators will be placed here.

Route::group([
'prefix' => config('backpack.base.route_prefix', 'admin'),
'middleware' => ['web', config('backpack.base.middleware_key', 'admin')],
'namespace' => 'AppHttpControllersAdmin',
], function () { // custom admin routes
}); // this should be the absolute last line of this file


Route::group(
[
'namespace' => 'AppHttpControllersAuth',
'middleware' => ['web', config('backpack.base.middleware_key', 'admin')],
'prefix' => config('backpack.base.route_prefix'),
],
function () {
// if not otherwise configured, setup the auth routes
if (config('backpack.base.setup_auth_routes')) {
// Authentication Routes...

}

// if not otherwise configured, setup the dashboard routes
if (config('backpack.base.setup_dashboard_routes')) {
Route::get('dashboard', 'AdminController@dashboard')->name('backpack.dashboard');
Route::get('/', 'AdminController@redirect')->name('backpack');
}

// if not otherwise configured, setup the "my account" routes
if (config('backpack.base.setup_my_account_routes')) {
Route::get('edit-account-profile', 'MyAccountController@getAccountProfileForm')->name('backpack.account.profile');
Route::post('edit-account-profile', 'MyAccountController@postAccountProfileForm');
}
});


File Blade: resourcesviewsvendorbackpackbaseauthaccountupdate_profile.blade.php



    @extends('backpack::layout')

@section('after_styles')
<style media="screen">
.backpack-profile-form .required::after {
content: ' *';
color: red;
}
</style>
@endsection

@section('header')
<section class="content-header">

<h1>
{{ trans('backpack::base.my_account') }}
</h1>

<ol class="breadcrumb">

<li>
<a href="{{ backpack_url() }}">{{ config('backpack.base.project_name') }}</a>
</li>

<li>
<a href="{{ route('backpack.account.info') }}">{{ trans('backpack::base.my_account') }}</a>
</li>

<li class="active">
{{ trans('backpack::base.update_account_info') }} Profile
</li>

</ol>

</section>
@endsection

@section('content')
<div class="row">
<div class="col-md-3">
@include('backpack::auth.account.sidemenu')
</div>
<div class="col-md-6">


<div class="box">
<div class="box-body backpack-profile-form">
{!! Form::open(array('route' => 'backpack.account.profile', 'method' => 'post')) !!}
<div class="form-group">
@php
$label = 'Nome';
$field = 'nome';
@endphp
{!! Form::label($field, $label, ['class' => 'required']) !!}
{!! Form::text($field, old($field) ? old($field) : $profile->$field, ['class' => 'form-control', 'required']) !!}
</div>
<div class="clearfix"></div>
<div class="form-group">
@php
$label = 'Cognome';
$field = 'cognome';
@endphp
{!! Form::label($field, $label, ['class' => 'required']) !!}
{!! Form::text($field, old($field) ? old($field) : $profile->$field, ['class' => 'form-control', 'required']) !!}
</div>
<div class="clearfix"></div>
<div class="form-group">
@php
$label = 'Sex';
$field = 'sesso';
@endphp
{!! Form::label($field, $label, ['class' => 'required']) !!}
{!! Form::select($field, array('M' => 'Male', 'F' => 'Female'), old($field) ? old($field) : $profile->$field, ['class' => 'form-control', 'required']) !!}
</div>
<div class="clearfix"></div>
<div class="box-footer">
@php
$field = 'id';
$label = '<span class="ladda-label"><i class="fa fa-save"></i>'.trans('backpack::base.save').'</span>';
@endphp
{!! Form::hidden($field, old($field) ? old($field) : $profile->$field) !!}
{!! Form::button($label, ['class' => 'btn btn-success', 'type' => 'submit']) !!}
<a href="{{ backpack_url() }}" class="btn btn-default"><span class="ladda-label">{{ trans('backpack::base.cancel') }}</span></a>
</div>
{!! Form::close() !!}
</div>
</div>


</div>
</div>
@endsection


What I expected to happen:



I expect that the form is validated



What happened:



when I submit, the request returns to me empty



What I've already tried to fix it:



Backpack, Laravel, PHP, DB version:



Laravel Framework 5.7.12
"php": "^7.1.3"
"backpack/backupmanager": "^1.4"
"backpack/crud": "^3.4"
"backpack/langfilemanager": "^1.0"
"backpack/logmanager": "^2.3"
"backpack/newscrud": "^2.1"
"backpack/pagemanager": "^1.1"
"backpack/permissionmanager": "^3.12"
"backpack/settings": "^2.1"
"barryvdh/laravel-elfinder": "^0.4.1"
"fideloper/proxy": "^4.0"
"laravel/framework": "5.7.*",
"laravel/tinker": "^1.0",
"laravelcollective/html": "^5.7",
"mews/purifier": "^2.1",
"tymon/jwt-auth": "^0.5.12"










share|improve this question














I thought about adding a page, to change the profile of a user: name, surname, etc.



Bug report



File: MyAccountController.php



function: public function postAccountProfileForm(UpdateRequest $request)
the FormRequest, returns empty



What I did:



DB:
users->Profiles



File Controller: AppHttpControllersAuthMyAccountController



    namespace AppHttpControllersAuth;

use BackpackBaseappHttpControllersAuthMyAccountController as BaseMyAccountController;
use AppHttpRequestsAuthAccount_profileRequest as StoreRequest;
use AppHttpRequestsAuthAccount_profileRequest as UpdateRequest;
use Auth;
use AppModelsAuthAccount_profile;

class MyAccountController extends BaseMyAccountController
{
/**
* Show the user a form to change his personal information.
*/
public function getAccountProfileForm()
{
$user = Auth::user();
$this->data['title'] = trans('backpack::base.my_account');
$this->data['profile'] = Account_profile::getAccount_profilebyId($user->id);

return view('backpack::auth.account.update_profile', $this->data);
}

/**
* Save the modified personal information for a user.
*/
public function postAccountProfileForm(UpdateRequest $request)
{
//var_dump($request);
//die();
//$result = $this->guard()->user()->update($request->except(['_token']));
$result = Account_profile::getAccount_profilebyId($this->guard()->user()['id'])->update($request->except(['_token']));

if ($result) {
Alert::success(trans('backpack::base.account_updated'))->flash();
} else {
Alert::error(trans('backpack::base.error_saving'))->flash();
}

return redirect()->back();
}
}


File Request: AppHttpRequestsAuthAccount_profileRequest



    namespace AppHttpRequestsAuth;
use AppHttpRequestsRequest;
use IlluminateFoundationHttpFormRequest;

class Account_profileRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
// only allow updates if the user is logged in
return backpack_auth()->check();
}

/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
// 'name' => 'required|min:5|max:255'
'nome' => 'required|min:5|max:45',
'cognome' => 'required|min:5|max:45',
'sesso' => 'required|min:5|max:45',
'countrys_id' => 'required|numeric',
'regions_id' => 'required|numeric',
//'provinces_id' => 'required|numeric',
//'citys_id' => 'required|numeric',
'users_id' => 'required|numeric',
//'attivo' => 'required|boolean',
//'accetto_condizionigenerali' => 'required|boolean',
//'accetto_marketing' => 'required|boolean',
//'attivo_notifiche' => 'required|boolean'
//continue_13
];
}

/**
* Get the validation attributes that apply to the request.
*
* @return array
*/
public function attributes()
{
return [
//
];
}

/**
* Get the validation messages that apply to the request.
*
* @return array
*/
public function messages()
{
return [
//
];
}
}


File Models: AppModelsAuthAccount_profile



    namespace AppModelsAuth;

use IlluminateDatabaseEloquentModel;
use BackpackCRUDCrudTrait;

use AppModelsProfile;

class Account_profile extends Model
{
use CrudTrait;

/*
|--------------------------------------------------------------------------
| GLOBAL VARIABLES
|--------------------------------------------------------------------------
*/

/*
|--------------------------------------------------------------------------
| FUNCTIONS
|--------------------------------------------------------------------------
*/
public static function getAccount_profilebyId($id)
{
return Profile::find($id);
}

/*
|--------------------------------------------------------------------------
| RELATIONS
|--------------------------------------------------------------------------
*/

/*
|--------------------------------------------------------------------------
| SCOPES
|--------------------------------------------------------------------------
*/

/*
|--------------------------------------------------------------------------
| ACCESORS
|--------------------------------------------------------------------------
*/

/*
|--------------------------------------------------------------------------
| MUTATORS
|--------------------------------------------------------------------------
*/
}


File Route: RoutesbackpackCustom



    // --------------------------
// Custom Backpack Routes
// --------------------------
// This route file is loaded automatically by BackpackBase.
// Routes you generate using BackpackGenerators will be placed here.

Route::group([
'prefix' => config('backpack.base.route_prefix', 'admin'),
'middleware' => ['web', config('backpack.base.middleware_key', 'admin')],
'namespace' => 'AppHttpControllersAdmin',
], function () { // custom admin routes
}); // this should be the absolute last line of this file


Route::group(
[
'namespace' => 'AppHttpControllersAuth',
'middleware' => ['web', config('backpack.base.middleware_key', 'admin')],
'prefix' => config('backpack.base.route_prefix'),
],
function () {
// if not otherwise configured, setup the auth routes
if (config('backpack.base.setup_auth_routes')) {
// Authentication Routes...

}

// if not otherwise configured, setup the dashboard routes
if (config('backpack.base.setup_dashboard_routes')) {
Route::get('dashboard', 'AdminController@dashboard')->name('backpack.dashboard');
Route::get('/', 'AdminController@redirect')->name('backpack');
}

// if not otherwise configured, setup the "my account" routes
if (config('backpack.base.setup_my_account_routes')) {
Route::get('edit-account-profile', 'MyAccountController@getAccountProfileForm')->name('backpack.account.profile');
Route::post('edit-account-profile', 'MyAccountController@postAccountProfileForm');
}
});


File Blade: resourcesviewsvendorbackpackbaseauthaccountupdate_profile.blade.php



    @extends('backpack::layout')

@section('after_styles')
<style media="screen">
.backpack-profile-form .required::after {
content: ' *';
color: red;
}
</style>
@endsection

@section('header')
<section class="content-header">

<h1>
{{ trans('backpack::base.my_account') }}
</h1>

<ol class="breadcrumb">

<li>
<a href="{{ backpack_url() }}">{{ config('backpack.base.project_name') }}</a>
</li>

<li>
<a href="{{ route('backpack.account.info') }}">{{ trans('backpack::base.my_account') }}</a>
</li>

<li class="active">
{{ trans('backpack::base.update_account_info') }} Profile
</li>

</ol>

</section>
@endsection

@section('content')
<div class="row">
<div class="col-md-3">
@include('backpack::auth.account.sidemenu')
</div>
<div class="col-md-6">


<div class="box">
<div class="box-body backpack-profile-form">
{!! Form::open(array('route' => 'backpack.account.profile', 'method' => 'post')) !!}
<div class="form-group">
@php
$label = 'Nome';
$field = 'nome';
@endphp
{!! Form::label($field, $label, ['class' => 'required']) !!}
{!! Form::text($field, old($field) ? old($field) : $profile->$field, ['class' => 'form-control', 'required']) !!}
</div>
<div class="clearfix"></div>
<div class="form-group">
@php
$label = 'Cognome';
$field = 'cognome';
@endphp
{!! Form::label($field, $label, ['class' => 'required']) !!}
{!! Form::text($field, old($field) ? old($field) : $profile->$field, ['class' => 'form-control', 'required']) !!}
</div>
<div class="clearfix"></div>
<div class="form-group">
@php
$label = 'Sex';
$field = 'sesso';
@endphp
{!! Form::label($field, $label, ['class' => 'required']) !!}
{!! Form::select($field, array('M' => 'Male', 'F' => 'Female'), old($field) ? old($field) : $profile->$field, ['class' => 'form-control', 'required']) !!}
</div>
<div class="clearfix"></div>
<div class="box-footer">
@php
$field = 'id';
$label = '<span class="ladda-label"><i class="fa fa-save"></i>'.trans('backpack::base.save').'</span>';
@endphp
{!! Form::hidden($field, old($field) ? old($field) : $profile->$field) !!}
{!! Form::button($label, ['class' => 'btn btn-success', 'type' => 'submit']) !!}
<a href="{{ backpack_url() }}" class="btn btn-default"><span class="ladda-label">{{ trans('backpack::base.cancel') }}</span></a>
</div>
{!! Form::close() !!}
</div>
</div>


</div>
</div>
@endsection


What I expected to happen:



I expect that the form is validated



What happened:



when I submit, the request returns to me empty



What I've already tried to fix it:



Backpack, Laravel, PHP, DB version:



Laravel Framework 5.7.12
"php": "^7.1.3"
"backpack/backupmanager": "^1.4"
"backpack/crud": "^3.4"
"backpack/langfilemanager": "^1.0"
"backpack/logmanager": "^2.3"
"backpack/newscrud": "^2.1"
"backpack/pagemanager": "^1.1"
"backpack/permissionmanager": "^3.12"
"backpack/settings": "^2.1"
"barryvdh/laravel-elfinder": "^0.4.1"
"fideloper/proxy": "^4.0"
"laravel/framework": "5.7.*",
"laravel/tinker": "^1.0",
"laravelcollective/html": "^5.7",
"mews/purifier": "^2.1",
"tymon/jwt-auth": "^0.5.12"







php laravel backpack-for-laravel






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 21 '18 at 0:48









xdastyxdasty

12




12













  • If you found a bug, then reporting it to the developers should probably be the best option you have. According to their documentation, they usually handle bug reports on Backpack for Laravel's Github. If you have some time left then, you can also read Stackoverflow's "What topics can I ask about here?".

    – P. Ellul
    Nov 21 '18 at 9:39





















  • If you found a bug, then reporting it to the developers should probably be the best option you have. According to their documentation, they usually handle bug reports on Backpack for Laravel's Github. If you have some time left then, you can also read Stackoverflow's "What topics can I ask about here?".

    – P. Ellul
    Nov 21 '18 at 9:39



















If you found a bug, then reporting it to the developers should probably be the best option you have. According to their documentation, they usually handle bug reports on Backpack for Laravel's Github. If you have some time left then, you can also read Stackoverflow's "What topics can I ask about here?".

– P. Ellul
Nov 21 '18 at 9:39







If you found a bug, then reporting it to the developers should probably be the best option you have. According to their documentation, they usually handle bug reports on Backpack for Laravel's Github. If you have some time left then, you can also read Stackoverflow's "What topics can I ask about here?".

– P. Ellul
Nov 21 '18 at 9:39














0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53403781%2fadd-profile-information-in-myaccountcontroller-backpack-laravel%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53403781%2fadd-profile-information-in-myaccountcontroller-backpack-laravel%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

android studio warns about leanback feature tag usage required on manifest while using Unity exported app?

SQL update select statement

'app-layout' is not a known element: how to share Component with different Modules