Get a problem with update using query builder on laravel 5. I've tried to disabled the updated_at but keep failing.
Here is my code:
$query = StockLog::where('stock_id', $id)->whereBetween('created_at', $from, $to])->update(['batch_id' => $max + 1]);
I've tried 2 ways: first one at my model i set:
public function setUpdatedAtAttribute($value)
{
/*do nothing*/
}
Second one:
$stocklog = new StockLog;
$stocklog->timestamps = false;
$query = $stocklog::where('stock_id', $id)->whereBetween('created_at', [$from, $to])->update([
'batch_id' => $max + 1]);
both of them are failed. is there anyway to disabled the updated_at?
Thanks in advance
$table->timestamps();
What you could do is set thispublic $timestamps = false;
in your model and ad the created_at manualy – Offstagepublic function up() { Schema::create('password_resets', function(Blueprint $table) { $table->string('email')->index(); $table->string('token')->index(); $table->timestamp('created_at'); }); }
This is how my password reset migration looks it does not have any updated_at field. Could you show your migration? – Offstage