Call to undefined method Illuminate\Database\Query\Builder::usingModel()
Closed this issue · 8 comments
I am getting error
Call to undefined method Illuminate\Database\Query\Builder::usingModel()
when trying to use package, for example
$refunds = RefundsLog::scan();
Laravel v8.83.12
@andrewboohoo Thanks for the report! Can you share the code of RefundsLog
model? (especially, the parts that use Eloquent features such as casts
)
There may be some Eloquent features that this package not supported yet.
I am getting the same error using the following model just to try it out (dynamodb-local in docker)
'dynamodb' => [
'driver' => 'dynamodb',
'key' => env('AWS_ACCESS_KEY_ID'),
'secret' => env('AWS_SECRET_ACCESS_KEY'),
'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
'token' => env('AWS_SESSION_TOKEN', null),
'endpoint' => env('DYNAMODB_ENDPOINT', null),
'prefix' => 'someapp_' . config('app.env') . '_', // table prefix
],
<?php
namespace App\Models;
use Kitar\Dynamodb\Model\Model;
class DynamoUser extends Model
{
protected $table = 'users';
protected $primaryKey = 'email';
protected $fillable = ['email', 'name', 'password'];
}
I solved it by adding a protected $connection = 'dynamodb';
to my model
I finally understand! Thank you for reporting @umayanrmr @Jonnx
You have to set DB_CONNECTION=dynamodb
in the .env
file. If you do so, you don't need to override protected $connection
. This is not in the document, so I'll add it soon.
I'll close this issue at this time. Please feel free to re-open if needed.
I finally understand! Thank you for reporting @umayanrmr @Jonnx
You have to set
DB_CONNECTION=dynamodb
in the.env
file. If you do so, you don't need to overrideprotected $connection
. This is not in the document, so I'll add it soon.
What if I want to use both MySQL and DynamoDB in my application?
@gvanto
I believe you can manage it in the same way you would handle multiple MySQL databases.
https://fideloper.com/laravel-multiple-database-connections