This is explained here using the below model,controller files
EmpMaster.php
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
namespace App\Models; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\SoftDeletes; class EmpMaster extends Model { /** * The database table used by the model. * * @var string */ use SoftDeletes; protected $table = 'employee_master'; protected $primaryKey = 'EmpId'; /** * Attributes that should be mass-assignable. * * @var array */ protected $fillable = ['EmpId', 'created_at', 'updatedBy', 'updated_at', 'deletedBy', 'deleted_at']; /** * The attributes excluded from the model's JSON form. * * @var array */ protected $hidden = []; /** * The attributes that should be casted to native types. * * @var array */ protected $casts = []; /** * The attributes that should be mutated to dates. * * @var array */ protected $dates = ['created_at', 'updated_at','deleted_at']; /** |
Controller.php
1 2 3 |
$Idarray = array('EmpId'=>5621); $updateArray = array('deleted_at' => now(),'deletedBy' => 1); EmpMaster::DeleteRecords($updateArray,); |