Stancl/Tenancy Filament 3
hi i have setup Stancl/Tenancy and its working fine , but i cant get filament to work on tenants subdomain
it does load part of the page in the bg but then i get this error
138 Replies
added this
obviously is trying to access the central domains users db
am i missing something thanks
Which one is your central domain and which one the subdomain?
localhost is my central
apex.localhost is my sub
i don't have an users table in my central migrations
when registering a tenant i create an user inside tenants db
so from what i can tell is looking for the users table in the central domain db
instead of the tenants db
@Dennis Koch ?
anyone ?
seems to work for some part
So only the dashboard is an issue? Weird.
well not really , when i click create on anything its pops same error
i have nailed it
v2 docs say
stancl/tenancy
To set up stancl/tenancy to work with Filament, you just need to add the InitializeTenancyByDomain::class middleware to Livewire and the Filament config file:
use Stancl\Tenancy\Middleware\InitializeTenancyByDomain;
'middleware' => [
// ...
'base' => [
// ...
InitializeTenancyByDomain::class
],
],
In Livewire 3, the configuration key middleware_group has been removed, so instead add the following in TenancyServiceProvider (or any other provider):
Solution
@Dennis Koch i now have the same issue when using the fileupload
any idea how to fix this
Since it’s a Livewire request that should be handled by the Livewire middleware you already set up 🤔
That’s what I thinking
But that’s for the livewire/update
I tried /livewire only but still same
any idea
Nope. Sorry.
k
@Dennis Kochnailed it
the issue i have now is this
as you can see its trying to fetch the image from the wrong path
How can I modify the url
@Dan Harrin any idea
#✅┊rules
K
Thought you could help sorry for tagging
would really appreciate any help on this
at this point, it's probably a livewire-stancl issue rather than anything to do with Filament.
You probably are right I tend to think more of livewire
Because setting the stancl middleware for the temp dir in livewire cgf sorted the issue with the upload
But there is no setting for anything else
Did you check if the Filesystem tenancy bootstrapper is setted?
https://tenancyforlaravel.com/docs/v3/tenancy-bootstrappers/
Tenancy for Laravel
Tenancy bootstrappers | Tenancy for Laravel
Tenancy bootstrappers | Tenancy for Laravel
in the same file I put this too:
'middleware_group' => [
'web',
'universal',
InitializeTenancyBySubdomain::class,
],
like additional to the actual middleware ?
i haven't checked this yet
Filesystem tenancy bootstrapper is set
I don’t know what’s the best way with the current version. With the alpha there is a command to symlink the tenants public folders as
public-1
etc.
This is what you need and also you need to adjust the URLs for the new public symlinks. I think that was more work in the current version that’s why I sponsored for the alphaI found this post with pretty much the exact same issues https://discord.com/channels/883083792112300104/1140292180745924618
I wonder if anyone there got this working
Everything else works fine
How is this related? The other post is about assets, your issue is the public storage folder.
well its the same maybe its worded wrong by me
on the tenant app i get the assets using tenant_asset()
i need a way to do that for filament now
@Dennis Koch
i have Disabled tenant asset helper: 'config.tenancy.filesystem.asset_helper_tenancy' => false,
Your assets seem to load fine? Otherwise CSS and JS wouldn't work, right?
i have done all the steps you laid out here https://discord.com/channels/883083792112300104/1140292180745924618/1142012944750759936
for any assets i use tenant_asset()
Can you shortly explain again what your current issue is? What part it not working?
so after using the image upload in filament
file gets uploaded fine in its tenant dir
Okay, so it's about public storage as I thought. Not about assets
i get that file like this
fine
I think you need this + manually symlinking public folders.
https://tenancyforlaravel.com/docs/v3/tenancy-bootstrappers/#storage-facade
Tenancy for Laravel
Tenancy bootstrappers | Tenancy for Laravel
Tenancy bootstrappers | Tenancy for Laravel
asset()
is not meant for accessing storage.only issue in filament its that the image its not being resolved properly
it should be vas.localhost/
Yes, I understand. It's pointing to
storage/
which is the central domain.
it should be vas.localhost/No, that wouldn't help as
public/storage
is a symlink to storage/app/public
, also the subdomains would link there.
Did you check the link to the docs I sent?yea i went over that all day yesterday i done it
i have this
Can you show the
root_override
part of config/tenancy.php
?
And the code for your ImageColumnYou should specify the disk.
->disk('public')
is probably what you want. Or are the files private?they are not private
same , i think public is the default
Exactly same URL?
What does
Storage::disk('public')->url('test')
return inside Filament?same url yest
i done a dump in the Resource file , is that what you meant ?
No, resource file is run before middelware.
You could output it as a column via
getStateUsing()
Hm, I don't know. Is this returning something different? You can run this from anywhere
So it's not Filament related. Something with your setup is wrong. You have the StorageBootstrapper enabled? Check the config for the bootstrappers, please.
if i do this
it changes the path
Sure, but that should work out of the box.
Can you share the
bootstrappers
of your config/tenancy.php
?sure
Hm.
FilesystemTenancyBootstrapper
should do this.
I am out of ideas. this is false
if i put it true it breaks all the css/js in filament
no worries man i really appreacite taking the time
thank you , ill leave it to that im out of ideas too
Yes that's correct. Again: asset_helper is unrelated to Storage.
well
@Dennis Koch
can i do this for the form ?
I don't think so, as it uses the Storage facade
Hello. Anyone solve the img preview issue with Stancl Tenancy.
yeah, theres a config option to disable that behaviour
i think
Hi Dan, is this you mean. I checked asset_helper_tenancy true and false both. but still not working.
I tried this,
Tables\Columns\ImageColumn::make('logo')
->label('Logo')
->url(function (Team $record) {
$url = Storage::disk('public')->url($record->logo);
return Storage::disk('public')->url($record->logo);
}),
$fullPath = Storage::disk('public')->path($record->logo);
"D:\xxx\xxx\xxx\xxx\sass\storage/tenant3cea6d60-2b75-451d-af4b-92cd9ed9fc10/app/public\01HP7G59C3DHAFHVXREZ75W03Y.webp" $url = Storage::disk('public')->url($record->logo); "http://sass.test/storage/01HP7G59C3DHAFHVXREZ75W03Y.webp"
"D:\xxx\xxx\xxx\xxx\sass\storage/tenant3cea6d60-2b75-451d-af4b-92cd9ed9fc10/app/public\01HP7G59C3DHAFHVXREZ75W03Y.webp" $url = Storage::disk('public')->url($record->logo); "http://sass.test/storage/01HP7G59C3DHAFHVXREZ75W03Y.webp"
did you figure this out? 🙂 im having the same issue
no buddy can't find any help on this anywhere
what would that be ?
We had to use
SpatieMediaLibraryFileUpload
to override the url generation as FileUpload
does not provide an API for that.
In the media-library
config file
Then
Had Issue with this part, and stopped using it.ok thanks man , let me have a look at that much appreciated
Are you using FileUpload or SpatieMediaLibraryFileUpload?
fileupload
the image uploads fine , its just getting the preview is not working
and that in turn doesn't let me to change the image
as its trying to fetch the image from central domain instead of tenant
could not find a way to change this behaviour
Yeah I had the same issue.
Stop using the temporary_file_upload override
and You would need to Override the FileUpload File using Composer (Which I dont Recommand) Thats why I switched to Spatie
i will give spatie a go thank you
Stop using the temporary_file_upload override <= meant the livewire config edit
'middleware' => \Stancl\Tenancy\Middleware\InitializeTenancyByDomainOrSubdomain::class, // Example: 'throttle:5,1' | Default: 'throttle:60,1' ?
this one ?
Yes
return the middleware to null,
and use spatie i assume otherwise it throws an error
Yeah
cool
let me get spatie installed
is this a service TenantAwareUrlGenerator
?
this is what i got
Check the TenancyServiceProvider
and check whether the storage/tenant-name/framework/cache folder is there
did you install the filament plugin https://filamentphp.com/plugins/filament-spatie-media-library ? or spatie/laravel-medialibrary
Filament
Spatie Media Library by Filament - Filament
Filament support for Spatie's Laravel Media Library package.
Filament
Spatie Media Library by Filament - Filament
Filament support for Spatie's Laravel Media Library package.
these is mine
this is yours
if you are not using Spatie Permissions or Filament Shield you could ignore that
Check this
ok
im doing that already
Here is my tenancy config file
Any Luck?
what i didn't have is Stancl\Tenancy\Features\CrossDomainRedirect::class, // https://tenancyforlaravel.com/docs/v3/features/cross-domain-redirect
Tenancy for Laravel
Cross-domain redirect | Tenancy for Laravel
Cross-domain redirect | Tenancy for Laravel
but still getting the same , i might need to install telescope see what is giving me that 500 error
try reverting back the livewire middleware setting
what will happen?
is uploading the file now but is giving still 500 err
which is better at least is using the right domain
after save?
yea
could you check the storage folder , for the file
before save
let me do a migrate fresh and resigser a fresh tenant
its a mess in here
and the error for this image?
if i go on the image link directly
i get http://apex.localhost/tenancy/assets/1/01HVCWDBSF1JF4JHCZMV90Y84V.png
ups
Tenant could not be identified on domain apex.localhost
Which middleware are you using in the panel?
looking at this is trying to use domain only
InitializeTenancyByDomainOrSubdomain::class, in the panel
try using InitializeTenancyByDomain::class,
PreventAccessFromCentralDomains::class,
nah , got it
had to stick this in
public function boot() in tenancy provider
Yeah I noticed that the error is using the InitializeTenancyByDomain
did everything work now?
haha seems so thanks a lot i owe you big time 🙂
just in the blade how do you retrieve the image
do you use tenant_asset ?
oh nvm i see it makes a link
very nice
I didnt need it in my case, but yes. You should. You could also use Spatie in the blade
how if you dont mind ?
If you are using Livewire component, using Forms in Livewire is simple and easy
yea im using that
just make a form and use it
ok , listen thanks a bunch i was losing hope on this 🙂
I had to suffer as well. couldnt find a good guide to support uploading files.
Good luck
thanks again man
best of luck to you too
Anytime
i ended up doing this for now
Curator doesn’t use spatie’s package for this exact reason. Just saying. 😅
I hope this is ok, but I wanted to cross reference another solution in another thread seemingly solved by @camya. He used a middleware and a modified CreateFrameworkDirectoriesForTenant::class job to solve it in a pretty solid way.
https://discord.com/channels/883083792112300104/1223843491386228796/1241067799485354054
Got uploads working now in Panels and in Custom Filament Forms (outside of panels).
Other than his notes I had to go back into the tenancy for laravel setup regarding Livewire to make some changes, but nothing not documented there or in @camya's post.
Thanks