I am using Laravel 5.1
.
There is a model in my project for a table named scores
as below:
<?php namespace App\Models;
use Illuminate\Database\Eloquent\SoftDeletes;
class Score extends BaseModel{
use SoftDeletes;
protected $dates = ['deleted_at'];
public $timestamps=true;
protected $table = 'scores';
protected $fillable = array('user_id','score','numerator','denominator','created_at','updated_at','deleted_at');
public function users() {
return $this->belongsTo('User');
}
}
I want to soft delete the records of this table. I am using eloquent as below:
$user_id = 10;
$created_at = date('Y-m-d', strtotime($created_at));
$ps = Score::where('user_id', '=', $user_id)
->whereRaw('DATE_FORMAT(created_at,"%Y-%m-%d") = ?',array($created_at))
->delete();
But the records are getting hard deleted each time. Where am I making a mistake?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire