Store the connection configuration into the instance to be able to access it from the eloquent model through $this->getConnection()->getConfig('<index>').
In my case, as I use a Single-Table design, I want to access the connection parameters since I pass the created DynamoDB table name to it from serverless.yml:
use Kitar\Dynamodb\Model\Model as BaseModel;
abstract class Model extends BaseModel implements Contracts\BaseModel {
final public function getTable(): string {
// get single-table designated table name
return $this->table ??= $this->getConnection()->getConfig('std_table');
}
}
Store the connection configuration into the instance to be able to access it from the eloquent model through
$this->getConnection()->getConfig('<index>')
.In my case, as I use a Single-Table design, I want to access the connection parameters since I pass the created DynamoDB table name to it from
serverless.yml
:serverless.yml
config/database.php
App\Models\Base\Model.php