mirror of
https://github.com/crater-invoice/crater.git
synced 2025-10-27 11:41:09 -04:00
Added migration to Change over due status
This commit is contained in:
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
use Crater\Models\Invoice;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class ChangeOverDueStatusToSent extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
$overdueInvoices = Invoice::where('status', Invoice::STATUS_OVERDUE)->get();
|
||||
|
||||
if ($overdueInvoices) {
|
||||
$overdueInvoices->map(function ($overdueInvoice) {
|
||||
$overdueInvoice->status = Invoice::STATUS_SENT;
|
||||
$overdueInvoice->overdue = true;
|
||||
$overdueInvoice->save();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user