Initial commit

This commit is contained in:
omair saleh
2020-08-12 04:16:41 +08:00
commit 57bd2be885
476 changed files with 41783 additions and 0 deletions
+2
View File
@@ -0,0 +1,2 @@
*.sqlite
*.sqlite-journal
+20
View File
@@ -0,0 +1,20 @@
<?php
/** @var \Illuminate\Database\Eloquent\Factory $factory */
use Faker\Generator as Faker;
$factory->define(App\Models\Address::class, function (Faker $faker) {
return [
'company_id' => $faker->numberBetween(1, 30),
'street_one' => $faker->streetAddress,
'street_two' => $faker->streetAddress,
'city' => $faker->city,
'state' => $faker->state,
'post_code' => $faker->postcode,
'country' => $faker->country,
'default' => 1,
'billing' => 1
];
});
+14
View File
@@ -0,0 +1,14 @@
<?php
/** @var \Illuminate\Database\Eloquent\Factory $factory */
use Faker\Generator as Faker;
$factory->define(App\Models\Company::class, function (Faker $faker) {
return [
'reference_no' => $faker->numerify('##########'),
'name' => $faker->company.' '.$faker->companySuffix,
'type' => $faker->randomDigitNotNull
];
});
+17
View File
@@ -0,0 +1,17 @@
<?php
/** @var \Illuminate\Database\Eloquent\Factory $factory */
use Faker\Generator as Faker;
$factory->define(App\Models\Contact::class, function (Faker $faker) {
return [
'company_id' => $faker->word,
'name' => $faker->word,
'designation' => $faker->word,
'email' => $faker->word,
'phone' => $faker->word,
'wechat_id' => $faker->word
];
});
+30
View File
@@ -0,0 +1,30 @@
<?php
/** @var \Illuminate\Database\Eloquent\Factory $factory */
use App\Classes\ValueObjects\Constants\Roles;
use App\Models\User;
use Faker\Generator as Faker;
use Illuminate\Support\Str;
/*
|--------------------------------------------------------------------------
| Model Factories
|--------------------------------------------------------------------------
|
| This directory should contain each of the model factory definitions for
| your application. Factories provide a convenient way to generate new
| model instances for testing / seeding your application's database.
|
*/
$factory->define(User::class, function (Faker $faker) {
return [
'name' => $faker->name,
'role_id' => Roles::USER,
'email' => $faker->unique()->safeEmail,
'email_verified_at' => now(),
'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi',
'remember_token' => Str::random(10),
];
});
@@ -0,0 +1,39 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateUsersTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('users', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('email')->unique();
$table->timestamp('email_verified_at')->nullable();
$table->string('password');
$table->smallInteger('role_id');
$table->boolean('active')->default(true);
$table->rememberToken();
$table->softDeletes();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('users');
}
}
@@ -0,0 +1,35 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateFailedJobsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('failed_jobs', function (Blueprint $table) {
$table->id();
$table->text('connection');
$table->text('queue');
$table->longText('payload');
$table->longText('exception');
$table->timestamp('failed_at')->useCurrent();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('failed_jobs');
}
}
@@ -0,0 +1,37 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreatePasswordResetsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('password_resets', function (Blueprint $table) {
$table->id();
$table->bigInteger('user_id')->unsigned();
$table->string('token');
$table->boolean('is_expired')->default(true);
$table->boolean('is_complete')->default(false);
$table->timestamps();
$table->foreign('user_id')->references('id')->on('users');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('password_resets');
}
}
@@ -0,0 +1,35 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateJobsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('jobs', function (Blueprint $table) {
$table->id();
$table->string('queue')->index();
$table->longText('payload');
$table->unsignedTinyInteger('attempts');
$table->unsignedInteger('reserved_at')->nullable();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('jobs');
}
}
@@ -0,0 +1,42 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateActivityLogTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('activity_log', function (Blueprint $table) {
$table->id();
$table->string('log_name')->nullable();
$table->text('description');
$table->unsignedBigInteger('subject_id')->nullable();
$table->string('subject_type')->nullable();
$table->unsignedBigInteger('causer_id')->nullable();
$table->string('causer_type')->nullable();
$table->text('properties')->nullable();
$table->timestamps();
$table->index('log_name');
$table->index(['subject_id', 'subject_type'], 'subject');
$table->index(['causer_id', 'causer_type'], 'causer');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('activity_log');
}
}
@@ -0,0 +1,37 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class CreateCompaniesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('companies', function (Blueprint $table) {
$table->id();
$table->bigInteger('reference_no')->unique();
$table->string('name');
$table->integer('type');
$table->integer('status')->default(0);
$table->timestamps();
$table->softDeletes();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('companies');
}
}
@@ -0,0 +1,45 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class CreateAddressesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('addresses', function (Blueprint $table) {
$table->id();
$table->foreignId('company_id');
$table->string('street_one');
$table->string('street_two')->nullable();
$table->string('city');
$table->string('state');
$table->string('post_code');
$table->string('country');
$table->integer('default');
$table->integer('billing');
$table->timestamps();
$table->softDeletes();
$table->foreign('company_id')->references('id')->on('companies');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('addresses');
}
}
@@ -0,0 +1,43 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateOrderTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('order', function (Blueprint $table) {
$table->id();
$table->foreignId('company_id');
$table->string('marking')->unique();
$table->foreignId('forwarder_id');
$table->foreignId('address_id');
$table->string('current_step')->nullable();
$table->boolean('multiple_batch')->default(0);
$table->boolean('complete')->default(0);
$table->softDeletes();
$table->timestamps();
$table->foreign('company_id')->references('id')->on('companies');
$table->foreign('forwarder_id')->references('id')->on('companies');
$table->foreign('address_id')->references('id')->on('addresses');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('order');
}
}
@@ -0,0 +1,40 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class CreateContactsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('contacts', function (Blueprint $table) {
$table->id();
$table->foreignId('company_id');
$table->string('name');
$table->string('designation')->nullable();
$table->string('email')->nullable();
$table->string('phone')->nullable();
$table->string('wechat_id')->nullable();
$table->timestamps();
$table->softDeletes();
$table->foreign('company_id')->references('id')->on('companies');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('contacts');
}
}
@@ -0,0 +1,43 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateOrdersTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('orders', function (Blueprint $table) {
$table->id();
$table->foreignId('company_id');
$table->string('marking')->unique();
$table->foreignId('forwarder_id');
$table->foreignId('address_id');
$table->string('current_step')->nullable();
$table->boolean('multiple_batch')->default(0);
$table->boolean('complete')->default(0);
$table->softDeletes();
$table->timestamps();
$table->foreign('company_id')->references('id')->on('companies');
$table->foreign('forwarder_id')->references('id')->on('companies');
$table->foreign('address_id')->references('id')->on('addresses');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('orders');
}
}
@@ -0,0 +1,36 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateOrderWarehousesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('order_warehouses', function (Blueprint $table) {
$table->id();
$table->foreignId('order_id');
$table->foreignId('warehouse_id');
$table->timestamps();
$table->foreign('order_id')->references('id')->on('orders');
$table->foreign('warehouse_id')->references('id')->on('companies');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('order_warehouses');
}
}
+16
View File
@@ -0,0 +1,16 @@
<?php
use Illuminate\Database\Seeder;
class AddressesTableSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
factory(App\Models\Address::class, 30)->create();
}
}
+16
View File
@@ -0,0 +1,16 @@
<?php
use Illuminate\Database\Seeder;
class CompaniesTableSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
factory(App\Models\Company::class, 30)->create();
}
}
+16
View File
@@ -0,0 +1,16 @@
<?php
use Illuminate\Database\Seeder;
class ContactsTableSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
factory(App\Models\Contact::class, 30)->create();
}
}
+17
View File
@@ -0,0 +1,17 @@
<?php
use Illuminate\Database\Seeder;
class DatabaseSeeder extends Seeder
{
/**
* Seed the application's database.
*
* @return void
*/
public function run()
{
$this->call(UsersTableSeeder::class);
$this->call(CompaniesTableSeeder::class);
}
}
+41
View File
@@ -0,0 +1,41 @@
<?php
use App\Classes\ValueObjects\Constants\Roles;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Hash;
class UsersTableSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
DB::table('users')->insert([
[
'name' => 'Omair Saleh',
'email' => 'omair@izyim.com',
'password' => Hash::make('123456abcabc'),
'email_verified_at' => \Carbon\Carbon::now(),
'role_id' => Roles::SUPER_ADMIN,
'created_at' => \Carbon\Carbon::now(),
'updated_at' => \Carbon\Carbon::now()
],
[
'name' => 'Development User',
'email' => env('EMAIL_DEVELOPMENT', 'dev@izyim.com'),
'password' => Hash::make('123456abcabc'),
'email_verified_at' => \Carbon\Carbon::now(),
'role_id' => Roles::ADMIN,
'created_at' => \Carbon\Carbon::now(),
'updated_at' => \Carbon\Carbon::now()
]
]);
factory(App\Models\User::class, 30)->create();
}
}