1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-13 22:54:25 +01:00

Add parameter to reduce query burden

This commit is contained in:
David Bomba 2021-04-29 18:57:13 +10:00
parent 86534fe1e2
commit 9cb2fa4263
3 changed files with 39 additions and 0 deletions

View File

@ -47,6 +47,7 @@ class CompanyUser extends Pivot
'is_locked',
'slack_webhook_url',
'shop_restricted',
'number_years_active',
];
protected $touches = ['user'];

View File

@ -51,6 +51,7 @@ class CompanyUserTransformer extends EntityTransformer
'archived_at' => (int) $company_user->deleted_at,
'created_at' => (int) $company_user->created_at,
'permissions_updated_at' => (int) $company_user->permissions_updated_at,
'number_years_active' => (int) $company_user->number_years_active,
];
}

View File

@ -0,0 +1,37 @@
<?php
use App\Models\CompanyUser;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddNumberYearsActiveToCompanyUsersTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('company_user', function (Blueprint $table) {
$table->unsignedInteger('number_years_active')->default(3);
});
CompanyUser::cursor()->each(function ($cu){
$cu->number_years_active = 3;
$cu->save();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
}
}