Does Not Work
kornatzky opened this issue · 3 comments
Laravel 10
use App\RedisModels\Bid;
$bid = new Bid;
$bid->created_at = now();
$bid->updated_at = now();
$bid->auction_id = 302;
$bid->item_id = 23;
$bid->price = 789.56;
$bid->user_id = 76;
$bid->type = 'user';
$bid->save()
get this error:
DEPRECATED Return type of Alvin0\RedisModel\Model::jsonSerialize() should either be compatible with JsonSerializable::jsonSerialize(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in vendor/alvin0/redis-model/src/Model.php on line 955.
Predis\ClientException Command `SETOPTION` is not a registered Redis command.
Predis\ClientException
Command SETOPTION
is not a registered Redis command.
at vendor/predis/predis/src/Command/Factory.php:67
63▕ {
64▕ if (!$commandClass = $this->getCommandClass($commandID)) {
65▕ $commandID = strtoupper($commandID);
66▕
➜ 67▕ throw new ClientException("Command $commandID
is not a registered Redis command.");
68▕ }
69▕
70▕ $command = new $commandClass();
71▕ $command->setArguments($arguments);
+5 vendor frames
6 app/Console/Commands/TestRedisModel.php:32
Alvin0\RedisModel\Model::__construct()
+12 vendor frames
19 artisan:35
Illuminate\Foundation\Console\Kernel::handle()
First of all, I would like to thank you very much for using my package.
I think there are some errors in your model's setup.
You can refer to the following example:
file app\RedisModels\Bid.php
<?php
namespace App\RedisModels;
use Alvin0\RedisModel\Model;
class Bid extends Model
{
/**
* The primary key for the model.
*
* @var string
*/
protected $primaryKey = 'item_id';
/**
* The model's sub keys for the model.
*
* @var array
*/
protected $subKeys = [];
/**
* The attributes that should be cast.
*
* @var array
*/
protected $casts = [];
/**
* The attributes that are mass assignable.
*
* @var array<string>
*/
protected $fillable = [
'auction_id',
'item_id',
'price',
'user_id',
'type',
];
}
Controller
use App\RedisModels\Bid;
$bid = new Bid;
$bid->created_at = now();
$bid->updated_at = now();
$bid->auction_id = 302;
$bid->item_id = 23;
$bid->price = 789.56;
$bid->user_id = 76;
$bid->type = 'user';
$bid->save();
Thanks for the attention. I discovered the following. First, I moved to working with phpredis instead of predis.
Second, I fixed the model per your suggestion. And it works.
Thank for this wonderful package!
I want to tweet about it soon. It should be more well known.