Another slightly less ugly way for backward compatibility
Instead of using a constructor, add a special check in the boot-method for locations. This seems to fit better in the system and does hopefully not break the existing tests. Signed-off-by: Tobias Regnery <tobias.regnery@gmail.com>
This commit is contained in:
+1
-10
@@ -18,17 +18,8 @@ use Watson\Validating\ValidatingTrait;
|
||||
|
||||
class Location extends SnipeModel
|
||||
{
|
||||
function __construct() {
|
||||
parent::__construct();
|
||||
// This is a workaround for backward compatibility with older versions where locations doesn't get scoped.
|
||||
// Normaly we would only add 'use CompanyableTrait;', but this has to be conditional on the setting.
|
||||
// So instead of using the trait, add the scope directly if no backward compatibility is used
|
||||
if (Setting::getSettings()->scope_locations_fmcs) {
|
||||
static::addGlobalScope(new CompanyableScope);
|
||||
}
|
||||
}
|
||||
|
||||
use HasFactory;
|
||||
use CompanyableTrait;
|
||||
|
||||
protected $presenter = \App\Presenters\LocationPresenter::class;
|
||||
use Presentable;
|
||||
|
||||
Reference in New Issue
Block a user