Fix site_id table references
This commit is contained in:
parent
4b85e01e93
commit
798608cebd
@ -35,19 +35,19 @@ class ImportCosts implements ShouldQueue
|
|||||||
$this->file = $file;
|
$this->file = $file;
|
||||||
Config::set('site',$site);
|
Config::set('site',$site);
|
||||||
|
|
||||||
$this->co = Cost::where('site_id',$site->id)
|
$this->co = Cost::where('site_id',$site->site_id)
|
||||||
->where('supplier_id',$so->id)
|
->where('supplier_id',$so->id)
|
||||||
->where('billed_at',$invoice_date)
|
->where('billed_at',$invoice_date)
|
||||||
->firstOrNew();
|
->firstOrNew();
|
||||||
$this->co->active = TRUE;
|
$this->co->active = TRUE;
|
||||||
$this->co->site_id = $site->id;
|
$this->co->site_id = $site->site_id;
|
||||||
$this->co->billed_at = $invoice_date;
|
$this->co->billed_at = $invoice_date;
|
||||||
$this->co->supplier_id = $so->id;
|
$this->co->supplier_id = $so->id;
|
||||||
$this->co->save();
|
$this->co->save();
|
||||||
|
|
||||||
Cost\Broadband::where('cost_id',$this->co->id)->where('site_id',$site->id)->delete();
|
Cost\Broadband::where('cost_id',$this->co->id)->where('site_id',$site->site_id)->delete();
|
||||||
Cost\Phone::where('cost_id',$this->co->id)->where('site_id',$site->id)->delete();
|
Cost\Phone::where('cost_id',$this->co->id)->where('site_id',$site->site_id)->delete();
|
||||||
Cost\Generic::where('cost_id',$this->co->id)->where('site_id',$site->id)->delete();
|
Cost\Generic::where('cost_id',$this->co->id)->where('site_id',$site->site_id)->delete();
|
||||||
|
|
||||||
// @todo to be stored in supplier config
|
// @todo to be stored in supplier config
|
||||||
$headers = [
|
$headers = [
|
||||||
|
52
database/migrations/2022_08_19_133535_fix_siteid.php
Normal file
52
database/migrations/2022_08_19_133535_fix_siteid.php
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
foreach ([
|
||||||
|
'checkouts',
|
||||||
|
'costs',
|
||||||
|
'domain_registrars',
|
||||||
|
'product_broadband',
|
||||||
|
'product_email',
|
||||||
|
'product_generic',
|
||||||
|
'product_host',
|
||||||
|
'product_ssl',
|
||||||
|
'products',
|
||||||
|
'provider_oauth',
|
||||||
|
'supplier_broadband',
|
||||||
|
'supplier_domain',
|
||||||
|
'supplier_email',
|
||||||
|
'supplier_generic',
|
||||||
|
'supplier_host',
|
||||||
|
'supplier_host_servers',
|
||||||
|
'supplier_ssl',
|
||||||
|
] as $table)
|
||||||
|
{
|
||||||
|
Schema::table($table, function (Blueprint $table) {
|
||||||
|
$table->dropForeign(['site_id']);
|
||||||
|
$table->foreign(['site_id'])->references(['site_id'])->on('sites');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
abort(500,'cant go back');
|
||||||
|
}
|
||||||
|
};
|
Loading…
Reference in New Issue
Block a user