Mahdi.Pishguy Mahdi.Pishguy - 7 months ago 16
PHP Question

Laravel both of created_at and updated_at update to same value in update action

in laravel after update existing data with other database's column information both of

created_at
and
updated_at
are updating to same value.

My Form:

{!! Form::model($user_data,array('url' => array('manageUsers', $user_data->id), 'files' => true,'method' => 'PUT', 'class'=>'validate','id'=>'xfrm_submit')) !!}
{!! Form::hidden('id',$user_data->id) !!}
<div class="form-group">
{!! Form::label( 'acceptor_name','Acceptor Name:' ) !!}
<span style="color:#ff0000;padding: 0 2px 2px 0">*</span>
<input id="acceptor_name"
name="acceptor_name"
type="text"
value="{{$user_data->acceptor_name}}">
</div>
</form>


My Controller
update
action :

public function update(StoreUserManagment $request)
{
$user_data = User::find($request->input('id'));
$user_data->acceptor_name =$request->input('acceptor_name');
$user_data->save();
return redirect('manageUsers');

}


Migration file:

public function up()
{
Schema::create('users', function (Blueprint $table) {
$table->increments('id');
$table->string('name', '20');
$table->string('family', '25');
$table->string('username', '15')->unique();
$table->string('password', '64');
$table->string('token', '50');
$table->string('email', '20')->unique();
$table->string('remember_token', '100');
$table->string('image_file_name', '50');
$table->string('mobile_number', '13');
$table->tinyInteger('status');
$table->text('account_state_note');
$table->timestamps();
});
}

Answer

That's an issue https://github.com/laravel/framework/issues/11518

I solved this using ->nullableTimestamps() instead of ->timestamps()

You can try this,may be it will work

Comments