Add projects to all entities - fixes for gateway casts

This commit is contained in:
David Bomba 2020-10-15 07:58:20 +11:00
parent 60c29a95c9
commit 3dca6ff171
15 changed files with 61 additions and 18 deletions

View File

@ -25,6 +25,7 @@ use App\Repositories\ProjectRepository;
use App\Transformers\ProjectTransformer; use App\Transformers\ProjectTransformer;
use App\Utils\Traits\BulkOptions; use App\Utils\Traits\BulkOptions;
use App\Utils\Traits\MakesHash; use App\Utils\Traits\MakesHash;
use App\Utils\Traits\SavesDocuments;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Facades\Cache; use Illuminate\Support\Facades\Cache;
@ -34,6 +35,7 @@ use Illuminate\Support\Facades\Cache;
class ProjectController extends BaseController class ProjectController extends BaseController
{ {
use MakesHash; use MakesHash;
use SavesDocuments;
protected $entity_type = Project::class; protected $entity_type = Project::class;

View File

@ -33,7 +33,7 @@ class StoreProjectRequest extends Request
{ {
$rules = []; $rules = [];
//$rules['name'] ='required|unique:projects,name,null,null,company_id,'.auth()->user()->companyId(); $rules['name'] ='required|unique:projects,name,null,null,company_id,'.auth()->user()->companyId();
$rules['client_id'] = 'required|exists:clients,id,company_id,'.auth()->user()->company()->id; $rules['client_id'] = 'required|exists:clients,id,company_id,'.auth()->user()->company()->id;
return $rules; return $rules;

View File

@ -40,6 +40,7 @@ class Credit extends BaseModel
protected $fillable = [ protected $fillable = [
'assigned_user_id', 'assigned_user_id',
'project_id',
'number', 'number',
'discount', 'discount',
'po_number', 'po_number',

View File

@ -43,6 +43,7 @@ class Expense extends BaseModel
'tax_name3', 'tax_name3',
'payment_date', 'payment_date',
'payment_type_id', 'payment_type_id',
'project_id',
'transaction_reference', 'transaction_reference',
'invoice_documents', 'invoice_documents',
'should_be_invoiced', 'should_be_invoiced',

View File

@ -25,7 +25,8 @@ class Gateway extends StaticModel
'updated_at' => 'timestamp', 'updated_at' => 'timestamp',
'created_at' => 'timestamp', 'created_at' => 'timestamp',
'default_gateway_type_id' => 'string', 'default_gateway_type_id' => 'string',
'fields' => 'json', // 'fields' => 'json',
'fields' => 'object',
'options' => 'array', 'options' => 'array',
]; ];
@ -35,21 +36,21 @@ class Gateway extends StaticModel
protected $dateFormat = 'Y-m-d H:i:s.u'; protected $dateFormat = 'Y-m-d H:i:s.u';
/** // /**
* @return mixed // * @return mixed
* @deprecated 5.0.17 No longer needs as we are removing omnipay dependence // * @deprecated 5.0.17 No longer needs as we are removing omnipay dependence
*/ // */
public function getFields() // public function getFields()
{ // {
if ($this->isCustom()) { // if ($this->isCustom()) {
return [ // return [
'name' => '', // 'name' => '',
'text' => '', // 'text' => '',
]; // ];
} else { // } else {
return Omnipay::create($this->provider)->getDefaultParameters(); // return Omnipay::create($this->provider)->getDefaultParameters();
} // }
} // }
public function getOptionsAttribute() public function getOptionsAttribute()
{ {

View File

@ -86,6 +86,7 @@ class Invoice extends BaseModel
'footer', 'footer',
'partial', 'partial',
'partial_due_date', 'partial_due_date',
'project_id',
'custom_value1', 'custom_value1',
'custom_value2', 'custom_value2',
'custom_value3', 'custom_value3',

View File

@ -54,6 +54,7 @@ class Quote extends BaseModel
'terms', 'terms',
'public_notes', 'public_notes',
'private_notes', 'private_notes',
'project_id',
'invoice_type_id', 'invoice_type_id',
'tax_name1', 'tax_name1',
'tax_rate1', 'tax_rate1',

View File

@ -63,6 +63,7 @@ class RecurringInvoice extends BaseModel
protected $fillable = [ protected $fillable = [
'client_id', 'client_id',
'project_id',
'number', 'number',
'discount', 'discount',
'is_amount_discount', 'is_amount_discount',

View File

@ -84,6 +84,7 @@ class CreditTransformer extends EntityTransformer
return [ return [
'id' => $this->encodePrimaryKey($credit->id), 'id' => $this->encodePrimaryKey($credit->id),
'user_id' => $this->encodePrimaryKey($credit->user_id), 'user_id' => $this->encodePrimaryKey($credit->user_id),
'project_id' => $this->encodePrimaryKey($credit->project_id),
'assigned_user_id' => $this->encodePrimaryKey($credit->assigned_user_id), 'assigned_user_id' => $this->encodePrimaryKey($credit->assigned_user_id),
'amount' => (float) $credit->amount, 'amount' => (float) $credit->amount,
'balance' => (float) $credit->balance, 'balance' => (float) $credit->balance,

View File

@ -87,6 +87,7 @@ class ExpenseTransformer extends EntityTransformer
'updated_at' => (int) $expense->updated_at, 'updated_at' => (int) $expense->updated_at,
'archived_at' => (int) $expense->deleted_at, 'archived_at' => (int) $expense->deleted_at,
'created_at' => (int) $expense->created_at, 'created_at' => (int) $expense->created_at,
'project_id' => $this->encodePrimaryKey($expense->project_id),
]; ];
} }
} }

View File

@ -88,6 +88,7 @@ class InvoiceTransformer extends EntityTransformer
return [ return [
'id' => $this->encodePrimaryKey($invoice->id), 'id' => $this->encodePrimaryKey($invoice->id),
'user_id' => $this->encodePrimaryKey($invoice->user_id), 'user_id' => $this->encodePrimaryKey($invoice->user_id),
'project_id' => $this->encodePrimaryKey($invoice->project_id),
'assigned_user_id' => $this->encodePrimaryKey($invoice->assigned_user_id), 'assigned_user_id' => $this->encodePrimaryKey($invoice->assigned_user_id),
'amount' => (float) $invoice->amount, 'amount' => (float) $invoice->amount,
'balance' => (float) $invoice->balance, 'balance' => (float) $invoice->balance,

View File

@ -137,6 +137,7 @@ class QuoteTransformer extends EntityTransformer
'line_items' => $quote->line_items ?: (array) [], 'line_items' => $quote->line_items ?: (array) [],
'entity_type' => 'quote', 'entity_type' => 'quote',
'exchange_rate' => (float) $quote->exchange_rate, 'exchange_rate' => (float) $quote->exchange_rate,
'project_id' => $this->encodePrimaryKey($quote->project_id),
]; ];
} }
} }

View File

@ -83,6 +83,7 @@ class RecurringInvoiceTransformer extends EntityTransformer
return [ return [
'id' => $this->encodePrimaryKey($invoice->id), 'id' => $this->encodePrimaryKey($invoice->id),
'user_id' => $this->encodePrimaryKey($invoice->user_id), 'user_id' => $this->encodePrimaryKey($invoice->user_id),
'project_id' => $this->encodePrimaryKey($invoice->project_id),
'assigned_user_id' => $this->encodePrimaryKey($invoice->assigned_user_id), 'assigned_user_id' => $this->encodePrimaryKey($invoice->assigned_user_id),
'amount' => (float) $invoice->amount, 'amount' => (float) $invoice->amount,
'balance' => (float) $invoice->balance, 'balance' => (float) $invoice->balance,

View File

@ -90,7 +90,7 @@ class CreateUsersTable extends Migration
$table->string('site_url', 200)->nullable(); $table->string('site_url', 200)->nullable();
$table->boolean('is_offsite')->default(false); $table->boolean('is_offsite')->default(false);
$table->boolean('is_secure')->default(false); $table->boolean('is_secure')->default(false);
$table->mediumText('fields')->nullable(); $table->longText('fields')->nullable();
$table->unsignedInteger('default_gateway_type_id')->default(1); $table->unsignedInteger('default_gateway_type_id')->default(1);
$table->timestamps(6); $table->timestamps(6);
}); });

View File

@ -0,0 +1,30 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class ProjectIdsToEntities extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('expenses', function (Blueprint $table) {
$table->unsignedInteger('project_id')->nullable();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
}
}