Skip to content

FindOrFail not in model anymore in L5 #39

@AlanRezende

Description

@AlanRezende

Hi i was trying to use the laravel-multi-tenant in Laravel 5 most of thing works fine, but the findOrFail in the trait that calls the parent::findOrFail does not work anymore because theres no FindOrFail in the eloquent model anymore, just in the builder. Anyone knows how can i have a workaround it?

/**
     * Override the default findOrFail method so that we can rethrow a more useful exception.
     * Otherwise it can be very confusing why queries don't work because of tenant scoping issues.
     *
     * @param       $id
     * @param array $columns
     *
     * @throws TenantModelNotFoundException
     */
    public static function findOrFail($id, $columns = ['*'])
    {
        try {
            return parent::findOrFail($id, $columns);
        } catch (ModelNotFoundException $e) {
            throw with(new TenantModelNotFoundException())->setModel(get_called_class());
        }
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions