2017 © Pedro Peláez
 

library laravel-ecommerce

A laravel ecommerce solution.

image

chrisbraybrooke/laravel-ecommerce

A laravel ecommerce solution.

  • Friday, July 27, 2018
  • by ChrisBraybrooke
  • Repository
  • 1 Watchers
  • 0 Stars
  • 101 Installations
  • Vue
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 43 Versions
  • 49 % Grown

The README.md

Laravel ECommerce Package

Laravel Setup

laravel new laravel-shop
php artisan make:auth

Installation

Only installation on a fresh Laravel app is reccomended:, (*1)

composer require chrisbraybrooke/laravel-ecommerce

Setup:

php artisan vendor:publish --tag=migrations

php artisan vendor:publish --tag=ecommerce-config
php artisan vendor:publish --tag=ecommerce-migrations
php artisan vendor:publish --tag=ecommerce-admin

php artisan migrate

Roles And Permissions:

php artisan vendor:publish --tag=ecommerce-seeds

In database/seeds/DatabaseSeeder.php add the RolesAndPermissionsSeeder class, (*2)

use Illuminate\Database\Seeder;

class DatabaseSeeder extends Seeder
{
    /**
     * Seed the application's database.
     *
     * @return void
     */
    public function run()
    {
        // $this->call(UsersTableSeeder::class);
        $this->call(RolesAndPermissionsSeeder::class)
    }
}

And then seed the database, (*3)

php artisan migrate --seed

Media:

php artisan vendor:publish --tag=config

After publishing the config files, be sure to change the media class to ChrisBraybrooke\ECommerce\Models\Media, (*4)

/*
 * The class name of the media model that should be used.
 */
 'media_model' => ChrisBraybrooke\ECommerce\Models\Media::class,

Users:

To ensure all roles / permissions work correctly, you will need to edit your App/User.php class so that it extends the Laravel Ecommerce User class., (*5)

use Illuminate\Notifications\Notifiable;
use ChrisBraybrooke\ECommerce\Models\User as Authenticatable;

class User extends Authenticatable
{
    use Notifiable;
}

You will then want to create your first admin user., (*6)

php artisan tinker

$user = new App\User
$user->name = 'Your Name'
$user->email = 'youremail@here.com'
$user->password = bcrypt('password')

$user->save()

$user->assignRole('admin')

We use Laravel Passport under the hood, so make sure you install passport to generate the relevent keys etc., (*7)

php artisan passport:install

You then need to add this middleware to your app/Http/Kernel.php web group. Make sure it is added after the \App\Http\Middleware\EncryptCookies::class middleware., (*8)

'web' => [
    // Other middleware...
    \Laravel\Passport\Http\Middleware\CreateFreshApiToken::class,
],

Finally in your config/auth.php config file, you should set the API driver to passport., (*9)

'guards' => [
    'web' => [
        'driver' => 'session',
        'provider' => 'users',
    ],

    'api' => [
        'driver' => 'passport',
        'provider' => 'users',
    ],
],

Updating the version

It's a good idea to keep the version numbering up-to-date with any minor and major changes that are made to avoid conflicts with older code. This package uses seperate version numbers for its API and SPA functions., (*10)

The API version number can be found and changed under src/ECommerceServiceProvider.php And the SPA version number can be found and changed under resources/assets/admin-spa/admin.js (this one will require compiling)., (*11)

The Versions