php-soft/laravel-shopping-cart

Laravel Shopping Cart Module

dev-master / 1.0.x-dev 2016-02-23 14:40 UTC

This package is auto-updated.

Last update: 2024-10-21 19:37:42 UTC


README

Build Status

This is RESTful APIs

1. Installation

Install via composer - edit your composer.json to require the package.

"require": {
    // ...
    "php-soft/laravel-shopping-cart": "dev-master",
}

Then run composer update in your terminal to pull it in. Once this has finished, you will need to add the service provider to the providers array in your app.php config as follows:

'providers' => [
    // ...
    PhpSoft\ArrayView\Providers\ArrayViewServiceProvider::class,
    PhpSoft\ShoppingCart\Providers\ShoppingCartServiceProvider::class,
]

2. Migration and Seeding

Now generate the migration:

$ php artisan ps-shoppingcart:migrate

It will generate the migration files. You may now run it with the artisan migrate command:

$ php artisan migrate

Running Seeders with command:

$ php artisan db:seed --class=ShoppingCartModuleSeeder

3. Usage

Add routes in app/Http/routes.php

// categories resource
Route::get('categories', '\PhpSoft\ShoppingCart\Controllers\CategoryController@index');
Route::get('categories/{id}', '\PhpSoft\ShoppingCart\Controllers\CategoryController@show');
Route::group(['middleware'=>'auth'], function() { // use middleware jwt.auth if use JSON Web Token
    Route::post('categories', [
        'middleware' => 'permission:create-category',
        'uses' => '\PhpSoft\ShoppingCart\Controllers\CategoryController@store'
    ]);
    Route::put('categories/{id}', [
        'middleware' => 'permission:update-category',
        'uses' => '\PhpSoft\ShoppingCart\Controllers\CategoryController@update'
    ]);
    Route::delete('categories/{id}', [
        'middleware' => 'permission:delete-category',
        'uses' => '\PhpSoft\ShoppingCart\Controllers\CategoryController@destroy'
    ]);
});

Route::get('categories/{id}/products', '\PhpSoft\ShoppingCart\Controllers\ProductController@index');

// products resource
Route::get('products', '\PhpSoft\ShoppingCart\Controllers\ProductController@index');
Route::get('products/{id}', '\PhpSoft\ShoppingCart\Controllers\ProductController@show');
Route::group(['middleware'=>'auth'], function() { // use middleware jwt.auth if use JSON Web Token
    Route::post('products', [
        'middleware' => 'permission:create-product',
        'uses' => '\PhpSoft\ShoppingCart\Controllers\ProductController@store'
    ]);
    Route::put('products/{id}', [
        'middleware' => 'permission:update-product',
        'uses' => '\PhpSoft\ShoppingCart\Controllers\ProductController@update'
    ]);
    Route::delete('products/{id}', [
        'middleware' => 'permission:delete-product',
        'uses' => '\PhpSoft\ShoppingCart\Controllers\ProductController@destroy'
    ]);
});

You can remove middlewares if your application don't require check authenticate and permission!