- Add Business Type In Company

- Seeder CLF Company
- DB Migration 4
This commit is contained in:
CheeSiong
2020-11-24 14:34:41 +08:00
parent 2faad9a7f8
commit 83a9cee82d
6 changed files with 123 additions and 3 deletions
@@ -0,0 +1,9 @@
<?php
namespace App\Classes\ValueObjects\Constants;
final class BusinessType {
public const IMPORTER = 1;
public const FREIGHT_FORARDER = 2;
public const CURRENCY_VENDOR = 3;
}
+40
View File
@@ -0,0 +1,40 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Relations\HasOne;
/**
* Class CompanyBank
* @package App\Models
* @version August 4, 2020, 4:36 am
*
* @property \App\Models\Country country_id
* @property \App\Models\Company company_id
* @property string bank_name
* @property string holder_name
* @property string account_no
* @property int type
* @property int default
* @property int status
*/
class CompanyBank extends AbstractModel
{
protected $table = 'company_banks';
/**
* @return \Illuminate\Database\Eloquent\Relations\HasOne
**/
public function country(): HasOne
{
return $this->hasOne(Country::class, 'country_id', 'id');
}
/**
* @return \Illuminate\Database\Eloquent\Relations\HasOne
**/
public function company(): HasOne
{
return $this->hasOne(Company::class, 'company_id', 'id');
}
}
@@ -15,9 +15,10 @@ class CreateCompaniesTable extends Migration
{
Schema::create('companies', function (Blueprint $table) {
$table->id();
$table->string('name')->nullable();
$table->string('reference')->nullable();
$table->integer('type')->nullable();
$table->string('name');
$table->string('reference');
$table->integer('type');
$table->integer('business_type')->default(1);
$table->timestamps();
$table->softDeletes();
});
@@ -0,0 +1,41 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateCompanyBanksTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('company_banks', function (Blueprint $table) {
$table->id();
$table->bigInteger('country_id')->unsigned()->nullable();
$table->foreign('country_id')->references('id')->on('countries')->onDelete('cascade');
$table->bigInteger('company_id')->unsigned()->nullable();
$table->foreign('company_id')->references('id')->on('companies')->onDelete('cascade');
$table->string('bank_name');
$table->string('holder_name');
$table->string('account_no');
$table->integer('type');
$table->integer('default');
$table->integer('status');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('company_banks');
}
}
+27
View File
@@ -0,0 +1,27 @@
<?php
use Illuminate\Database\Seeder;
use Illuminate\Support\Str;
class CompaniesTableSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
DB::table('companies')->insert([
[
'id' => 1,
'name' => 'CIEF SDN BHD',
'reference' => 'CIEF',
'type' => 2,
'business_type' => 1,
'created_at' => date('Y-m-d H:i:s'),
'updated_at' => date('Y-m-d H:i:s')
]
]);
}
}
+2
View File
@@ -21,6 +21,8 @@ class DatabaseSeeder extends Seeder
$this->call(SegmentsTableSeeder::class);
$this->call(SegmentConstantsTableSeeder::class);
$this->call(CompaniesTableSeeder::class);
// Admin
$this->call(AdminUserTableSeeder::class);