【发布时间】:2019-04-03 17:11:09
【问题描述】:
【问题讨论】:
-
我们需要更多解释。
-
如何创建 laravel storage:link 自定义路径?我想点project/public/storage >> project/storage/app/tenancy/tenants
标签: laravel multi-tenant laravel-5.6
【问题讨论】:
标签: laravel multi-tenant laravel-5.6
我在这里遇到了同样的问题,这是我使用 Hyn 5.4 的解决方案,您可以像这样检索当前租户:
https://laravel-tenancy.com/docs/hyn/5.4/identification#retrieve-current-tenant
// Get current Website (Tenant)
$website = \Hyn\Tenancy\Facades\TenancyFacade::website();
// prefered option
$website = app(\Hyn\Tenancy\Environment::class)->tenant();
// alternative (outdated)
$website = app(\Hyn\Tenancy\Environment::class)->website();
$websiteId = $website->id;
// Get current Hostname
$hostname = app(\Hyn\Tenancy\Environment::class)->hostname();
// Get FQDN (Fully-Qualified Domain Name) by current hostname
$fqdn = $hostname->fqdn;
您可以通过创建将链接到
租户媒体
https://laravel-tenancy.com/docs/hyn/5.4/structure#media
Route::get('/media/{path}', '\Hyn\Tenancy\Controllers\MediaController')
->where('path', '.+')
->name('tenant.media');
【讨论】:
如果您想创建自定义存储磁盘,您可以在config/filesystems.php 中添加,在disk 下输入此代码。
'tenancy' => [
'driver' => 'local',
'root' => storage_path('app/tenancy'),
],
所以你可以使用Storage::disk('tenancy')访问它
例如
Storage::disk('tenancy')->get('tenants/64121.../images');
【讨论】: