In Laravel-8 application, I am tring to use this function:
public static function addToLog($subject, $logType=null, $subjectHint=null)
{
$log = [];
$log['subject'] = $subject;
$log['log_type'] = $logType;
$log['subject_hint'] = $subjectHint;
$log['log_url'] = Request::fullUrl();
$log['log_method'] = Request::method();
$log['ip_address'] = Request::ip();
$log['agent'] = Request::header('user-agent');
$log['user_id'] = auth()->check() ? auth()->user()->id : 1;
LogActivityModel::create($log);
}
But I got this error:
[2021-05-19 13:25:55] local.ERROR: PDOException: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'ip_address' in 'field list' in C:\xampp\htdocs\myapp\vendor\laravel\framework\src\Illuminate\Database\Connection.php:465
But ip_address column exists.
Here is my migration:
public function up()
{
Schema::create('user_log_activities', function (Blueprint $table) {
$table->bigIncrements('id');
$table->bigInteger('user_id')->nullable()->unsigned();
$table->string('log_url', 300)->nullable();
$table->string('log_method', 20)->nullable();
$table->string('log_type', 50)->nullable();
$table->string('subject', 200)->nullable();
$table->string('subject_hint', 20)->nullable();
$table->string('id_address', 64)->nullable();
$table->string('agent', 300)->nullable();
$table->timestamps();
});
}
How do I get it resolve?
Thanks