I have a table like it-
And model for it is like this-
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Http\Request;
class WebinarLiveAttenders extends Model
{
protected $table = 'webinar_live_attenders';
protected $primaryKey='id';
protected $fillable = array('webinar_id','ip','last_update');
public $timestamps=false;
public function webinars()
{
return $this->hasOne('App\Webinar');
}
}
I am running a query like this-
public function post_update_user_status()
{
//Request::getClientIp();
$requestData = Request::all();
$date = new DateTime;
$formatted_date = $date->format('Y-m-d H:i:s');
$user_status = WebinarLiveAttenders::firstOrNew([
'webinar_id' => $requestData['uuid'],
'ip' => Request::getClientIp()
]);
$user_status->last_update = $formatted_date;
$user_status->save();
return 'Done';
}
Problem is I am getting time_on=0 always.
But I want it to be the time of creation.
I can't use timestamps here.
Can anyone please help?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire