parent
91dd62561e
commit
be3e29aa5b
33 changed files with 378 additions and 1 deletions
@ -0,0 +1,5 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
return [ |
||||||
|
'name' => 'Agents' |
||||||
|
]; |
@ -0,0 +1,21 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace Modules\Agents\Database\Seeders; |
||||||
|
|
||||||
|
use Illuminate\Database\Seeder; |
||||||
|
use Illuminate\Database\Eloquent\Model; |
||||||
|
|
||||||
|
class AgentsDatabaseSeeder extends Seeder |
||||||
|
{ |
||||||
|
/** |
||||||
|
* Run the database seeds. |
||||||
|
* |
||||||
|
* @return void |
||||||
|
*/ |
||||||
|
public function run() |
||||||
|
{ |
||||||
|
Model::unguard(); |
||||||
|
|
||||||
|
// $this->call("OthersTableSeeder"); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,16 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace Modules\Agents\Http\Controllers; |
||||||
|
|
||||||
|
use Illuminate\Contracts\Support\Renderable; |
||||||
|
use Illuminate\Http\Request; |
||||||
|
use Illuminate\Foundation\Bus\DispatchesJobs; |
||||||
|
use Illuminate\Foundation\Validation\ValidatesRequests; |
||||||
|
use Illuminate\Routing\Controller as BaseController; |
||||||
|
|
||||||
|
class AgentActionApi extends BaseController |
||||||
|
{ |
||||||
|
public function addCustomer(Request $request){ |
||||||
|
dd(12222); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,17 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace Modules\Agents\Http\Controllers; |
||||||
|
|
||||||
|
use Illuminate\Contracts\Support\Renderable; |
||||||
|
use Illuminate\Http\Request; |
||||||
|
use Illuminate\Foundation\Bus\DispatchesJobs; |
||||||
|
use Illuminate\Foundation\Validation\ValidatesRequests; |
||||||
|
use Illuminate\Routing\Controller as BaseController; |
||||||
|
|
||||||
|
class AgentController extends BaseController |
||||||
|
{ |
||||||
|
use DispatchesJobs, ValidatesRequests; |
||||||
|
public function index(Request $request){ |
||||||
|
dd("Running........."); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,114 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace Modules\Agents\Providers; |
||||||
|
|
||||||
|
use Illuminate\Support\ServiceProvider; |
||||||
|
use Illuminate\Database\Eloquent\Factory; |
||||||
|
|
||||||
|
class AgentsServiceProvider extends ServiceProvider |
||||||
|
{ |
||||||
|
/** |
||||||
|
* @var string $moduleName |
||||||
|
*/ |
||||||
|
protected $moduleName = 'Agents'; |
||||||
|
|
||||||
|
/** |
||||||
|
* @var string $moduleNameLower |
||||||
|
*/ |
||||||
|
protected $moduleNameLower = 'agents'; |
||||||
|
|
||||||
|
/** |
||||||
|
* Boot the application events. |
||||||
|
* |
||||||
|
* @return void |
||||||
|
*/ |
||||||
|
public function boot() |
||||||
|
{ |
||||||
|
$this->registerTranslations(); |
||||||
|
$this->registerConfig(); |
||||||
|
$this->registerViews(); |
||||||
|
$this->loadMigrationsFrom(module_path($this->moduleName, 'Database/Migrations')); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Register the service provider. |
||||||
|
* |
||||||
|
* @return void |
||||||
|
*/ |
||||||
|
public function register() |
||||||
|
{ |
||||||
|
$this->app->register(RouteServiceProvider::class); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Register config. |
||||||
|
* |
||||||
|
* @return void |
||||||
|
*/ |
||||||
|
protected function registerConfig() |
||||||
|
{ |
||||||
|
$this->publishes([ |
||||||
|
module_path($this->moduleName, 'Config/config.php') => config_path($this->moduleNameLower . '.php'), |
||||||
|
], 'config'); |
||||||
|
$this->mergeConfigFrom( |
||||||
|
module_path($this->moduleName, 'Config/config.php'), $this->moduleNameLower |
||||||
|
); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Register views. |
||||||
|
* |
||||||
|
* @return void |
||||||
|
*/ |
||||||
|
public function registerViews() |
||||||
|
{ |
||||||
|
$viewPath = resource_path('views/modules/' . $this->moduleNameLower); |
||||||
|
|
||||||
|
$sourcePath = module_path($this->moduleName, 'Resources/views'); |
||||||
|
|
||||||
|
$this->publishes([ |
||||||
|
$sourcePath => $viewPath |
||||||
|
], ['views', $this->moduleNameLower . '-module-views']); |
||||||
|
|
||||||
|
$this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Register translations. |
||||||
|
* |
||||||
|
* @return void |
||||||
|
*/ |
||||||
|
public function registerTranslations() |
||||||
|
{ |
||||||
|
$langPath = resource_path('lang/modules/' . $this->moduleNameLower); |
||||||
|
|
||||||
|
if (is_dir($langPath)) { |
||||||
|
$this->loadTranslationsFrom($langPath, $this->moduleNameLower); |
||||||
|
$this->loadJsonTranslationsFrom($langPath, $this->moduleNameLower); |
||||||
|
} else { |
||||||
|
$this->loadTranslationsFrom(module_path($this->moduleName, 'Resources/lang'), $this->moduleNameLower); |
||||||
|
$this->loadJsonTranslationsFrom(module_path($this->moduleName, 'Resources/lang'), $this->moduleNameLower); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Get the services provided by the provider. |
||||||
|
* |
||||||
|
* @return array |
||||||
|
*/ |
||||||
|
public function provides() |
||||||
|
{ |
||||||
|
return []; |
||||||
|
} |
||||||
|
|
||||||
|
private function getPublishableViewPaths(): array |
||||||
|
{ |
||||||
|
$paths = []; |
||||||
|
foreach (\Config::get('view.paths') as $path) { |
||||||
|
if (is_dir($path . '/modules/' . $this->moduleNameLower)) { |
||||||
|
$paths[] = $path . '/modules/' . $this->moduleNameLower; |
||||||
|
} |
||||||
|
} |
||||||
|
return $paths; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,69 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace Modules\Agents\Providers; |
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Route; |
||||||
|
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider; |
||||||
|
|
||||||
|
class RouteServiceProvider extends ServiceProvider |
||||||
|
{ |
||||||
|
/** |
||||||
|
* The module namespace to assume when generating URLs to actions. |
||||||
|
* |
||||||
|
* @var string |
||||||
|
*/ |
||||||
|
protected $moduleNamespace = 'Modules\Agents\Http\Controllers'; |
||||||
|
|
||||||
|
/** |
||||||
|
* Called before routes are registered. |
||||||
|
* |
||||||
|
* Register any model bindings or pattern based filters. |
||||||
|
* |
||||||
|
* @return void |
||||||
|
*/ |
||||||
|
public function boot() |
||||||
|
{ |
||||||
|
parent::boot(); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Define the routes for the application. |
||||||
|
* |
||||||
|
* @return void |
||||||
|
*/ |
||||||
|
public function map() |
||||||
|
{ |
||||||
|
$this->mapApiRoutes(); |
||||||
|
|
||||||
|
$this->mapWebRoutes(); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Define the "web" routes for the application. |
||||||
|
* |
||||||
|
* These routes all receive session state, CSRF protection, etc. |
||||||
|
* |
||||||
|
* @return void |
||||||
|
*/ |
||||||
|
protected function mapWebRoutes() |
||||||
|
{ |
||||||
|
Route::middleware('web') |
||||||
|
->namespace($this->moduleNamespace) |
||||||
|
->group(module_path('Agents', '/Routes/web.php')); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Define the "api" routes for the application. |
||||||
|
* |
||||||
|
* These routes are typically stateless. |
||||||
|
* |
||||||
|
* @return void |
||||||
|
*/ |
||||||
|
protected function mapApiRoutes() |
||||||
|
{ |
||||||
|
Route::prefix('api') |
||||||
|
->middleware('api') |
||||||
|
->namespace($this->moduleNamespace) |
||||||
|
->group(module_path('Agents', '/Routes/api.php')); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,9 @@ |
|||||||
|
@extends('api::layouts.master') |
||||||
|
|
||||||
|
@section('content') |
||||||
|
<h1>Hello World</h1> |
||||||
|
|
||||||
|
<p> |
||||||
|
This view is loaded from module: {!! config('api.name') !!} |
||||||
|
</p> |
||||||
|
@endsection |
@ -0,0 +1,19 @@ |
|||||||
|
<!DOCTYPE html> |
||||||
|
<html lang="en"> |
||||||
|
<head> |
||||||
|
<meta charset="utf-8"> |
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge"> |
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1"> |
||||||
|
<title>Module API</title> |
||||||
|
|
||||||
|
{{-- Laravel Vite - CSS File --}} |
||||||
|
{{-- {{ module_vite('build-api', 'Resources/assets/sass/app.scss') }} --}} |
||||||
|
|
||||||
|
</head> |
||||||
|
<body> |
||||||
|
@yield('content') |
||||||
|
|
||||||
|
{{-- Laravel Vite - JS File --}} |
||||||
|
{{-- {{ module_vite('build-api', 'Resources/assets/js/app.js') }} --}} |
||||||
|
</body> |
||||||
|
</html> |
@ -0,0 +1,22 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
use Illuminate\Http\Request; |
||||||
|
use Modules\Agents\Http\Controllers\AgentActionApi; |
||||||
|
|
||||||
|
/* |
||||||
|
|-------------------------------------------------------------------------- |
||||||
|
| API Routes |
||||||
|
|-------------------------------------------------------------------------- |
||||||
|
| |
||||||
|
| Here is where you can register API routes for your application. These |
||||||
|
| routes are loaded by the RouteServiceProvider within a group which |
||||||
|
| is assigned the "api" middleware group. Enjoy building your API! |
||||||
|
*/ |
||||||
|
|
||||||
|
Route::group( ['middleware' => ['auth:api']], function() { |
||||||
|
Route::post('/add_customer', [AgentActionApi::class, 'addCustomer'])->name('agent_add_customer'); |
||||||
|
}); |
||||||
|
|
||||||
|
// Route::get('/RP006', function(Request $request){ |
||||||
|
// var_dump( $request->bearerToken()); |
||||||
|
// })/*->middleware('auth:api')*/; //disable auth middleware to inspect header |
@ -0,0 +1,16 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
/* |
||||||
|
|-------------------------------------------------------------------------- |
||||||
|
| Web Routes |
||||||
|
|-------------------------------------------------------------------------- |
||||||
|
| |
||||||
|
| Here is where you can register web routes for your application. These |
||||||
|
| routes are loaded by the RouteServiceProvider within a group which |
||||||
|
| contains the "web" middleware group. Now create something great! |
||||||
|
| |
||||||
|
*/ |
||||||
|
|
||||||
|
Route::prefix('agents')->group(function() { |
||||||
|
Route::get('/', [\Modules\Agents\Http\Controllers\AgentController::class, 'index']); |
||||||
|
}); |
@ -0,0 +1,11 @@ |
|||||||
|
{ |
||||||
|
"name": "Agents", |
||||||
|
"alias": "agents", |
||||||
|
"description": "", |
||||||
|
"keywords": [], |
||||||
|
"priority": 0, |
||||||
|
"providers": [ |
||||||
|
"Modules\\Agents\\Providers\\AgentsServiceProvider" |
||||||
|
], |
||||||
|
"files": [] |
||||||
|
} |
@ -0,0 +1,24 @@ |
|||||||
|
{ |
||||||
|
"private": true, |
||||||
|
"scripts": { |
||||||
|
"dev": "npm run development", |
||||||
|
"development": "mix", |
||||||
|
"watch": "mix watch", |
||||||
|
"watch-poll": "mix watch -- --watch-options-poll=1000", |
||||||
|
"hot": "mix watch --hot", |
||||||
|
"prod": "npm run production", |
||||||
|
"production": "mix --production" |
||||||
|
}, |
||||||
|
"devDependencies": { |
||||||
|
"axios": "^0.21.4", |
||||||
|
"dotenv": "^10.0.0", |
||||||
|
"dotenv-expand": "^5.1.0", |
||||||
|
"laravel-mix": "^6.0.31", |
||||||
|
"laravel-mix-merge-manifest": "^2.0.0", |
||||||
|
"lodash": "^4.17.21", |
||||||
|
"postcss": "^8.3.7", |
||||||
|
"resolve-url-loader": "^5.0.0", |
||||||
|
"sass": "^1.56.2", |
||||||
|
"sass-loader": "^12.6.0" |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,20 @@ |
|||||||
|
const defaultTheme = require('tailwindcss/defaultTheme'); |
||||||
|
|
||||||
|
/** @type {import('tailwindcss').Config} */ |
||||||
|
module.exports = { |
||||||
|
content: [ |
||||||
|
'./vendor/laravel/framework/src/Illuminate/Pagination/resources/views/*.blade.php', |
||||||
|
'./storage/framework/views/*.php', |
||||||
|
'./resources/views/**/*.blade.php', |
||||||
|
], |
||||||
|
|
||||||
|
theme: { |
||||||
|
extend: { |
||||||
|
fontFamily: { |
||||||
|
sans: ['Nunito', ...defaultTheme.fontFamily.sans], |
||||||
|
}, |
||||||
|
}, |
||||||
|
}, |
||||||
|
|
||||||
|
plugins: [require('@tailwindcss/forms')], |
||||||
|
}; |
@ -0,0 +1,14 @@ |
|||||||
|
const dotenvExpand = require('dotenv-expand'); |
||||||
|
dotenvExpand(require('dotenv').config({ path: '../../.env'/*, debug: true*/})); |
||||||
|
|
||||||
|
const mix = require('laravel-mix'); |
||||||
|
require('laravel-mix-merge-manifest'); |
||||||
|
|
||||||
|
mix.setPublicPath('../../public').mergeManifest(); |
||||||
|
|
||||||
|
mix.js(__dirname + '/Resources/assets/js/app.js', '/public/modules/api/js/api.js') |
||||||
|
.sass( __dirname + '/Resources/assets/sass/app.scss', '/public/modules/api/css/api.css'); |
||||||
|
|
||||||
|
if (mix.inProduction()) { |
||||||
|
mix.version(); |
||||||
|
} |
Loading…
Reference in new issue