Iam usin mysql 5.7,laravel5.2 and php 5.6.17 in my application..
I created a migration table
public function up()
{
Schema::create('admin_login_history', function (Blueprint $table) {
$table->increments('id');
$table->string('url');
$table->json('client_details');
$table->integer('user_id')->nullable();
$table->timestamps();
});
}
I created a model for it..
class AdminLoginHistory extends Model
{
protected $table = 'admin_login_history';
protected $fillable = ['file_path', 'url', 'user_id', 'client_details'];
protected $casts = ['client_details' => 'json'];
}
Iam inserting a array of data of client_details which is converted to json in my model.
now when retrieving the data from the table iam getting error
$loginhistory = AdminLoginHistory::where('user_id', $id)->orderBy('created_at', 'desc')->take(3)->get();
Error:
File Path: /home/storage/elivio/InvizoAdmin/vendor/laravel/framework/src/Illuminate/Database/Connection.php
Error Code:HY000, Line Number:669
Message:SQLSTATE[HY000]: General error: 2036 (SQL: select * from `admin_login_history` where `user_id` = 1 order by `created_at` desc limit 3)