first upload all files
This commit is contained in:
13
Modules/User/Database/Factories/ModelFactory.php
Normal file
13
Modules/User/Database/Factories/ModelFactory.php
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
use Faker\Generator;
|
||||
use Modules\User\Entities\User;
|
||||
|
||||
$factory->define(User::class, function (Generator $faker) {
|
||||
return [
|
||||
'first_name' => $faker->firstName,
|
||||
'last_name' => $faker->lastName,
|
||||
'email' => $faker->safeEmail,
|
||||
'password' => bcrypt(123456),
|
||||
];
|
||||
});
|
||||
@@ -0,0 +1,128 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Part of the Sentinel package.
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* Licensed under the 3-clause BSD License.
|
||||
*
|
||||
* This source file is subject to the 3-clause BSD License that is
|
||||
* bundled with this package in the LICENSE file.
|
||||
*
|
||||
* @package Sentinel
|
||||
* @version 2.0.12
|
||||
* @author Cartalyst LLC
|
||||
* @license BSD License (3-clause)
|
||||
* @copyright (c) 2011-2015, Cartalyst LLC
|
||||
* @link http://cartalyst.com
|
||||
*/
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class MigrationCartalystSentinel extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('users', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->string('first_name');
|
||||
$table->string('last_name');
|
||||
$table->string('email')->unique();
|
||||
$table->string('password');
|
||||
$table->text('permissions')->nullable();
|
||||
$table->datetime('last_login')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
Schema::create('roles', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->text('permissions')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
Schema::create('role_translations', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('role_id')->unsigned();
|
||||
$table->string('locale');
|
||||
$table->string('name');
|
||||
|
||||
$table->unique(['role_id', 'locale']);
|
||||
$table->foreign('role_id')->references('id')->on('roles')->onDelete('cascade');
|
||||
});
|
||||
|
||||
Schema::create('user_roles', function (Blueprint $table) {
|
||||
$table->integer('user_id')->unsigned();
|
||||
$table->integer('role_id')->unsigned();
|
||||
$table->timestamps();
|
||||
|
||||
$table->primary(['user_id', 'role_id']);
|
||||
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
|
||||
$table->foreign('role_id')->references('id')->on('roles')->onDelete('cascade');
|
||||
});
|
||||
|
||||
Schema::create('activations', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('user_id')->unsigned()->index();
|
||||
$table->string('code');
|
||||
$table->boolean('completed')->default(false);
|
||||
$table->datetime('completed_at')->nullable();
|
||||
$table->timestamps();
|
||||
|
||||
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
|
||||
});
|
||||
|
||||
Schema::create('persistences', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('user_id')->unsigned();
|
||||
$table->string('code')->unique();
|
||||
$table->timestamps();
|
||||
|
||||
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
|
||||
});
|
||||
|
||||
Schema::create('reminders', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('user_id')->unsigned();
|
||||
$table->string('code');
|
||||
$table->boolean('completed')->default(false);
|
||||
$table->datetime('completed_at')->nullable();
|
||||
$table->timestamps();
|
||||
|
||||
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
|
||||
});
|
||||
|
||||
Schema::create('throttle', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('user_id')->unsigned()->nullable();
|
||||
$table->string('type');
|
||||
$table->string('ip')->nullable();
|
||||
$table->timestamps();
|
||||
|
||||
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('throttle');
|
||||
Schema::dropIfExists('reminders');
|
||||
Schema::dropIfExists('persistences');
|
||||
Schema::dropIfExists('activations');
|
||||
Schema::dropIfExists('user_roles');
|
||||
Schema::dropIfExists('role_translations');
|
||||
Schema::dropIfExists('roles');
|
||||
Schema::dropIfExists('users');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class AddPhoneColumnToUsersTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->string('phone')->after('email');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->dropColumn('phone');
|
||||
});
|
||||
}
|
||||
}
|
||||
146
Modules/User/Database/Seeders/RolesTableSeeder.php
Normal file
146
Modules/User/Database/Seeders/RolesTableSeeder.php
Normal file
@@ -0,0 +1,146 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\User\Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
use Modules\User\Entities\Role;
|
||||
|
||||
class RolesTableSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
Role::create(['name' => 'Admin', 'permissions' => $this->getAdminRolePermissions()]);
|
||||
|
||||
Role::create(['name' => 'Customer']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get admin role permissions.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function getAdminRolePermissions()
|
||||
{
|
||||
return [
|
||||
// users
|
||||
'admin.users.index' => true,
|
||||
'admin.users.create' => true,
|
||||
'admin.users.edit' => true,
|
||||
'admin.users.destroy' => true,
|
||||
// roles
|
||||
'admin.roles.index' => true,
|
||||
'admin.roles.create' => true,
|
||||
'admin.roles.edit' => true,
|
||||
'admin.roles.destroy' => true,
|
||||
// products
|
||||
'admin.products.index' => true,
|
||||
'admin.products.create' => true,
|
||||
'admin.products.edit' => true,
|
||||
'admin.products.destroy' => true,
|
||||
// brands
|
||||
'admin.brands.index' => true,
|
||||
'admin.brands.create' => true,
|
||||
'admin.brands.edit' => true,
|
||||
'admin.brands.destroy' => true,
|
||||
// attributes
|
||||
'admin.attributes.index' => true,
|
||||
'admin.attributes.create' => true,
|
||||
'admin.attributes.edit' => true,
|
||||
'admin.attributes.destroy' => true,
|
||||
// attribute sets
|
||||
'admin.attribute_sets.index' => true,
|
||||
'admin.attribute_sets.create' => true,
|
||||
'admin.attribute_sets.edit' => true,
|
||||
'admin.attribute_sets.destroy' => true,
|
||||
// options
|
||||
'admin.options.index' => true,
|
||||
'admin.options.create' => true,
|
||||
'admin.options.edit' => true,
|
||||
'admin.options.destroy' => true,
|
||||
// filters
|
||||
'admin.filters.index' => true,
|
||||
'admin.filters.create' => true,
|
||||
'admin.filters.edit' => true,
|
||||
'admin.filters.destroy' => true,
|
||||
// reviews
|
||||
'admin.reviews.index' => true,
|
||||
'admin.reviews.create' => true,
|
||||
'admin.reviews.edit' => true,
|
||||
'admin.reviews.destroy' => true,
|
||||
// categories
|
||||
'admin.categories.index' => true,
|
||||
'admin.categories.create' => true,
|
||||
'admin.categories.edit' => true,
|
||||
'admin.categories.destroy' => true,
|
||||
// tags
|
||||
'admin.tags.index' => true,
|
||||
'admin.tags.create' => true,
|
||||
'admin.tags.edit' => true,
|
||||
'admin.tags.destroy' => true,
|
||||
// orders
|
||||
'admin.orders.index' => true,
|
||||
'admin.orders.show' => true,
|
||||
'admin.orders.edit' => true,
|
||||
// flash sales
|
||||
'admin.flash_sales.index' => true,
|
||||
'admin.flash_sales.create' => true,
|
||||
'admin.flash_sales.edit' => true,
|
||||
'admin.flash_sales.destroy' => true,
|
||||
// transactions
|
||||
'admin.transactions.index' => true,
|
||||
// coupons
|
||||
'admin.coupons.index' => true,
|
||||
'admin.coupons.create' => true,
|
||||
'admin.coupons.edit' => true,
|
||||
'admin.coupons.destroy' => true,
|
||||
// menus
|
||||
'admin.menus.index' => true,
|
||||
'admin.menus.create' => true,
|
||||
'admin.menus.edit' => true,
|
||||
'admin.menus.destroy' => true,
|
||||
'admin.menu_items.index' => true,
|
||||
'admin.menu_items.create' => true,
|
||||
'admin.menu_items.edit' => true,
|
||||
'admin.menu_items.destroy' => true,
|
||||
// Media
|
||||
'admin.media.index' => true,
|
||||
'admin.media.create' => true,
|
||||
'admin.media.destroy' => true,
|
||||
// pages
|
||||
'admin.pages.index' => true,
|
||||
'admin.pages.create' => true,
|
||||
'admin.pages.edit' => true,
|
||||
'admin.pages.destroy' => true,
|
||||
// currency rates
|
||||
'admin.currency_rates.index' => true,
|
||||
'admin.currency_rates.edit' => true,
|
||||
// tax
|
||||
'admin.taxes.index' => true,
|
||||
'admin.taxes.create' => true,
|
||||
'admin.taxes.edit' => true,
|
||||
'admin.taxes.destroy' => true,
|
||||
// translations
|
||||
'admin.translations.index' => true,
|
||||
'admin.translations.edit' => true,
|
||||
// appearance
|
||||
'admin.sliders.index' => true,
|
||||
'admin.sliders.create' => true,
|
||||
'admin.sliders.edit' => true,
|
||||
'admin.sliders.destroy' => true,
|
||||
// import
|
||||
'admin.importer.index' => true,
|
||||
'admin.importer.create' => true,
|
||||
// reports
|
||||
'admin.reports.index' => true,
|
||||
// settings
|
||||
'admin.settings.edit' => true,
|
||||
// storefront
|
||||
'admin.storefront.edit' => true,
|
||||
];
|
||||
}
|
||||
}
|
||||
19
Modules/User/Database/Seeders/UserDatabaseSeeder.php
Normal file
19
Modules/User/Database/Seeders/UserDatabaseSeeder.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\User\Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class UserDatabaseSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
$this->call(RolesTableSeeder::class);
|
||||
$this->call(UsersTableSeeder::class);
|
||||
}
|
||||
}
|
||||
33
Modules/User/Database/Seeders/UsersTableSeeder.php
Normal file
33
Modules/User/Database/Seeders/UsersTableSeeder.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\User\Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
use Modules\User\Entities\Role;
|
||||
use Modules\User\Entities\User;
|
||||
use Cartalyst\Sentinel\Laravel\Facades\Activation;
|
||||
|
||||
class UsersTableSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
$adminRole = Role::find(1);
|
||||
|
||||
$envaySoft = User::create([
|
||||
'first_name' => 'Envay',
|
||||
'last_name' => 'Soft',
|
||||
'email' => 'envaysoft@gmail.com',
|
||||
'password' => bcrypt(123456),
|
||||
]);
|
||||
|
||||
$activation = Activation::create($envaySoft);
|
||||
Activation::complete($envaySoft, $activation->code);
|
||||
|
||||
$adminRole->users()->attach($envaySoft);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user