mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
INA-3 | Scheduler and ScheduledJob models & migrations
This commit is contained in:
parent
ae21b9244e
commit
09b895dfcb
49
app/Models/ScheduledJob.php
Normal file
49
app/Models/ScheduledJob.php
Normal file
@ -0,0 +1,49 @@
|
||||
<?php
|
||||
/**
|
||||
* Invoice Ninja (https://invoiceninja.com).
|
||||
*
|
||||
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||
*
|
||||
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
|
||||
*
|
||||
* @license https://opensource.org/licenses/AAL
|
||||
*/
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* @property mixed|string action_class
|
||||
* @property array parameters
|
||||
* @property string action_name
|
||||
* @property integer scheduler_id
|
||||
*/
|
||||
class ScheduledJob extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
const CREATE_CLIENT_REPORT = 'create_client_report';
|
||||
const CREATE_CLIENT_CONTACT_REPORT = 'create_client_contact_report';
|
||||
const CREATE_CREDIT_REPORT = 'create_credit_report';
|
||||
const CREATE_DOCUMENT_REPORT = 'create_document_report';
|
||||
const CREATE_EXPENSE_REPORT = 'create_expense_report';
|
||||
const CREATE_INVOICE_ITEM_REPORT = 'create_invoice_item_report';
|
||||
const CREATE_INVOICE_REPORT = 'create_invoice_report';
|
||||
const CREATE_PAYMENT_REPORT = 'create_payment_report';
|
||||
const CREATE_PRODUCT_REPORT = 'create_product_report';
|
||||
const CREATE_PROFIT_AND_LOSS_REPORT = 'create_profit_and_loss_report';
|
||||
const CREATE_QUOTE_ITEM_REPORT ='create_quote_item_report';
|
||||
const CREATE_QUOTE_REPORT = 'create_quote_report';
|
||||
const CREATE_RECURRING_INVOICE_REPORT = 'create_recurring_invoice_report';
|
||||
const CREATE_TASK_REPORT = 'create_task_report';
|
||||
|
||||
|
||||
protected $fillable = ['action_class', 'action_name', 'parameters', 'scheduler_id'];
|
||||
protected $casts = [
|
||||
'required_parameters' => 'array',
|
||||
'scheduled_run' => 'date',
|
||||
'parameters' => 'array'
|
||||
];
|
||||
}
|
45
app/Models/Scheduler.php
Normal file
45
app/Models/Scheduler.php
Normal file
@ -0,0 +1,45 @@
|
||||
<?php
|
||||
/**
|
||||
* Invoice Ninja (https://invoiceninja.com).
|
||||
*
|
||||
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||
*
|
||||
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
|
||||
*
|
||||
* @license https://opensource.org/licenses/AAL
|
||||
*/
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* @property boolean paused
|
||||
* @property boolean archived
|
||||
* @property \Carbon\Carbon|mixed start_from
|
||||
* @property string repeat_every
|
||||
* @property \Carbon\Carbon|mixed scheduled_run
|
||||
*/
|
||||
class Scheduler extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'start_from',
|
||||
'paused',
|
||||
'archived',
|
||||
'repeat_every',
|
||||
'scheduled_run',
|
||||
];
|
||||
const DAILY = 'DAY';
|
||||
const WEEKLY = 'WEEK';
|
||||
const MONTHLY = 'MONTH';
|
||||
const QUARTERLY = '3MONTHS';
|
||||
const ANNUALLY = 'YEAR';
|
||||
|
||||
public function job(): \Illuminate\Database\Eloquent\Relations\HasOne
|
||||
{
|
||||
return $this->hasOne(ScheduledJob::class, 'scheduler_id', 'id');
|
||||
}
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
<?php
|
||||
/**
|
||||
* Invoice Ninja (https://invoiceninja.com).
|
||||
*
|
||||
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||
*
|
||||
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
|
||||
*
|
||||
* @license https://opensource.org/licenses/AAL
|
||||
*/
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateScheduledJobsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('scheduled_jobs', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('action_name');
|
||||
$table->string('action_class');
|
||||
$table->json('parameters')->nullable();
|
||||
$table->foreignIdFor(\App\Models\Scheduler::class);
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('scheduled_jobs');
|
||||
}
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
<?php
|
||||
/**
|
||||
* Invoice Ninja (https://invoiceninja.com).
|
||||
*
|
||||
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||
*
|
||||
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
|
||||
*
|
||||
* @license https://opensource.org/licenses/AAL
|
||||
*/
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateSchedulersTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('schedulers', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->boolean('paused')->default(false);
|
||||
$table->boolean('archived')->default(false);
|
||||
$table->string('repeat_every');
|
||||
$table->timestamp('start_from');
|
||||
$table->timestamp('scheduled_run');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('schedulers');
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user