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

Use static properties for Team and Membership too #119

Merged
merged 1 commit into from
Sep 9, 2020

Conversation

mallardduck
Copy link
Contributor

Keeping some parody with the way the User model is managed by the Jetstream service, the Team and Membership models are now treated the same way.

This was inspired by #118 since that made me realize editing models location wouldn't be done in a consistent manner. So if all you wanted to do was point models to a different location you'd be overriding properties and methods. So by exposing all as static properties, now you only would add properties to your extension of Jetstream.


What extending Jetstream to adjust models looks like:

Before:

<?php


namespace App;

use App\SomeOther\Folder\User;

class MyJetstream extends \Laravel\Jetstream\Jetstream
{
    public static $userModel = User::class;

    /**
     * Get the name of the team model used by the application.
     *
     * @return string
     */
    public static function teamModel()
    {
        return 'App\\SomeOther\\Folder\\Team';
    }

    /**
     * Get the name of the team model used by the application.
     *
     * @return string
     */
    public static function membershipModel()
    {
        return 'App\\SomeOther\\Folder\\Membership';
    }
}

After

<?php


namespace App;

use App\SomeOther\Folder\User;
use App\SomeOther\Folder\Team;
use App\SomeOther\Folder\Membership;

class MyJetstream extends \Laravel\Jetstream\Jetstream
{
    public static $userModel = User::class;
    public static $teamModel = Team::class;
    public static $membershipModel = Membership::class;
}

@taylorotwell taylorotwell merged commit 16840d7 into laravel:1.x Sep 9, 2020
@taylorotwell
Copy link
Member

Thanks but we should also add methods to set these without having to extend the class.

@mallardduck
Copy link
Contributor Author

@taylorotwell - good call, I overlooked that existing already for User.
Will send over an additional PR soon.

@mallardduck
Copy link
Contributor Author

@taylorotwell if I were to document the use*Model methods somewhere in the docs repo, where do you think makes more sense?

  1. Getting Started > Configuration
  2. Customization > Models

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

Successfully merging this pull request may close these issues.

2 participants