-
Notifications
You must be signed in to change notification settings - Fork 69
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
[2.1] Added support for customizing tenant model #49
Conversation
@@ -20,7 +20,8 @@ class TenantRepository | |||
*/ | |||
public function query(bool $withTrashed = false) | |||
{ | |||
$query = Tenant::query(); | |||
$class = config('saml2.tenantModel'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The same here.
Btw, we could also have something like Saml2::newModelIntance()
to have one resolver function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would that return the Model::newModelInstance()
or Model::query()
that it currently uses? Not sure which is preferred in that case.
Like I have this change stashed if you like it:
<?php
namespace Slides\Saml2;
use Slides\Saml2\Models\Tenant;
class Saml2
{
public static function tenantModel()
{
$class = config('saml2.tenantModel', Tenant::class);
return $class::query();
}
}
@brezzhnev Do you think this looks good or have any thoughts on changing it more? |
@brezzhnev Any thoughts here? I'd really like to be able to use this and customize the model without forking or anything if you have time to review. |
The benefit of this is that it allows applications to customize a bit of the model say to add more attributes to fillable or add relationships to other models which is what I'm looking to do since I have added a foreign key to another table in my database. It also resolves #27.
For example all I would have to do with these changes is update the
config/saml2.php
file with this:And then I can subclass this package's model in my application and I'm able to start using the new one right away to customize for my use cases.