akaunting 3.0 (the last dance)
This commit is contained in:
@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Illuminate\Support\Str;
|
||||
@ -27,7 +28,7 @@ class Macro extends ServiceProvider
|
||||
public function boot()
|
||||
{
|
||||
Request::macro('isApi', function () {
|
||||
return $this->is(config('api.subtype') . '/*');
|
||||
return $this->is(config('api.prefix') . '/*');
|
||||
});
|
||||
|
||||
Request::macro('isNotApi', function () {
|
||||
@ -50,6 +51,14 @@ class Macro extends ServiceProvider
|
||||
return !$this->isInstall();
|
||||
});
|
||||
|
||||
Request::macro('isPreview', function ($company_id) {
|
||||
return $this->is($company_id . '/preview/*');
|
||||
});
|
||||
|
||||
Request::macro('isNotPreview', function ($company_id) {
|
||||
return !$this->isPreview($company_id);
|
||||
});
|
||||
|
||||
Request::macro('isSigned', function ($company_id) {
|
||||
return $this->is($company_id . '/signed/*');
|
||||
});
|
||||
@ -109,5 +118,15 @@ class Macro extends ServiceProvider
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
Collection::macro('withChildren', function ($relation, $addChildren) {
|
||||
$list = new Collection();
|
||||
|
||||
foreach ($this as $model) {
|
||||
$addChildren($list, $model, $relation, 0, $addChildren);
|
||||
}
|
||||
|
||||
return $list;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user