mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-12 22:34:03 +00:00
Merge branch 'master' into cache-prefix
This commit is contained in:
commit
ba8cfdda85
38 changed files with 631 additions and 362 deletions
16
tests/Etc/EarlyIdentification/AdditionalMiddleware.php
Normal file
16
tests/Etc/EarlyIdentification/AdditionalMiddleware.php
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
<?php
|
||||
|
||||
namespace Stancl\Tenancy\Tests\Etc\EarlyIdentification;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class AdditionalMiddleware
|
||||
{
|
||||
public function handle(Request $request, Closure $next): mixed
|
||||
{
|
||||
app()->instance('additionalMiddlewareRunsInTenantContext', tenancy()->initialized);
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
19
tests/Etc/EarlyIdentification/Controller.php
Normal file
19
tests/Etc/EarlyIdentification/Controller.php
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
|
||||
namespace Stancl\Tenancy\Tests\Etc\EarlyIdentification;
|
||||
|
||||
use Illuminate\Routing\Controller as BaseController;
|
||||
|
||||
class Controller extends BaseController
|
||||
{
|
||||
public function __construct(public Service $service)
|
||||
{
|
||||
app()->instance('controllerRunsInTenantContext', tenancy()->initialized);
|
||||
$this->middleware(AdditionalMiddleware::class);
|
||||
}
|
||||
|
||||
public function index(): string
|
||||
{
|
||||
return $this->service->token;
|
||||
}
|
||||
}
|
||||
15
tests/Etc/EarlyIdentification/Service.php
Normal file
15
tests/Etc/EarlyIdentification/Service.php
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Stancl\Tenancy\Tests\Etc\EarlyIdentification;
|
||||
|
||||
class Service
|
||||
{
|
||||
public string $token;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->token = config('tenancy.token');
|
||||
}
|
||||
}
|
||||
|
|
@ -30,7 +30,7 @@ class HttpKernel extends Kernel
|
|||
*/
|
||||
protected $middlewareGroups = [
|
||||
'web' => [
|
||||
\Orchestra\Testbench\Http\Middleware\EncryptCookies::class,
|
||||
\Illuminate\Cookie\Middleware\EncryptCookies::class,
|
||||
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
|
||||
\Illuminate\Session\Middleware\StartSession::class,
|
||||
// \Illuminate\Session\Middleware\AuthenticateSession::class,
|
||||
|
|
|
|||
|
|
@ -0,0 +1,35 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateSessionsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('sessions', function (Blueprint $table) {
|
||||
$table->string('id')->primary();
|
||||
$table->foreignId('user_id')->nullable()->index();
|
||||
$table->string('ip_address', 45)->nullable();
|
||||
$table->text('user_agent')->nullable();
|
||||
$table->text('payload');
|
||||
$table->integer('last_activity')->index();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('sessions');
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue