1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2025-12-12 15:34:03 +00:00

Fix #7 - tenant assets

This commit is contained in:
Samuel Štancl 2019-01-20 14:52:14 +01:00
parent 25bc3f81b3
commit 3a6ceed992
4 changed files with 38 additions and 1 deletions

View 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);
}
}
}

View file

@ -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');
} }
/** /**

View file

@ -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
View file

@ -0,0 +1,5 @@
<?php
Route::get('/tenancy/assets/{path}', 'Stancl\Tenancy\Controllers\TenantAssetController@asset')
->where('path', '(.*)')
->name('stancl.tenancy.asset');