HipsterJazzbo\Landlord\BelongsToTenants::findOrFail PHP Method

findOrFail() public static method

Override the default findOrFail method so that we can re-throw a more useful exception. Otherwise it can be very confusing why queries don't work because of tenant scoping issues.
public static findOrFail ( mixed $id, array $columns = ['*'] ) : Illuminate\Database\Eloquent\Collection | Model
$id mixed
$columns array
return Illuminate\Database\Eloquent\Collection | Illuminate\Database\Eloquent\Model
    public static function findOrFail($id, $columns = ['*'])
    {
        try {
            return static::query()->findOrFail($id, $columns);
        } catch (ModelNotFoundException $e) {
            // If it DOES exist, just not for this tenant, throw a nicer exception
            if (!is_null(static::allTenants()->find($id, $columns))) {
                throw (new ModelNotFoundForTenantException())->setModel(get_called_class());
            }
            throw $e;
        }
    }