ashokgelal / townhouse Goto Github PK
View Code? Open in Web Editor NEWA multi-tenant Laravel app for listing property rentals
A multi-tenant Laravel app for listing property rentals
Hi there,
Very good tutorial, but still having a problem in accessing the main domain.
I'm able to access the tenants websites, but the main domain not.
any advice on this would be greatly appreciated.
Thank you
When i try to create tenant getting error
tenancy>php artisan tenant:create boise [email protected]
Symfony\Component\Debug\Exception\FatalThrowableError : Class 'Hyn\Tenancy\Models\Customer' not found
at tenancy\app\Console\Commands\CreateTenant.php:46
42| }
43|
44| private function tenantExists($name, $email)
45| {
46| return Customer::where('name', $name)->orWhere('email', $email)->exists();
47| }
48|
49| private function registerTenant($name, $email)
50| {
Exception trace:
1 App\Console\Commands\CreateTenant::tenantExists("boise", "[email protected]")
tenancy\app\Console\Commands\CreateTenant.php:27
2 App\Console\Commands\CreateTenant::handle()
tenancy\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php:29
Please use the argument -v to see more details.
Thank you for the great work with this townhouse project!
I want to ask a question that is fundamental to Laravel Tenancy, so that I can know what to expect of townhouse. My question is:
Does Laravel Tenancy (and by extension, townhouse) provide support for external websites/domains?
For example, if I host this Laravel Tenancy app on www.my-saas-domain.com and I have 3 clients from different countries that want my service hosted at www.my-saas-domain.com to be available on their already existing websites, and their websites are www.flamingo.com, www.cupcakes.com, and the third client has his website at www.client3.com:
Thanks
Hi, I have a problem with the migrations, when run php artisan tenancy:install
run customer, websites, and hostname are migrated, but the user and passwordResets are not migrated because they are into tenant folder when run php artisan migrate
Thanks
I tried replicating step 5 of the tutorial but I'm stuck at ProfileTest.
I'm getting the following when I try to test ProfileTest::edit_renders_correct_view
Code:
/** @test */
public function edit_renders_correct_view()
{
$user = $this->createUserInTenant();
$this->signIn($user);
$response = $this->get(route('tenant.account.profile.edit'));
$response->assertViewIs('tenant.account.profile');
}
Console:
1) Tests\Feature\ProfileTest::edit_renders_correct_view
The response is not a view.
/home/vagrant/code/townhouse-testing/vendor/laravel/framework/src/Illuminate/Foundation/Testing/TestResponse.php:787
/home/vagrant/code/townhouse-testing/vendor/laravel/framework/src/Illuminate/Foundation/Testing/TestResponse.php:712
/home/vagrant/code/townhouse-testing/tests/Feature/ProfileTest.php:18
On debugging, I found that $response has a statusCode
of 404, where the expected is 200.
I have this repository using commit da862a5 (before 5.2 update) together with my project in Laravel/Homestead and this repository's ProfileTest passes while the ProfileTest for my project fails. I used kdiff3 to compare my project repository with the mentioned commit of this repository and to best of my knowledge all routing related code/configuration is the same.
When I manually create a tenant using sudo php artisan tenant:create boston [email protected]
, map, I can access the profile page.
Hi
I followed all the steps in my system (W10, Apache2 and MySQL) but when I try to open boise.townhouse.dev
in browser then its not showing any page for me and its redirecting to https
also.
Do I need to add vhost in apache to make it work?
Thanks,
Anil
Hello, How can i organise web.php routs and judge which tenant in controller for url 'boise.townhouse.dev/show'.
I have no idea to handle Hyn\Tenancy!
thank you!
Hi Ashok,
I have started a new project based on your tutorial (Great by the way...bravo), but noticed that recently 5.2 of tenancy package was released and they did a big change in the package.
The Customer model no longer present.
Will you update the tutorial? Can you give some hints on this?
Big thanks to you.
Hi!
Lets suppose that i have an app called: townhouse.co, and my app can handle multiple services, eg:
creator.townhouse.co
elections.townhouse.co
(each one has its own logic)
then, i need to whitelabel these services (to each town), eg:
creator.london.uk
elections.london.uk
creator.florida.us
elections.florida.us
how i can accomplish that? (note that in the url, we dont use "townhouse.co" anymore, but the city name)
As a full fledge multi tenant web application i would love to have admin portal with the same code base. Looking forward this feature to be added.
Hi, after create all post How create Milti-tenant all work fine but when reset password show an error
Database [tenant] not configured.
Laravel: 5.5
multi-tenant: 5.0
All work fine, but in this line I have commented this line.
/** @test */
public function tenant_database_is_removed()
{
$this->artisan('tenant:create', ['name' => 'xxx', 'email' => '[email protected]']);
$this->artisan('tenant:delete', ['name' => 'xxx']);
**//$this->expectException(QueryException::class);**
$this->assertDatabaseHas('users', ['email' => '[email protected]']);
}ting that exception of type "Illuminate\Database\QueryException" is thrown.
ispges ➤ t --stop-on-failure git:develop*
PHPUnit 6.5.6 by Sebastian Bergmann and contributors.
...........F
Time: 4.28 seconds, Memory: 22.00MB
There was 1 failure:
1) Tests\Feature\TenantDeleteCommandTest::tenant_database_is_removed
Failed asserting that exception of type "Illuminate\Database\QueryException" is thrown.
FAILURES!
Tests: 12, Assertions: 17, Failures: 1.
Hello
I have implemented your multi-tenant approach and reskinned the password reset page to fit with my application.
When I click the link in the email it loads the page fine, I populate the details and submit but it refreshes the page rather than progressing to the /home route. I thought originally that the password reset was submitted just didnt route to my dashboard (home) page, however when I try to login via the regular auth/login form I get "These credentials do not match our records." prompt.
I've double and tripple checked the default reset page blade code against my modified code and i'm not missing anything relating to the form.
Any ideas?
My reset.blade.php code...
`
<form method="POST" action="{{ route('password.request') }}">
@csrf
<input type="hidden" name="token" value="{{ $token }}">
<div class="login-wrapper wd-300 wd-xs-350 pd-25 pd-xs-40 bg-white rounded shadow-base">
<div class="signin-logo tx-center tx-28 tx-bold tx-inverse">
<span class="tx-normal">TITAN</span>
</div>
<div class="tx-center">Welcome to the Titan framework.</div>
<div class="tx-center mg-b-30">Please set a new password to continue.</div>
<div class="form-group">
<input id="email" placeholder="Enter your email address" type="email" class="form-control{{ $errors->has('email') ? ' is-invalid' : '' }}"
name="email" value="{{ $email or old('email') }}" required autofocus> @if ($errors->has('email'))
<span class="invalid-feedback">
<strong>{{ $errors->first('email') }}</strong>
</span>
@endif
</div>
<!-- form-group -->
<div class="form-group">
<input id="password" placeholder="Choose password" type="password" class="form-control{{ $errors->has('password') ? ' is-invalid' : '' }}"
name="password" required> @if ($errors->has('password'))
<span class="invalid-feedback">
<strong>{{ $errors->first('password') }}</strong>
</span>
@endif
</div>
<!-- form-group -->
<div class="form-group">
<input id="password-confirm" placeholder="Confirm password" type="password" class="form-control{{ $errors->has('password_confirmation') ? ' is-invalid' : '' }}"
name="password_confirmation" required> @if ($errors->has('password_confirmation'))
<span class="invalid-feedback">
<strong>{{ $errors->first('password_confirmation') }}</strong>
</span>
@endif
</div>
<!-- form-group -->
<button type="submit" class="btn btn-info btn-block">{{ __('Reset Password') }}</button>
</div>
<!-- login-wrapper -->
When I try to create admin user for tenant I get the below error:
Method Illuminate\Database\Query\Builder::assignRole does not exist.
I successfully installed tenancy using php artisan tenancy:install
The class CreateTenant is also created at app\Console\Commands\CreateTenant.php
I also added these in providers in app.php
// Hyn multi tenancy.
Hyn\Tenancy\Providers\Tenants\ConfigurationProvider::class,
Hyn\Tenancy\Providers\TenancyProvider::class,
// Hyn multi tenancy webserver integration.
Hyn\Tenancy\Providers\WebserverProvider::class,
and added this in Kernel.php,
protected $commands = [
// Commands\CreateTenant::class
'App\Console\Commands\CreateTenant'
];
But when I run php artisan tenant:create gc [email protected] , I get error "There are no commands defined in "tenant" namespace.
I have cleared config cache many times, but still same error. Please guide what am I missing here.
Thanks
I'm on Ubuntu and I have followed of the steps through Part 1. But when I run my server using **php artisan serve ** I get this error message:
Sorry, the page you are looking for could not be found.
Is there a way I can get this working on ubuntu or do I need to get a Macbook?
hi , thank you for this nice project..
after install in in command php artisan tenant:create bosto 123456 [email protected]
and set webserver.php > apache = true it cant run apache2ctl graceful
it need sudo aslo i set sudo apache2ctl graceful in webserver.php get password but have other errors ...
please help me how i can run this project in user non sudo
Hi I have an error when I create a tenant from console:
#php artisan tenant:create boise [email protected]
Illuminate\Database\QueryException : SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'IF NOT EXISTS 51d58fb26e6a436b83e835a3cbbb432b
@'127.0.0.1' IDENTIFIED BY '1ce8' at line 1 (SQL: CREATE USER IF NOT EXISTS 51d58fb26e6a436b83e835a3cbbb432b
@'127.0.0.1' IDENTIFIED BY '1ce8cd62c029a370c4b063151678c542')
at /home/user/Apps/workshop_proj/vendor/laravel/framework/src/Illuminate/Database/Connection.php:664
660| // If an exception occurs when attempting to run a query, we'll format the error
661| // message to include the bindings with SQL, which will make this exception a
662| // lot more helpful to the developer instead of just the database's errors.
663| catch (Exception $e) {
664| throw new QueryException(
665| $query, $this->prepareBindings($bindings), $e
666| );
667| }
668|
Exception trace:
1 Doctrine\DBAL\Driver\PDOException::("SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'IF NOT EXISTS 51d58fb26e6a436b83e835a3cbbb432b
@'127.0.0.1' IDENTIFIED BY '1ce8' at line 1")
/home/user/Apps/workshop_proj/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:82
2 PDOException::("SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'IF NOT EXISTS 51d58fb26e6a436b83e835a3cbbb432b
@'127.0.0.1' IDENTIFIED BY '1ce8' at line 1")
/home/user/Apps/workshop_proj/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:80
Please use the argument -v to see more details.
hi,
cloned the project and now when i run it on townhouse.test.
app.js and app.css are not found it result to 404 error.
Hi,
I have a question, in the middleware enforce.tenancy is by default for all tenants, but
I would like that only was for the subdomain url subdomain.domain.com,
for the domain.com middleware It should be web.
How I can change in the EnforceTenancy middleware?
Thanks!!
In the refactoring I found an error The given data was invalid.
and to solve it I had to change the way in which the relations of the hostname and the website are made.
the relationship to website
$website->customer_id = $customer->id;
$hostname->customer_id = $customer->id;
$hostname->website_id = $website->id;
the relationship to hostname
$hostname->customer_id = $customer->id;
$hostname->website_id = $website->id;
and now it works!!
;)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.