Add locations to mini/first load
This commit is contained in:
parent
7b7a630fdc
commit
c7bad23909
|
|
@ -154,6 +154,7 @@ class BaseController extends Controller
|
|||
'company.bank_transactions',
|
||||
'company.bank_transaction_rules',
|
||||
'company.task_schedulers',
|
||||
'company.locations',
|
||||
];
|
||||
|
||||
/**
|
||||
|
|
@ -178,6 +179,7 @@ class BaseController extends Controller
|
|||
'company.bank_integrations',
|
||||
'company.bank_transaction_rules',
|
||||
'company.task_schedulers',
|
||||
'company.locations',
|
||||
];
|
||||
|
||||
/**
|
||||
|
|
@ -525,6 +527,9 @@ class BaseController extends Controller
|
|||
'company.task_schedulers' => function ($query) {
|
||||
$query->whereNotNull('updated_at');
|
||||
},
|
||||
'company.locations' => function ($query) {
|
||||
$query->whereNotNull('updated_at');
|
||||
},
|
||||
]
|
||||
);
|
||||
|
||||
|
|
@ -630,6 +635,9 @@ class BaseController extends Controller
|
|||
$query->where('schedulers.user_id', $user->id);
|
||||
}
|
||||
},
|
||||
'company.locations' => function ($query) use ($created_at) {
|
||||
$query->where('created_at', '>=', $created_at);
|
||||
},
|
||||
]
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -252,6 +252,11 @@ class Credit extends BaseModel
|
|||
return $this->belongsTo(User::class, 'assigned_user_id', 'id')->withTrashed();
|
||||
}
|
||||
|
||||
public function location(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Location::class)->withTrashed();
|
||||
}
|
||||
|
||||
public function vendor(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Vendor::class);
|
||||
|
|
|
|||
|
|
@ -319,6 +319,11 @@ class Invoice extends BaseModel
|
|||
return $this->belongsTo(User::class)->withTrashed();
|
||||
}
|
||||
|
||||
public function location(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Location::class)->withTrashed();
|
||||
}
|
||||
|
||||
public function recurring_invoice(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
{
|
||||
return $this->belongsTo(RecurringInvoice::class, 'recurring_id', 'id')->withTrashed();
|
||||
|
|
|
|||
|
|
@ -307,6 +307,11 @@ class PurchaseOrder extends BaseModel
|
|||
return $this->belongsTo(User::class)->withTrashed();
|
||||
}
|
||||
|
||||
public function location(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Location::class)->withTrashed();
|
||||
}
|
||||
|
||||
public function client(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Client::class)->withTrashed();
|
||||
|
|
|
|||
|
|
@ -268,6 +268,11 @@ class Quote extends BaseModel
|
|||
return $this->belongsTo(User::class)->withTrashed();
|
||||
}
|
||||
|
||||
public function location(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Location::class)->withTrashed();
|
||||
}
|
||||
|
||||
public function client(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Client::class)->withTrashed();
|
||||
|
|
|
|||
|
|
@ -362,6 +362,11 @@ class RecurringInvoice extends BaseModel
|
|||
return $this->belongsTo(User::class)->withTrashed();
|
||||
}
|
||||
|
||||
public function location(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Location::class)->withTrashed();
|
||||
}
|
||||
|
||||
public function assigned_user(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'assigned_user_id', 'id')->withTrashed();
|
||||
|
|
|
|||
|
|
@ -32,8 +32,20 @@ class CreditTransformer extends EntityTransformer
|
|||
protected array $availableIncludes = [
|
||||
'activities',
|
||||
'client',
|
||||
'location',
|
||||
];
|
||||
|
||||
public function includeLocation(Credit $credit)
|
||||
{
|
||||
$transformer = new LocationTransformer($this->serializer);
|
||||
|
||||
if (!$credit->location) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $this->includeItem($credit->location, $transformer, \App\Models\Location::class);
|
||||
}
|
||||
|
||||
public function includeActivities(Credit $credit)
|
||||
{
|
||||
$transformer = new ActivityTransformer($this->serializer);
|
||||
|
|
@ -134,6 +146,7 @@ class CreditTransformer extends EntityTransformer
|
|||
'invoice_id' => $credit->invoice_id ? $this->encodePrimaryKey($credit->invoice_id) : '',
|
||||
'tax_info' => $credit->tax_data ?: new \stdClass(),
|
||||
'e_invoice' => $credit->e_invoice ?: new \stdClass(),
|
||||
'location_id' => $this->encodePrimaryKey($credit->location_id),
|
||||
|
||||
];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,8 +34,20 @@ class InvoiceTransformer extends EntityTransformer
|
|||
'payments',
|
||||
'client',
|
||||
'activities',
|
||||
'location',
|
||||
];
|
||||
|
||||
public function includeLocation(Invoice $invoice)
|
||||
{
|
||||
$transformer = new LocationTransformer($this->serializer);
|
||||
|
||||
if (!$invoice->location) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $this->includeItem($invoice->location, $transformer, \App\Models\Location::class);
|
||||
}
|
||||
|
||||
public function includeInvitations(Invoice $invoice)
|
||||
{
|
||||
$transformer = new InvoiceInvitationTransformer($this->serializer);
|
||||
|
|
@ -160,6 +172,7 @@ class InvoiceTransformer extends EntityTransformer
|
|||
'tax_info' => $invoice->tax_data ?: new \stdClass(),
|
||||
'e_invoice' => $invoice->e_invoice ?: new \stdClass(),
|
||||
'backup' => $invoice->backup ?: new \stdClass(),
|
||||
'location_id' => $this->encodePrimaryKey($invoice->location_id),
|
||||
];
|
||||
|
||||
if (request()->has('reminder_schedule') && request()->query('reminder_schedule') == 'true') {
|
||||
|
|
|
|||
|
|
@ -151,6 +151,7 @@ class PurchaseOrderTransformer extends EntityTransformer
|
|||
'currency_id' => $purchase_order->currency_id ? (string) $purchase_order->currency_id : '',
|
||||
'tax_info' => $purchase_order->tax_data ?: new \stdClass(),
|
||||
'e_invoice' => $purchase_order->e_invoice ?: new \stdClass(),
|
||||
'location_id' => $this->encodePrimaryKey($purchase_order->location_id),
|
||||
|
||||
];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,8 +32,21 @@ class QuoteTransformer extends EntityTransformer
|
|||
protected array $availableIncludes = [
|
||||
'activities',
|
||||
'client',
|
||||
'location',
|
||||
];
|
||||
|
||||
|
||||
public function includeLocation(Quote $quote)
|
||||
{
|
||||
$transformer = new LocationTransformer($this->serializer);
|
||||
|
||||
if (!$quote->location) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $this->includeItem($quote->location, $transformer, \App\Models\Location::class);
|
||||
}
|
||||
|
||||
public function includeActivities(Quote $quote)
|
||||
{
|
||||
$transformer = new ActivityTransformer($this->serializer);
|
||||
|
|
@ -150,6 +163,7 @@ class QuoteTransformer extends EntityTransformer
|
|||
'subscription_id' => $this->encodePrimaryKey($quote->subscription_id),
|
||||
'tax_info' => $quote->tax_data ?: new \stdClass(),
|
||||
'e_invoice' => $quote->e_invoice ?: new \stdClass(),
|
||||
'location_id' => $this->encodePrimaryKey($quote->location_id),
|
||||
|
||||
];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,8 +31,20 @@ class RecurringInvoiceTransformer extends EntityTransformer
|
|||
protected array $availableIncludes = [
|
||||
'activities',
|
||||
'client',
|
||||
'location',
|
||||
];
|
||||
|
||||
public function includeLocation(RecurringInvoice $invoice)
|
||||
{
|
||||
$transformer = new LocationTransformer($this->serializer);
|
||||
|
||||
if (!$invoice->location) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $this->includeItem($invoice->location, $transformer, \App\Models\Location::class);
|
||||
}
|
||||
|
||||
public function includeHistory(RecurringInvoice $invoice)
|
||||
{
|
||||
$transformer = new InvoiceHistoryTransformer($this->serializer);
|
||||
|
|
@ -134,6 +146,7 @@ class RecurringInvoiceTransformer extends EntityTransformer
|
|||
'paid_to_date' => (float) $invoice->paid_to_date,
|
||||
'subscription_id' => (string) $this->encodePrimaryKey($invoice->subscription_id),
|
||||
'e_invoice' => $invoice->e_invoice ?: new \stdClass(),
|
||||
'location_id' => $this->encodePrimaryKey($invoice->location_id),
|
||||
];
|
||||
|
||||
if (request()->has('show_dates') && request()->query('show_dates') == 'true') {
|
||||
|
|
|
|||
|
|
@ -40,11 +40,30 @@ return new class extends Migration
|
|||
$table->foreign('vendor_id')->references('id')->on('vendors')->onDelete('cascade')->onUpdate('cascade');
|
||||
$table->foreign('company_id')->references('id')->on('companies')->onDelete('cascade');
|
||||
});
|
||||
|
||||
Schema::table('invoices', function (Blueprint $table){
|
||||
|
||||
$table->foreignId('location_id')->nullable()->constrained()->cascadeOnDelete();
|
||||
});
|
||||
|
||||
Schema::table('recurring_invoices', function (Blueprint $table) {
|
||||
$table->foreignId('location_id')->nullable()->constrained()->cascadeOnDelete();
|
||||
});
|
||||
|
||||
Schema::table('credits', function (Blueprint $table) {
|
||||
$table->foreignId('location_id')->nullable()->constrained()->cascadeOnDelete();
|
||||
});
|
||||
|
||||
Schema::table('quotes', function (Blueprint $table) {
|
||||
$table->foreignId('location_id')->nullable()->constrained()->cascadeOnDelete();
|
||||
});
|
||||
|
||||
Schema::table('purchase_orders', function (Blueprint $table) {
|
||||
$table->foreignId('location_id')->nullable()->constrained()->cascadeOnDelete();
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
//
|
||||
|
|
|
|||
Loading…
Reference in New Issue