How to Map GridDB Data Types to Laravel Eloquent Models When Using the GridDB PHP Client?

I’m building a Laravel application where I need to store and retrieve data from GridDB. I’ve successfully established a connection to GridDB and can perform basic operations like creating containers and inserting data.

However, I’m facing challenges with mapping GridDB data types to Eloquent model attributes.

What I’ve Done:

  • I have a container in GridDB with the following schema:

    id (INTEGER)

    sensor_id (STRING)

    value (DOUBLE)

    timestamp (TIMESTAMP)

  • Laravel Eloquent Model:

<?php



namespace AppModels;



use IlluminateDatabaseEloquentModel;



class SensorData extends Model
{
protected $table = 'sensor_data';
protected $primaryKey = 'id';
public $incrementing = false;
public $timestamps = false;



protected $fillable = [
'id',
'sensor_id',
'value',
'timestamp',
];



protected $casts = [
'id' => 'integer',
'sensor_id' => 'string',
'value' => 'double',
'timestamp' => 'datetime',
];
}
  • Data Retrieval:
$data = SensorData::where('sensor_id', 'sensor_001')
->whereBetween('timestamp', [$startDate, $endDate])
->get();

and for this i get:

Undefined Table or Column:
Base table or view not found: 1146 Table 'mydatabase.sensor_data' doesn't exist

If I try to fetch data directly using the GridDB PHP client and map it to the model, I get errors related to data type mismatches, especially with the timestamp field.

How can I correctly map GridDB data types to Laravel Eloquent model attributes?