1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 13:12:50 +01:00

Add task schedulers to login / refresh routes

This commit is contained in:
David Bomba 2023-01-17 08:37:15 +11:00
parent 9641d88b14
commit f84a309964
3 changed files with 17 additions and 5 deletions

View File

@ -109,7 +109,7 @@ class BaseController extends Controller
'company.bank_integrations', 'company.bank_integrations',
'company.bank_transactions', 'company.bank_transactions',
'company.bank_transaction_rules', 'company.bank_transaction_rules',
'company.schedulers', 'company.task_schedulers',
]; ];
private $mini_load = [ private $mini_load = [
@ -129,7 +129,7 @@ class BaseController extends Controller
'company.subscriptions', 'company.subscriptions',
'company.bank_integrations', 'company.bank_integrations',
'company.bank_transaction_rules', 'company.bank_transaction_rules',
'company.schedulers', 'company.task_schedulers',
]; ];
public function __construct() public function __construct()
@ -467,7 +467,7 @@ class BaseController extends Controller
$query->where('bank_transaction_rules.user_id', $user->id); $query->where('bank_transaction_rules.user_id', $user->id);
} }
}, },
'company.schedulers'=> function ($query) use ($updated_at, $user) { 'company.task_schedulers'=> function ($query) use ($updated_at, $user) {
$query->where('updated_at', '>=', $updated_at); $query->where('updated_at', '>=', $updated_at);
if (! $user->isAdmin()) { if (! $user->isAdmin()) {
@ -554,7 +554,7 @@ class BaseController extends Controller
$query->where('bank_transaction_rules.user_id', $user->id); $query->where('bank_transaction_rules.user_id', $user->id);
} }
}, },
'company.schedulers'=> function ($query) use ($user) { 'company.task_schedulers'=> function ($query) use ($user) {
if (! $user->isAdmin()) { if (! $user->isAdmin()) {
$query->where('schedulers.user_id', $user->id); $query->where('schedulers.user_id', $user->id);
@ -818,7 +818,7 @@ class BaseController extends Controller
$query->where('bank_transactions.user_id', $user->id); $query->where('bank_transactions.user_id', $user->id);
} }
}, },
'company.schedulers'=> function ($query) use ($created_at, $user) { 'company.task_schedulers'=> function ($query) use ($created_at, $user) {
$query->where('created_at', '>=', $created_at); $query->where('created_at', '>=', $created_at);
if (! $user->isAdmin()) { if (! $user->isAdmin()) {

View File

@ -177,6 +177,11 @@ class Company extends BaseModel
return $this->hasMany(Scheduler::class); return $this->hasMany(Scheduler::class);
} }
public function task_schedulers() //alias for schedulers
{
return $this->hasMany(Scheduler::class);
}
public function all_documents() public function all_documents()
{ {
return $this->hasMany(Document::class); return $this->hasMany(Document::class);

View File

@ -108,6 +108,7 @@ class CompanyTransformer extends EntityTransformer
'bank_transactions', 'bank_transactions',
'bank_transaction_rules', 'bank_transaction_rules',
'task_schedulers', 'task_schedulers',
'schedulers',
]; ];
/** /**
@ -251,6 +252,12 @@ class CompanyTransformer extends EntityTransformer
return $this->includeCollection($company->schedulers, $transformer, Scheduler::class); return $this->includeCollection($company->schedulers, $transformer, Scheduler::class);
} }
public function includeSchedulers(Company $company)
{
$transformer = new SchedulerTransformer($this->serializer);
return $this->includeCollection($company->schedulers, $transformer, Scheduler::class);
}
public function includeBankTransactionRules(Company $company) public function includeBankTransactionRules(Company $company)
{ {