mardi 6 février 2018

Override created_at value

I'm trying to insert date into created at but nothing worked

I tried to use create as normal

$this->create([ 'product_id' => "$id", 'shop_name' => $shop,'created_at' => $date ]);

I tried to change the date format to match laravel

$date = date('Y-m-d H:i:s',strtotime($id['created_at']));

I also tried to user mutators to change the value each time

public function setFirstNameAttribute($value)
{
    $this->attributes['created_at'] = $value;
}

How can I set specific date in created_at rather then the deafult date ?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire