1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2025-12-12 14:14:04 +00:00
tenancy/src/StorageDrivers/Database/Repository.php
Samuel Štancl 869ac32983
[2.2.0] [WIP] Add functionality (#206)
* TenantDatabaseDoesNotExistException

* Apply fixes from StyleCI

* User post-creation callbacks

* Rename method

* postCreationActions

* pass $tenant as parameter

* pass $tenant to async actions

* WIP findBy()

* findBy\* ForwardsCalls

* Apply fixes from StyleCI

* findBy DB storage driver

* Redis  SD TODO message

* Apply fixes from StyleCI

* Fix chained jobs

* WIP event system

* import str

* instanceof closure check

* findBy instead of find

* Tenant -> Tenants

* dots

* Use DB hooks instead of a SC key

* Don't allow  callables for queue chain

* CanDeleteKeys interface

* Apply fixes from StyleCI

* CanFindByAnyKey interface

* Apply fixes from StyleCI

* Ditch models for custom repositories

* Resolve circular dependency

* Apply fixes from StyleCI

* Fix tests

* Apply fixes from StyleCI

* FutureTest

* Prefix tenant events with 'tenant.'

* Event listener arguments test
2019-10-27 21:10:41 +01:00

41 lines
962 B
PHP

<?php
declare(strict_types=1);
namespace Stancl\Tenancy\StorageDrivers\Database;
use Illuminate\Config\Repository as ConfigRepository;
use Illuminate\Database\Connection;
use Illuminate\Database\Query\Builder;
/** @mixin Builder */
abstract class Repository
{
/** @var Connection */
public $database;
/** @var string */
protected $tableName;
/** @var Builder */
private $table;
public function __construct(ConfigRepository $config)
{
$this->database = DatabaseStorageDriver::getCentralConnection();
$this->tableName = $this->getTable($config);
$this->table = $this->database->table($this->tableName);
}
public function table()
{
return $this->table->newQuery()->from($this->tableName);
}
abstract public function getTable(ConfigRepository $config);
public function __call($method, $parameters)
{
return $this->table()->$method(...$parameters);
}
}