ADD EV3-431 Profitcenter - betűkód phase2/1 add ProfitCenterSupplierCode data model
This commit is contained in:
parent
856b61da88
commit
75ba62b1e1
@ -3,6 +3,7 @@
|
|||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||||
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
||||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||||
|
|
||||||
@ -33,6 +34,11 @@ public function suppliers(): BelongsToMany
|
|||||||
return $this->belongsToMany(Supplier::class)->withTimestamps();
|
return $this->belongsToMany(Supplier::class)->withTimestamps();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function supplierCustomerCodes(): HasMany
|
||||||
|
{
|
||||||
|
return $this->hasMany(ProfitCenterSupplierCode::class);
|
||||||
|
}
|
||||||
|
|
||||||
public function contact(): MorphMany
|
public function contact(): MorphMany
|
||||||
{
|
{
|
||||||
return $this->morphMany(Contact::class, 'contactable');
|
return $this->morphMany(Contact::class, 'contactable');
|
||||||
|
|||||||
23
app/Models/ProfitCenterSupplierCode.php
Normal file
23
app/Models/ProfitCenterSupplierCode.php
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||||
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||||
|
|
||||||
|
class ProfitCenterSupplierCode extends BaseAuditable
|
||||||
|
{
|
||||||
|
use SoftDeletes;
|
||||||
|
|
||||||
|
protected $guarded = ['id', 'created_at', 'updated_at'];
|
||||||
|
|
||||||
|
public function profitCenter(): BelongsTo
|
||||||
|
{
|
||||||
|
return $this->belongsTo(ProfitCenter::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function supplier(): BelongsTo
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Supplier::class);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -44,6 +44,11 @@ public function profitCenter(): BelongsToMany
|
|||||||
return $this->belongsToMany(ProfitCenter::class)->withTimestamps();
|
return $this->belongsToMany(ProfitCenter::class)->withTimestamps();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function customerCodes(): HasMany
|
||||||
|
{
|
||||||
|
return $this->hasMany(ProfitCenterSupplierCode::class);
|
||||||
|
}
|
||||||
|
|
||||||
public function users(): HasMany
|
public function users(): HasMany
|
||||||
{
|
{
|
||||||
return $this->hasMany(User::class);
|
return $this->hasMany(User::class);
|
||||||
|
|||||||
@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::table('suppliers', function (Blueprint $table) {
|
||||||
|
$table->boolean('hasCustomerCode')->default(false)->after('deliveryLeadTime');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('suppliers', function (Blueprint $table) {
|
||||||
|
$table->dropColumn('hasCustomerCode');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
@ -0,0 +1,34 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::create('profit_center_supplier_codes', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->foreignId('profit_center_id')->constrained()->onDelete('cascade');
|
||||||
|
$table->foreignId('supplier_id')->constrained()->onDelete('cascade');
|
||||||
|
$table->string('customerCode')->nullable();
|
||||||
|
$table->userIdFields();
|
||||||
|
$table->timestamps();
|
||||||
|
$table->softDeletes();
|
||||||
|
|
||||||
|
$table->unique(['profit_center_id', 'supplier_id']);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('profit_center_supplier_codes');
|
||||||
|
}
|
||||||
|
};
|
||||||
Loading…
Reference in New Issue
Block a user