mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange.git
synced 2026-08-19 04:14:04 +00:00
merge master
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
use Faker\Generator as Faker;
|
||||
|
||||
$factory->define(App\ChinaBankSlip::class, function (Faker $faker) {
|
||||
return [
|
||||
//
|
||||
];
|
||||
});
|
||||
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
use Faker\Generator as Faker;
|
||||
|
||||
$factory->define(App\Rate::class, function (Faker $faker) {
|
||||
return [
|
||||
//
|
||||
];
|
||||
});
|
||||
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
use Faker\Generator as Faker;
|
||||
|
||||
$factory->define(App\SettingBeneficiary::class, function (Faker $faker) {
|
||||
return [
|
||||
//
|
||||
];
|
||||
});
|
||||
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
use Faker\Generator as Faker;
|
||||
|
||||
$factory->define(App\SettingCredit::class, function (Faker $faker) {
|
||||
return [
|
||||
//
|
||||
];
|
||||
});
|
||||
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
use Faker\Generator as Faker;
|
||||
|
||||
$factory->define(App\SettingSupplier::class, function (Faker $faker) {
|
||||
return [
|
||||
//
|
||||
];
|
||||
});
|
||||
@@ -14,10 +14,12 @@ use Faker\Generator as Faker;
|
||||
*/
|
||||
|
||||
$factory->define(App\User::class, function (Faker $faker) {
|
||||
static $password;
|
||||
|
||||
return [
|
||||
'name' => $faker->name,
|
||||
'email' => $faker->unique()->safeEmail,
|
||||
'password' => '$2y$10$TKh8H1.PfQx37YgCzwiKb.KjNyWgaHb9cbcoQgdIVFlYg7B77UdFm', // secret
|
||||
'password' => $password ?: $password = bcrypt('secret'),
|
||||
'remember_token' => str_random(10),
|
||||
];
|
||||
});
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class CreateOauthProvidersTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('oauth_providers', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('user_id')->unsigned();
|
||||
$table->string('provider');
|
||||
$table->string('provider_user_id')->index();
|
||||
$table->string('access_token')->nullable();
|
||||
$table->string('refresh_token')->nullable();
|
||||
$table->timestamps();
|
||||
|
||||
$table->foreign('user_id')
|
||||
->references('id')
|
||||
->on('users')
|
||||
->onDelete('cascade');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('oauth_providers');
|
||||
}
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class CreateUserVerificationsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('user_verifications', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('user_id')->unsigned();
|
||||
$table->string('token');
|
||||
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
|
||||
});
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->boolean('is_verified')->default(0);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists("user_verifications");
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->dropColumn('is_verified');
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class CreateRatesTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('rates', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->double('x1_cash');
|
||||
$table->double('x1_cheque');
|
||||
$table->double('x1_ba');
|
||||
$table->double('x2_cash');
|
||||
$table->double('x2_cheque');
|
||||
$table->double('x2_ba');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('rates');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class CreateSettingCreditsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('setting_credits', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->decimal('rmb_credit_limit');
|
||||
$table->decimal('usd_credit_limit');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('setting_credits');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class CreateSettingSuppliersTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('setting_suppliers', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->string('company_name');
|
||||
$table->string('gst_no');
|
||||
$table->string('supplier_reg_no');
|
||||
$table->string('bank_name');
|
||||
$table->string('acc_no');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('setting_suppliers');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class CreateSettingBeneficiariesTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('setting_beneficiaries', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->string('company_name');
|
||||
$table->string('bank_name');
|
||||
$table->string('acc_no');
|
||||
$table->string('bank_address');
|
||||
$table->string('swift');
|
||||
$table->string('cnap');
|
||||
$table->string('bank_branch');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('setting_beneficiaries');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
class EntrustSetupTables extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
DB::beginTransaction();
|
||||
|
||||
// Create table for storing roles
|
||||
Schema::create('roles', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->string('name')->unique();
|
||||
$table->string('display_name')->nullable();
|
||||
$table->string('description')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
// Create table for associating roles to users (Many-to-Many)
|
||||
Schema::create('role_user', function (Blueprint $table) {
|
||||
$table->integer('user_id')->unsigned();
|
||||
$table->integer('role_id')->unsigned();
|
||||
|
||||
$table->foreign('user_id')->references('id')->on('users')
|
||||
->onUpdate('cascade')->onDelete('cascade');
|
||||
$table->foreign('role_id')->references('id')->on('roles')
|
||||
->onUpdate('cascade')->onDelete('cascade');
|
||||
|
||||
$table->primary(['user_id', 'role_id']);
|
||||
});
|
||||
|
||||
// Create table for storing permissions
|
||||
Schema::create('permissions', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->string('name')->unique();
|
||||
$table->string('display_name')->nullable();
|
||||
$table->string('description')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
// Create table for associating permissions to roles (Many-to-Many)
|
||||
Schema::create('permission_role', function (Blueprint $table) {
|
||||
$table->integer('permission_id')->unsigned();
|
||||
$table->integer('role_id')->unsigned();
|
||||
|
||||
$table->foreign('permission_id')->references('id')->on('permissions')
|
||||
->onUpdate('cascade')->onDelete('cascade');
|
||||
$table->foreign('role_id')->references('id')->on('roles')
|
||||
->onUpdate('cascade')->onDelete('cascade');
|
||||
|
||||
$table->primary(['permission_id', 'role_id']);
|
||||
});
|
||||
|
||||
DB::commit();
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::drop('permission_role');
|
||||
Schema::drop('permissions');
|
||||
Schema::drop('role_user');
|
||||
Schema::drop('roles');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class CreateChinaBankSlipsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('china_bank_slips', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->string('bompany_name');
|
||||
$table->string('bank_name');
|
||||
$table->string('acc_no');
|
||||
$table->string('bank_address');
|
||||
$table->string('swift');
|
||||
$table->string('cnap');
|
||||
$table->string('bank _branch');
|
||||
$table->string('order_id');
|
||||
$table->double('transfer_amount_needed');
|
||||
$table->double('actual_transfer_amount');
|
||||
$table->string('date');
|
||||
$table->string('details');
|
||||
$table->string('bankslip_url');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('china_bank_slips');
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,9 @@ class DatabaseSeeder extends Seeder
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
// $this->call(UsersTableSeeder::class);
|
||||
$this->call(UsersTableSeeder::class);
|
||||
$this->call(RolesAndPermissionsSeeder::class);
|
||||
$this->call(RateTableSeeder::class);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class RateTableSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
DB::table('rates')->insert([
|
||||
'x1_cash' => 1.2,
|
||||
'x1_cheque' => 1.2,
|
||||
'x1_ba' => 1.2,
|
||||
'x2_cash' => 1.2,
|
||||
'x2_cheque' => 1.2,
|
||||
'x2_ba' => 1.2,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,189 @@
|
||||
<?php
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Roles & Permissions Seeder
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This Seeder class allows you to update and create Roles & Permissions
|
||||
| for the Laravel Entrust package.
|
||||
|
|
||||
| USE -> php artisan db:seed --class=RolesAndPermissionsSeeder
|
||||
|
|
||||
| https://github.com/thomasfw/RolesAndPermissionsSeeder
|
||||
|
|
||||
|--------------------------------------------------------------------------
|
||||
| Make sure you update the namespaces for your User & Entrust models
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
use App\User as User;
|
||||
use App\Role as Role;
|
||||
use App\Permission as Permission;
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
class RolesAndPermissionsSeeder extends Seeder {
|
||||
protected $roles = [
|
||||
|
||||
'admin' => [
|
||||
],
|
||||
|
||||
'member' => [
|
||||
],
|
||||
|
||||
|
||||
|
||||
];
|
||||
|
||||
|
||||
protected $permissions = [
|
||||
|
||||
// Add your Permissions here
|
||||
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* Roles
|
||||
*
|
||||
* @return array()
|
||||
*/
|
||||
public function roles()
|
||||
{
|
||||
return $this->roles;
|
||||
}
|
||||
|
||||
/**
|
||||
* Permissions
|
||||
*
|
||||
* @param $name
|
||||
* @return array()
|
||||
*/
|
||||
public function permissions($name = '')
|
||||
{
|
||||
$single = (array_key_exists($name,$this->permissions) ? array($name =>$this->permissions[$name]) : false );
|
||||
return ($name ? $single : $this->permissions);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Run the Seeder
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
DB::table(Config::get('entrust.permissions_table'))->delete();
|
||||
|
||||
foreach ($this->roles() as $key => $val) {
|
||||
$this->command->info(" ");
|
||||
$this->command->info('Creating/updating the \''.$key.'\' role');
|
||||
$this->command->info('-----------------------------------------');
|
||||
$val['name'] = $key;
|
||||
$this->reset($val);
|
||||
}
|
||||
$this->cleanup();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Reset Role, Permissions & Users
|
||||
*
|
||||
* @param $role
|
||||
* @return void
|
||||
*/
|
||||
public function reset($role)
|
||||
{
|
||||
$commandBullet = ' -> ';
|
||||
|
||||
// The Old Role
|
||||
$originalRole = Role::where('name',$role['name'])->first();
|
||||
if($originalRole) Role::where('id',$originalRole->id)->update(['name' => $role['name'].'__remove']);
|
||||
|
||||
// The New Role
|
||||
$newRole = new Role();
|
||||
$newRole->name = $role['name'];
|
||||
if(isset($role['display_name'])) $newRole->display_name = $role['display_name']; // optional
|
||||
if(isset($role['description'])) $newRole->description = $role['description']; // optional
|
||||
$newRole->save();
|
||||
$this->command->info($commandBullet."Created $role[name] role");
|
||||
|
||||
// Set the Permissions (if they exist)
|
||||
$pcount = 0;
|
||||
if(!empty($role['permissions']))
|
||||
{
|
||||
foreach ($role['permissions'] as $permission_name) {
|
||||
|
||||
$permission = $this->permissions($permission_name);
|
||||
if($permission === false || (!$permission_name)) {
|
||||
$this->command->error($commandBullet."Failed to attach permission '$permission_name'. It does not exist");
|
||||
continue;
|
||||
}
|
||||
|
||||
$newPermission = \Permission::where('name',$permission_name)->first();
|
||||
if (!$newPermission) {
|
||||
$newPermission = new Permission();
|
||||
$newPermission->name = key($permission);
|
||||
if(isset($permission['display_name'])) $newPermission->display_name = $permission['display_name']; // optional
|
||||
if(isset($permission['description'])) $newPermission->description = $permission['description']; // optional
|
||||
$newPermission->save();
|
||||
}
|
||||
$newRole->attachPermission($newPermission);
|
||||
$pcount++;
|
||||
}
|
||||
}
|
||||
$this->command->info($commandBullet."Attached $pcount permissions to $role[name] role");
|
||||
|
||||
// Update old records
|
||||
if ($originalRole)
|
||||
{
|
||||
$userCount = 0;
|
||||
$RoleUsers = DB::table(Config::get('entrust.role_user_table'))->where('role_id',$originalRole->id)->get();
|
||||
foreach ($RoleUsers as $user) {
|
||||
$u = User::where('id',$user->user_id)->first();
|
||||
$u->attachRole($newRole);
|
||||
$userCount++;
|
||||
}
|
||||
$this->command->info($commandBullet."Updated role attachment for $userCount users");
|
||||
|
||||
Role::where('id',$originalRole->id)->delete(); // will also remove old role_user records
|
||||
$this->command->info($commandBullet."Removed the original $role[name] role");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Cleanup()
|
||||
* Remove any roles & permissions that have been removed
|
||||
* @return void
|
||||
*/
|
||||
public function cleanup()
|
||||
{
|
||||
$commandBullet = ' -> ';
|
||||
$this->command->info(" ");
|
||||
$this->command->info('Cleaning up roles & permissions:');
|
||||
$this->command->info('--------------------------------');
|
||||
|
||||
$storedRoles = Role::all();
|
||||
if(!empty($storedRoles)) {
|
||||
$definedRoles = $this->roles();
|
||||
foreach ($storedRoles as $role) {
|
||||
if ( !array_key_exists($role->name,$definedRoles) ) {
|
||||
Role::where('name',$role->name)->delete();
|
||||
$this->command->info($commandBullet.'The \''.$role->name.'\' role was removed');
|
||||
}
|
||||
}
|
||||
}
|
||||
$storedPerms = DB::table(Config::get('entrust.permissions_table'))->get();
|
||||
if(!empty($storedPerms)) {
|
||||
$definedPerms = $this->permissions();
|
||||
foreach ($storedPerms as $perm) {
|
||||
if ( !array_key_exists($perm->name,$definedPerms) ) {
|
||||
DB::table(Config::get('entrust.permissions_table'))->where('name',$perm->name)->delete();
|
||||
$this->command->info($commandBullet.'The \''.$perm->name.'\' permission was removed');
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->command->info($commandBullet.'Done');
|
||||
$this->command->info(" ");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
use App\User;
|
||||
|
||||
class UsersTableSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
DB::table('users')->delete();
|
||||
|
||||
$users = array(
|
||||
['name' => 'Ryan Chenkie', 'email' => 'ryanchenkie@gmail.com', 'password' => Hash::make('secret')],
|
||||
['name' => 'Chris Sevilleja', 'email' => 'chris@scotch.io', 'password' => Hash::make('secret')],
|
||||
['name' => 'Holly Lloyd', 'email' => 'holly@scotch.io', 'password' => Hash::make('secret')],
|
||||
['name' => 'Adnan Kukic', 'email' => 'adnan@scotch.io', 'password' => Hash::make('secret')],
|
||||
);
|
||||
|
||||
foreach ($users as $user)
|
||||
{
|
||||
User::create($user);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user