mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-12 17:24:03 +00:00
Fix #7 - tenant assets
This commit is contained in:
parent
25bc3f81b3
commit
3a6ceed992
4 changed files with 38 additions and 1 deletions
23
src/Controllers/TenantAssetsController.php
Normal file
23
src/Controllers/TenantAssetsController.php
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Stancl\Tenancy\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Routing\Controller;
|
||||||
|
|
||||||
|
class TenantAssetController extends Controller
|
||||||
|
{
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->middleware('tenancy');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function asset($path)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
return response()->file(storage_path('app/public/' . $path));
|
||||||
|
} catch (\Throwable $th) {
|
||||||
|
dd(storage_path('app/public/' . $path));
|
||||||
|
abort(404);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -33,6 +33,8 @@ class TenancyServiceProvider extends ServiceProvider
|
||||||
$this->publishes([
|
$this->publishes([
|
||||||
__DIR__ . '/config/tenancy.php' => config_path('tenancy.php'),
|
__DIR__ . '/config/tenancy.php' => config_path('tenancy.php'),
|
||||||
], 'config');
|
], 'config');
|
||||||
|
|
||||||
|
$this->loadRoutesFrom(__DIR__ . '/routes.php');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -13,9 +13,16 @@ if (! function_exists('tenancy')) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!function_exists('tenant')) {
|
if (! function_exists('tenant')) {
|
||||||
function tenant($key = null)
|
function tenant($key = null)
|
||||||
{
|
{
|
||||||
return tenancy($key);
|
return tenancy($key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (! function_exists('tenant_asset')) {
|
||||||
|
function tenant_asset($asset)
|
||||||
|
{
|
||||||
|
return route('stancl.tenancy.asset', ['asset' => $asset]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
5
src/routes.php
Normal file
5
src/routes.php
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
Route::get('/tenancy/assets/{path}', 'Stancl\Tenancy\Controllers\TenantAssetController@asset')
|
||||||
|
->where('path', '(.*)')
|
||||||
|
->name('stancl.tenancy.asset');
|
||||||
Loading…
Add table
Add a link
Reference in a new issue