In my Laravel 5.8 / mysql 5.7.28 under Kununtu 18 I have a problem that adding new row created_at field is filled with -3 hours difference. In my control :
public function add_hostel_enquery()
{
$request = request();
$requestData = $request->all();
$newHostelInquery = new HostelInquery();
$newHostelInquery->creator_id = ! empty($requestData['creator_id']) ? $requestData['creator_id'] : '';
$newHostelInquery->hostel_id = ! empty($requestData['hostel_id']) ? $requestData['hostel_id'] : '';
$newHostelInquery->full_name = ! empty($requestData['full_name']) ? $requestData['full_name'] : '';
$newHostelInquery->email = ! empty($requestData['email']) ? $requestData['email'] : '';
$newHostelInquery->phone = ! empty($requestData['phone']) ? $requestData['phone'] : '';
$newHostelInquery->info = ! empty($requestData['info']) ? $requestData['info'] : '';
$newHostelInquery->start_date = ! empty($requestData['start_date']) ? $requestData['start_date'] : '';
$newHostelInquery->end_date = ! empty($requestData['end_date']) ? $requestData['end_date'] : '';
$newHostelInquery->request_callback = !empty($requestData['request_callback']) ? "Y" : 'N';
try {
DB::beginTransaction();
$newHostelInquery->save();
DB::commit();
...
In config/app.php :
'timezone' => 'Europe/Kiev',
and in my OS I have the same timezone .
Database is created as :
Schema::create('hostel_inqueries', function(Blueprint $table)
{
$table->increments('id');
...
$table->timestamp('created_at')->useCurrent();
$table->timestamp('updated_at')->nullable();
...
});
I know Updating row I fix it issue with code:
$hostelInquery->updated_at = Carbon::now(config('app.timezone'));
$hostelInquery->save();
How to make created_at filled on insert ?
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2WiRNtx
via IFTTT
Aucun commentaire:
Enregistrer un commentaire