Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

domain() works with only one domain. #128

Closed
winavin opened this issue Dec 17, 2023 · 5 comments
Closed

domain() works with only one domain. #128

winavin opened this issue Dec 17, 2023 · 5 comments
Assignees

Comments

@winavin
Copy link

winavin commented Dec 17, 2023

Folio Version

1.1.5

Laravel Version

10.37.3

PHP Version

8.1.4

Description

Folio::path(resource_path("views/pages/"));
Folio::domain('domain-one.test')->path(resource_path("views/pages/tenants/one"));
Folio::domain('domain-two.test')->path(resource_path("views/pages/tenants/two"));

First and 2nd line is working. but 2nd or any next domain is not working.

foreach($domains as $domain)
{
Folio::domain($domain->domain)->path(resource_path("views/pages/tenants/$domain->slug"));
}

in above code only first domain is working. any next domains are not working

Steps To Reproduce

in FolioServiceProvider

public function boot(): void
    {
        Folio::path(resource_path("views/pages/"));
        Folio::domain('domain-one.test')->path(resource_path("views/pages/tenants/one"));
        Folio::domain('domain-two.test')->path(resource_path("views/pages/tenants/two"));
    }
@nunomaduro
Copy link
Member

Hey there,

I am unable to reproduce your issue. However, it seems that the first Folio::path line points to folders shared with the lines below, specifically views/pages/tenants.

Can you try something like this and let me know how it goes?

        Folio::path(resource_path("views/pages/something-else"));
        Folio::domain('domain-one.test')->path(resource_path("views/pages/tenants/one"));
        Folio::domain('domain-two.test')->path(resource_path("views/pages/tenants/two"));

@winavin
Copy link
Author

winavin commented Dec 19, 2023

This is my folder structure.
Screenshot 2023-12-19 160745

in FolioServiceProvider

public function boot(): void
    {
        Folio::path(resource_path("views/pages/central"));
        Folio::domain('domain-one.test')->path(resource_path("views/pages/tenants/one"));
        Folio::domain('domain-two.test')->path(resource_path("views/pages/tenants/two"));
    }

Output for Folio Routes

php artisan folio:list


  GET       / .................................. resources/views/pages/central/index.blade.php  
  GET       domain-one.test/about-us ........... resources/views/pages/tenants/one/about-us.blade.php 

---------------------------------xxx------------------xxx----------------------
for

public function boot(): void
    {
        Folio::path(resource_path("views/pages"));
        Folio::domain('domain-one.test')->path(resource_path("views/pages/tenants/one"));
        Folio::domain('domain-two.test')->path(resource_path("views/pages/tenants/two"));
    }

Output is

  GET       domain-one.test/ ................ resources/views/pages/tenants/one/index.blade.php  
  GET       domain-one.test/about-us ........ resources/views/pages/tenants/one/about-us.blade.php  
  GET       /central ........................ resources/views/pages/central/index.blade.php  
  GET       /tenants/one .................... resources/views/pages/tenants/one/index.blade.php  
  GET       /tenants/one/about-us ........... resources/views/pages/tenants/one/about-us.blade.php  
  GET       /tenants/two .................... resources/views/pages/tenants/two/index.blade.php  
  GET       /tenants/two/about-us ........... resources/views/pages/tenants/two/about-us.blade.php

@winavin
Copy link
Author

winavin commented Dec 19, 2023

It seems like when there are same folder structure for multiple domains, that same folder structure conflict with creating urls.

pages
- tenants
---tenant-one
----- index.blade.php [ showing ]
----- same-page-name-for-each-domain.blade.php [ showing ]
----- different-page-name-for-domain-one.blade.php [ showing ]
---tenant-two
----- index.blade.php [ not showing ]
----- same-page-name-for-each-domain.blade.php [ not showing ]
----- different-page-name-for-domain-two.blade.php [ showing ]

then

routes for index and same page is not showing for domain two and following domains. while, different page names or folder structure is registered for each domain.

@nunomaduro
Copy link
Member

Thanks for sharing that info. Do you mind of creating and sharing a GitHub link to a open-source repository with fresh Laravel application that I can clone to reproduce your issue?

@nunomaduro
Copy link
Member

Because it may take a while, please create an new issue with that link, and a reference to this issue. Going to close this issue meanwhile.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants