# Ecommerce Multi Vendor
[<img src="https://e5he54pyft4.exactdn.com/wp-content/uploads/2020/02/tocaan.svg" width="200px" />](https://tocaan.com/en/)

- Ecommerce Multi Vendor is HMVC Laravel Project Can Be used For (Single or Multiple) Vendors
- Each Vendor has its own products 
- Supports multiple languages
- Supports multiple currencies

## HMVC Package

Please see [LARAVEL-MODULES](https://nwidart.com/laravel-modules/v6/introduction) for more information to create 
new Module or add new migrations files to specific Module

## Installation

You Should Follow These Steps :

1 - install Composer dependencies 

```bash
composer install
```

2 - To run all of your outstanding migrations, execute to migrate Artisan command:

```bash
php artisan migrate 
```

3 - Running Seeders Of All Modules

```bash
php artisan db:seed
```

4- create the symbolic link, you may use the storage:link Artisan command:

```bash
php artisan storage:link
```

5 - Deploying Passport
This command generates the encryption keys Passport needs in order to generate access tokens. The generated keys are not typically kept in source control:

```bash
php artisan passport:keys
```

## Admin Panel

after install you can open admin Panel with [/dashboard/login]()
 - Email : admin@admin.com 
 - Password : 123456

## Permissions And Roles
 - Create new Permission first with [/dashboard/permissions]()
 - Then Assign Permission to Specific Role By Editing Selected Role [/dashboard/roles]()
- Blade directives native @permission directive to check if a user has a certain permission (whether you gave them that permission directly or if you granted it indirectly via a role):

```bash
  @role('role_name') 
     <p>This is visible to users with the admin role. Gets translated to  \Entrust::role('admin')</p>
  @endrole
```
```bash
  @permission('permission_name') 
     <p>This is visible to users with the admin role. Gets translated to  \Entrust::role('admin')</p>
  @endpermission
```
```bash
@ability('admin,owner', 'create-post,edit-user')
    <p>This is visible to users with the given abilities. Gets translated to 
    \Entrust::ability('admin,owner', 'create-post,edit-user')</p>
@endability
```

- Middleware For checking against a single permission (see Best Practices) using can, you can use the built-in Laravel middleware provided by \Illuminate\Auth\Middleware\Authorize::class like this:
```bash
Route::group(['prefix' => 'admin', 'middleware' => ['role:admin']], function() {
    Route::get('/', 'AdminController@welcome');
    Route::get('/manage', ['middleware' => ['permission:manage-admins'], 'uses' => 'AdminController@manageAdmins']);
});
```
It is possible to use pipe symbol as OR operator:
```bash
'middleware' => ['role:admin|root']
```

To emulate AND functionality just use multiple instances of middleware

```bash
'middleware' => ['role:owner', 'role:writer']
```


For more complex situations use ability middleware which accepts 3 parameters: roles, permissions, validate_all

```bash
'middleware' => ['ability:admin|owner,create-post|edit-user,true']
```

to See available Middleware check app/Http/Kernel.php

```bash
    protected $routeMiddleware = [
        'role' => \App\Entrust\Middleware\EntrustRole::class,
        'permission' => \App\Entrust\Middleware\EntrustPermission::class,
        'ability' => \App\Entrust\Middleware\EntrustAbility::class, ,
    ];
```

## General Setting
Control General system Setting [/dashboard/setting]()

-- Usage
```bash
Setting::get('name');
// get setting value with key 'name'
// If this key is not found in DB then it will return the value defined from the config file or null if the key is also not defined in the config file.

Setting::get('name', 'Joe');
// get setting value with key 'name'
// return 'Joe' if the key does not exists. This will overwrite the default coming from the config file.

Setting::all();
// get all settings.
// This will merge the setting.php config file with the values (only where lang is null) found in the database and returns a collection.

Setting::lang('zh-TW')->get('name', 'Joe');
// get setting value with key and language

Setting::set('name', 'Joe');
// set setting value by key

Setting::lang('zh-TW')->set('name', 'Joe');
// set setting value by key and language

Setting::has('name');
// check the key exists in database, return boolean

Setting::lang('zh-TW')->has('name');
// check the key exists by language in database, return boolean

Setting::forget('name');
// delete the setting from database by key

Setting::lang('zh-TW')->forget('name');
// delete the setting from database by key and language
```


## Laravel Telescope

to enable Laravel Telescope please add in .env file
```bash
TELESCOPE_ENABLED=true
```

## Enable Forget Password routes 

to enable  forget password routes please add in .env file
```bash
PASSWORD=true
```

## Enable Registration routes

to enable Registration routes please add in .env file
```bash
REGISTER=true
```

## Enable Login routes

to enable LOGIN routes please add in .env file
```bash
LOGIN=true
```

## Testing

```bash
composer test
```

## Changelog

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

## Contributing

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

## Security Vulnerabilities

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.


## License

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.
