mirror of
https://github.com/snipe/snipe-it.git
synced 2025-01-12 06:17:28 -08:00
Adds a migration to create checkout acceptances
This creates the checkout acceptances for assets (basically what was previously shown in the „Unaccepted Assets“-report) when migrating the database
This commit is contained in:
parent
bbd1d6059a
commit
e445e201f3
|
@ -0,0 +1,43 @@
|
|||
<?php
|
||||
|
||||
use App\Models\Actionlog;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateCheckoutAcceptancesForUnacceptedAssets extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
// Get all assets not accepted
|
||||
$assets = DB::table('assets')->where('assigned_type', 'App\Models\User')->where('accepted', 'pending')->get();
|
||||
|
||||
$acceptances = [];
|
||||
|
||||
foreach($assets as $asset) {
|
||||
$acceptances[] = [
|
||||
'checkoutable_type' => 'App\Models\Asset',
|
||||
'checkoutable_id' => $asset->id,
|
||||
'assigned_to_id' => $asset->assigned_to,
|
||||
];
|
||||
}
|
||||
|
||||
DB::table('checkout_acceptances')->insert($acceptances);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue