php-soft / laravel-shopping-cart by huytbt

Laravel Shopping Cart Module
231
7
8
Package Data
Maintainer Username: huytbt
Maintainer Contact: huytbt@gmail.com (Huy Ta)
Package Create Date: 2015-07-16
Package Last Update: 2016-02-23
Language: PHP
License: MIT
Last Refreshed: 2024-12-14 15:12:38
Package Statistics
Total Downloads: 231
Monthly Downloads: 0
Daily Downloads: 0
Total Stars: 7
Total Watchers: 8
Total Forks: 2
Total Open Issues: 1

Laravel Shopping Cart Module

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!