Repo rebuild
This commit is contained in:
@@ -0,0 +1,18 @@
|
|||||||
|
root = true
|
||||||
|
|
||||||
|
[*]
|
||||||
|
charset = utf-8
|
||||||
|
end_of_line = lf
|
||||||
|
indent_size = 4
|
||||||
|
indent_style = space
|
||||||
|
insert_final_newline = true
|
||||||
|
trim_trailing_whitespace = true
|
||||||
|
|
||||||
|
[*.md]
|
||||||
|
trim_trailing_whitespace = false
|
||||||
|
|
||||||
|
[*.{yml,yaml}]
|
||||||
|
indent_size = 4
|
||||||
|
|
||||||
|
[{compose,docker-compose}.{yml,yaml}]
|
||||||
|
indent_size = 4
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
APP_NAME=Laravel
|
||||||
|
APP_ENV=local
|
||||||
|
APP_KEY=
|
||||||
|
APP_DEBUG=true
|
||||||
|
APP_URL=http://localhost
|
||||||
|
|
||||||
|
APP_LOCALE=en
|
||||||
|
APP_FALLBACK_LOCALE=en
|
||||||
|
APP_FAKER_LOCALE=en_US
|
||||||
|
|
||||||
|
APP_MAINTENANCE_DRIVER=file
|
||||||
|
# APP_MAINTENANCE_STORE=database
|
||||||
|
|
||||||
|
# PHP_CLI_SERVER_WORKERS=4
|
||||||
|
|
||||||
|
BCRYPT_ROUNDS=12
|
||||||
|
|
||||||
|
LOG_CHANNEL=stack
|
||||||
|
LOG_STACK=single
|
||||||
|
LOG_DEPRECATIONS_CHANNEL=null
|
||||||
|
LOG_LEVEL=debug
|
||||||
|
|
||||||
|
DB_CONNECTION=sqlite
|
||||||
|
# DB_HOST=127.0.0.1
|
||||||
|
# DB_PORT=3306
|
||||||
|
# DB_DATABASE=laravel
|
||||||
|
# DB_USERNAME=root
|
||||||
|
# DB_PASSWORD=
|
||||||
|
|
||||||
|
SESSION_DRIVER=database
|
||||||
|
SESSION_LIFETIME=120
|
||||||
|
SESSION_ENCRYPT=false
|
||||||
|
SESSION_PATH=/
|
||||||
|
SESSION_DOMAIN=null
|
||||||
|
|
||||||
|
BROADCAST_CONNECTION=log
|
||||||
|
FILESYSTEM_DISK=local
|
||||||
|
QUEUE_CONNECTION=database
|
||||||
|
|
||||||
|
CACHE_STORE=database
|
||||||
|
# CACHE_PREFIX=
|
||||||
|
|
||||||
|
MEMCACHED_HOST=127.0.0.1
|
||||||
|
|
||||||
|
REDIS_CLIENT=phpredis
|
||||||
|
REDIS_HOST=127.0.0.1
|
||||||
|
REDIS_PASSWORD=null
|
||||||
|
REDIS_PORT=6379
|
||||||
|
|
||||||
|
MAIL_MAILER=log
|
||||||
|
MAIL_SCHEME=null
|
||||||
|
MAIL_HOST=127.0.0.1
|
||||||
|
MAIL_PORT=2525
|
||||||
|
MAIL_USERNAME=null
|
||||||
|
MAIL_PASSWORD=null
|
||||||
|
MAIL_FROM_ADDRESS="hello@example.com"
|
||||||
|
MAIL_FROM_NAME="${APP_NAME}"
|
||||||
|
|
||||||
|
AWS_ACCESS_KEY_ID=
|
||||||
|
AWS_SECRET_ACCESS_KEY=
|
||||||
|
AWS_DEFAULT_REGION=us-east-1
|
||||||
|
AWS_BUCKET=
|
||||||
|
AWS_USE_PATH_STYLE_ENDPOINT=false
|
||||||
|
|
||||||
|
VITE_APP_NAME="${APP_NAME}"
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
* text=auto eol=lf
|
||||||
|
|
||||||
|
*.blade.php diff=html
|
||||||
|
*.css diff=css
|
||||||
|
*.html diff=html
|
||||||
|
*.md diff=markdown
|
||||||
|
*.php diff=php
|
||||||
|
|
||||||
|
CHANGELOG.md export-ignore
|
||||||
|
README.md export-ignore
|
||||||
|
.github/workflows/browser-tests.yml export-ignore
|
||||||
+41
@@ -0,0 +1,41 @@
|
|||||||
|
/.phpunit.cache
|
||||||
|
/node_modules
|
||||||
|
/public/build
|
||||||
|
/public/fonts-manifest.dev.json
|
||||||
|
/public/hot
|
||||||
|
/public/storage
|
||||||
|
/storage/*.key
|
||||||
|
/storage/pail
|
||||||
|
/vendor
|
||||||
|
.env
|
||||||
|
.env.backup
|
||||||
|
.env.production
|
||||||
|
.env.dusk.local
|
||||||
|
.env.testing
|
||||||
|
.phpactor.json
|
||||||
|
.phpunit.result.cache
|
||||||
|
Homestead.json
|
||||||
|
Homestead.yaml
|
||||||
|
npm-debug.log
|
||||||
|
yarn-error.log
|
||||||
|
/auth.json
|
||||||
|
/.fleet
|
||||||
|
/.idea
|
||||||
|
/.junie
|
||||||
|
/.github
|
||||||
|
/.nova
|
||||||
|
/.vscode
|
||||||
|
/.zed
|
||||||
|
package-lock.json
|
||||||
|
composer.lock
|
||||||
|
/provision/
|
||||||
|
/storage/logs/
|
||||||
|
/AGENTS.md
|
||||||
|
.DS_Store
|
||||||
|
*/.DS_Store
|
||||||
|
**/.DS_Store
|
||||||
|
/coverage/
|
||||||
|
/.scannerwork/
|
||||||
|
/storage/framework/
|
||||||
|
/storage/debugbar/
|
||||||
|
/phpunit.dusk.xml
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Analytics\Providers;
|
||||||
|
|
||||||
|
use Illuminate\Support\ServiceProvider;
|
||||||
|
|
||||||
|
class AnalyticsServiceProvider extends ServiceProvider
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Bootstrap the module services.
|
||||||
|
*/
|
||||||
|
public function boot(): void
|
||||||
|
{
|
||||||
|
$this->loadRoutesFrom(__DIR__ . '/../Routes/web.php');
|
||||||
|
$this->loadViewsFrom(__DIR__ . '/../Resources/views', 'analytics');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register the module services.
|
||||||
|
*/
|
||||||
|
public function register(): void
|
||||||
|
{
|
||||||
|
// Placeholder only.
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
# Analytics
|
||||||
|
|
||||||
|
Display KPIs, warehouse performance trends, executive summaries, and OTTC analysis.
|
||||||
|
|
||||||
|
Contains actual sample Blade views and placeholder service provider/routes only.
|
||||||
@@ -0,0 +1,120 @@
|
|||||||
|
<x-layouts::app :title="__('Analytics')">
|
||||||
|
<div class="container-fluid py-4 module-page module-analytics">
|
||||||
|
<div class="row g-4">
|
||||||
|
<div class="col-12">
|
||||||
|
<x-wms.page-hero eyebrow="Operations" title="Analytics"
|
||||||
|
description="Display KPIs, warehouse performance trends, executive summaries, and OTTC analysis."
|
||||||
|
icon="fa-solid fa-chart-line" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-md-6 col-xl-3">
|
||||||
|
<div class="card h-100 border-0 shadow-sm module-metric-card">
|
||||||
|
<div class="card-body">
|
||||||
|
<div class="small text-uppercase text-muted fw-semibold mb-2">01</div>
|
||||||
|
<h3 class="h6 mb-2">KPI1 Bar</h3>
|
||||||
|
<p class="small text-muted mb-0">Placeholder area for kpi1 bar.</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-6 col-xl-3">
|
||||||
|
<div class="card h-100 border-0 shadow-sm module-metric-card">
|
||||||
|
<div class="card-body">
|
||||||
|
<div class="small text-uppercase text-muted fw-semibold mb-2">02</div>
|
||||||
|
<h3 class="h6 mb-2">KPI1 Line</h3>
|
||||||
|
<p class="small text-muted mb-0">Placeholder area for kpi1 line.</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-6 col-xl-3">
|
||||||
|
<div class="card h-100 border-0 shadow-sm module-metric-card">
|
||||||
|
<div class="card-body">
|
||||||
|
<div class="small text-uppercase text-muted fw-semibold mb-2">03</div>
|
||||||
|
<h3 class="h6 mb-2">OTTC</h3>
|
||||||
|
<p class="small text-muted mb-0">Placeholder area for ottc.</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-6 col-xl-3">
|
||||||
|
<div class="card h-100 border-0 shadow-sm module-metric-card">
|
||||||
|
<div class="card-body">
|
||||||
|
<div class="small text-uppercase text-muted fw-semibold mb-2">04</div>
|
||||||
|
<h3 class="h6 mb-2">Warehouse Performance</h3>
|
||||||
|
<p class="small text-muted mb-0">Placeholder area for warehouse performance.</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-12">
|
||||||
|
<section class="card border-0 shadow-sm">
|
||||||
|
<div class="card-header bg-white border-bottom">
|
||||||
|
<div class="d-flex flex-column flex-md-row justify-content-between gap-2">
|
||||||
|
<div>
|
||||||
|
<h2 class="h5 mb-1">Analytics workbench</h2>
|
||||||
|
<p class="small text-muted mb-0">Sample table layout ready to wire into controllers,
|
||||||
|
queries, DataTables, or Livewire.</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="d-flex gap-2">
|
||||||
|
<button type="button" class="btn btn-outline-secondary btn-sm">Export</button>
|
||||||
|
<button type="button" class="btn btn-primary btn-sm">Create</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="card-body">
|
||||||
|
<div class="table-responsive">
|
||||||
|
<table class="table table-hover align-middle mb-0">
|
||||||
|
<thead class="table-light">
|
||||||
|
<tr>
|
||||||
|
<th>Metric</th>
|
||||||
|
<th>Today</th>
|
||||||
|
<th>Week</th>
|
||||||
|
<th class="text-end">Action</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td>KPI1 Bar</td>
|
||||||
|
<td>Sample 1</td>
|
||||||
|
<td><span
|
||||||
|
class="badge bg-success-subtle text-success border border-success-subtle">Active</span>
|
||||||
|
</td>
|
||||||
|
<td class="text-end"><a href="#"
|
||||||
|
class="btn btn-sm btn-outline-primary">Open</a></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>KPI1 Line</td>
|
||||||
|
<td>Sample 2</td>
|
||||||
|
<td><span
|
||||||
|
class="badge bg-success-subtle text-success border border-success-subtle">Active</span>
|
||||||
|
</td>
|
||||||
|
<td class="text-end"><a href="#"
|
||||||
|
class="btn btn-sm btn-outline-primary">Open</a></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>OTTC</td>
|
||||||
|
<td>Sample 3</td>
|
||||||
|
<td><span
|
||||||
|
class="badge bg-success-subtle text-success border border-success-subtle">Active</span>
|
||||||
|
</td>
|
||||||
|
<td class="text-end"><a href="#"
|
||||||
|
class="btn btn-sm btn-outline-primary">Open</a></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Warehouse Performance</td>
|
||||||
|
<td>Sample 4</td>
|
||||||
|
<td><span
|
||||||
|
class="badge bg-success-subtle text-success border border-success-subtle">Active</span>
|
||||||
|
</td>
|
||||||
|
<td class="text-end"><a href="#"
|
||||||
|
class="btn btn-sm btn-outline-primary">Open</a></td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</x-layouts::app>
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
<a href="{{ route('analytics.index') }}" class="nav-link d-flex align-items-center gap-2">
|
||||||
|
<i class="bi bi-graph-up-arrow"></i>
|
||||||
|
<span>Analytics</span>
|
||||||
|
</a>
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
// API routes can be added here when the module is implemented.
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Route;
|
||||||
|
|
||||||
|
Route::middleware(['web', 'auth'])
|
||||||
|
->prefix('analytics')
|
||||||
|
->name('analytics.')
|
||||||
|
->group(function (): void {
|
||||||
|
Route::view('/', 'analytics::index')->name('index');
|
||||||
|
});
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"name": "Analytics",
|
||||||
|
"alias": "analytics",
|
||||||
|
"description": "Display KPIs, warehouse performance trends, executive summaries, and OTTC analysis.",
|
||||||
|
"keywords": [],
|
||||||
|
"priority": 0,
|
||||||
|
"providers": [
|
||||||
|
"Modules\\Analytics\\Providers\\AnalyticsServiceProvider"
|
||||||
|
],
|
||||||
|
"files": []
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Audit\Providers;
|
||||||
|
|
||||||
|
use Illuminate\Support\ServiceProvider;
|
||||||
|
|
||||||
|
class AuditServiceProvider extends ServiceProvider
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Bootstrap the module services.
|
||||||
|
*/
|
||||||
|
public function boot(): void
|
||||||
|
{
|
||||||
|
$this->loadRoutesFrom(__DIR__ . '/../Routes/web.php');
|
||||||
|
$this->loadViewsFrom(__DIR__ . '/../Resources/views', 'audit');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register the module services.
|
||||||
|
*/
|
||||||
|
public function register(): void
|
||||||
|
{
|
||||||
|
// Placeholder only.
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
# Audit
|
||||||
|
|
||||||
|
Review activity logs, data changes, interface events, and administrative actions.
|
||||||
|
|
||||||
|
Contains actual sample Blade views and placeholder service provider/routes only.
|
||||||
@@ -0,0 +1,120 @@
|
|||||||
|
<x-layouts::app :title="__('Audit')">
|
||||||
|
<div class="container-fluid py-4 module-page module-audit">
|
||||||
|
<div class="row g-4">
|
||||||
|
<div class="col-12">
|
||||||
|
<x-wms.page-hero eyebrow="Operations" title="Audit"
|
||||||
|
description="Review activity logs, data changes, interface events, and administrative actions."
|
||||||
|
icon="fa-solid fa-clipboard-check" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-md-6 col-xl-3">
|
||||||
|
<div class="card h-100 border-0 shadow-sm module-metric-card">
|
||||||
|
<div class="card-body">
|
||||||
|
<div class="small text-uppercase text-muted fw-semibold mb-2">01</div>
|
||||||
|
<h3 class="h6 mb-2">Activity Log</h3>
|
||||||
|
<p class="small text-muted mb-0">Placeholder area for activity log.</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-6 col-xl-3">
|
||||||
|
<div class="card h-100 border-0 shadow-sm module-metric-card">
|
||||||
|
<div class="card-body">
|
||||||
|
<div class="small text-uppercase text-muted fw-semibold mb-2">02</div>
|
||||||
|
<h3 class="h6 mb-2">Data Changes</h3>
|
||||||
|
<p class="small text-muted mb-0">Placeholder area for data changes.</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-6 col-xl-3">
|
||||||
|
<div class="card h-100 border-0 shadow-sm module-metric-card">
|
||||||
|
<div class="card-body">
|
||||||
|
<div class="small text-uppercase text-muted fw-semibold mb-2">03</div>
|
||||||
|
<h3 class="h6 mb-2">API Audit</h3>
|
||||||
|
<p class="small text-muted mb-0">Placeholder area for api audit.</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-6 col-xl-3">
|
||||||
|
<div class="card h-100 border-0 shadow-sm module-metric-card">
|
||||||
|
<div class="card-body">
|
||||||
|
<div class="small text-uppercase text-muted fw-semibold mb-2">04</div>
|
||||||
|
<h3 class="h6 mb-2">User Actions</h3>
|
||||||
|
<p class="small text-muted mb-0">Placeholder area for user actions.</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-12">
|
||||||
|
<section class="card border-0 shadow-sm">
|
||||||
|
<div class="card-header bg-white border-bottom">
|
||||||
|
<div class="d-flex flex-column flex-md-row justify-content-between gap-2">
|
||||||
|
<div>
|
||||||
|
<h2 class="h5 mb-1">Audit workbench</h2>
|
||||||
|
<p class="small text-muted mb-0">Sample table layout ready to wire into controllers,
|
||||||
|
queries, DataTables, or Livewire.</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="d-flex gap-2">
|
||||||
|
<button type="button" class="btn btn-outline-secondary btn-sm">Export</button>
|
||||||
|
<button type="button" class="btn btn-primary btn-sm">Create</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="card-body">
|
||||||
|
<div class="table-responsive">
|
||||||
|
<table class="table table-hover align-middle mb-0">
|
||||||
|
<thead class="table-light">
|
||||||
|
<tr>
|
||||||
|
<th>When</th>
|
||||||
|
<th>User</th>
|
||||||
|
<th>Action</th>
|
||||||
|
<th class="text-end">Action</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td>Activity Log</td>
|
||||||
|
<td>Sample 1</td>
|
||||||
|
<td><span
|
||||||
|
class="badge bg-success-subtle text-success border border-success-subtle">Active</span>
|
||||||
|
</td>
|
||||||
|
<td class="text-end"><a href="#"
|
||||||
|
class="btn btn-sm btn-outline-primary">Open</a></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Data Changes</td>
|
||||||
|
<td>Sample 2</td>
|
||||||
|
<td><span
|
||||||
|
class="badge bg-success-subtle text-success border border-success-subtle">Active</span>
|
||||||
|
</td>
|
||||||
|
<td class="text-end"><a href="#"
|
||||||
|
class="btn btn-sm btn-outline-primary">Open</a></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>API Audit</td>
|
||||||
|
<td>Sample 3</td>
|
||||||
|
<td><span
|
||||||
|
class="badge bg-success-subtle text-success border border-success-subtle">Active</span>
|
||||||
|
</td>
|
||||||
|
<td class="text-end"><a href="#"
|
||||||
|
class="btn btn-sm btn-outline-primary">Open</a></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>User Actions</td>
|
||||||
|
<td>Sample 4</td>
|
||||||
|
<td><span
|
||||||
|
class="badge bg-success-subtle text-success border border-success-subtle">Active</span>
|
||||||
|
</td>
|
||||||
|
<td class="text-end"><a href="#"
|
||||||
|
class="btn btn-sm btn-outline-primary">Open</a></td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</x-layouts::app>
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
<a href="{{ route('audit.index') }}" class="nav-link d-flex align-items-center gap-2">
|
||||||
|
<i class="bi bi-clipboard-check"></i>
|
||||||
|
<span>Audit</span>
|
||||||
|
</a>
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
// API routes can be added here when the module is implemented.
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Route;
|
||||||
|
|
||||||
|
Route::middleware(['web', 'auth'])
|
||||||
|
->prefix('audit')
|
||||||
|
->name('audit.')
|
||||||
|
->group(function (): void {
|
||||||
|
Route::view('/', 'audit::index')->name('index');
|
||||||
|
});
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"name": "Audit",
|
||||||
|
"alias": "audit",
|
||||||
|
"description": "Review activity logs, data changes, interface events, and administrative actions.",
|
||||||
|
"keywords": [],
|
||||||
|
"priority": 0,
|
||||||
|
"providers": [
|
||||||
|
"Modules\\Audit\\Providers\\AuditServiceProvider"
|
||||||
|
],
|
||||||
|
"files": []
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
return [
|
||||||
|
'name' => 'AuditTrail',
|
||||||
|
'features' => [
|
||||||
|
],
|
||||||
|
];
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\AuditTrail\Database\Seeders;
|
||||||
|
|
||||||
|
use Illuminate\Database\Seeder;
|
||||||
|
|
||||||
|
class AuditTrailDatabaseSeeder extends Seeder
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the database seeds.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function run() {}
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Modules\AuditTrail\Support\ModuleInfo;
|
||||||
|
|
||||||
|
if (! function_exists('audittrail_feature_enabled')) {
|
||||||
|
/**
|
||||||
|
* Check if a feature is enabled in the config.
|
||||||
|
*/
|
||||||
|
function audittrail_feature_enabled(string $key): bool
|
||||||
|
{
|
||||||
|
return (bool) config(ModuleInfo::nameLower() . ".features.{$key}", false);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,88 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\AuditTrail\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Contracts\Support\Renderable;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Routing\Controller;
|
||||||
|
|
||||||
|
class AuditTrailController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
*
|
||||||
|
* @return Renderable
|
||||||
|
*/
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
return view('audittrail::index');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for creating a new resource.
|
||||||
|
*
|
||||||
|
* @return Renderable
|
||||||
|
*/
|
||||||
|
public function create()
|
||||||
|
{
|
||||||
|
return view('audittrail::create');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store a newly created resource in storage.
|
||||||
|
*
|
||||||
|
* @return Renderable
|
||||||
|
*/
|
||||||
|
public function store(Request $request)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the specified resource.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
*
|
||||||
|
* @return Renderable
|
||||||
|
*/
|
||||||
|
public function show($id)
|
||||||
|
{
|
||||||
|
return view('audittrail::show');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for editing the specified resource.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
*
|
||||||
|
* @return Renderable
|
||||||
|
*/
|
||||||
|
public function edit($id)
|
||||||
|
{
|
||||||
|
return view('audittrail::edit');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the specified resource in storage.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
*
|
||||||
|
* @return Renderable
|
||||||
|
*/
|
||||||
|
public function update(Request $request, $id)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the specified resource from storage.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
*
|
||||||
|
* @return Renderable
|
||||||
|
*/
|
||||||
|
public function destroy($id)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,133 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\AuditTrail\Providers;
|
||||||
|
|
||||||
|
use Config;
|
||||||
|
use Illuminate\Support\Facades\File;
|
||||||
|
use Illuminate\Support\ServiceProvider;
|
||||||
|
use Modules\AuditTrail\Support\ModuleInfo;
|
||||||
|
|
||||||
|
class AuditTrailServiceProvider extends ServiceProvider
|
||||||
|
{
|
||||||
|
protected string $moduleName = 'AuditTrail';
|
||||||
|
|
||||||
|
protected string $moduleNameLower = 'audittrail';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the services provided by the provider.
|
||||||
|
*/
|
||||||
|
public function provides(): array
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Boot the application events.
|
||||||
|
*/
|
||||||
|
public function boot(): void
|
||||||
|
{
|
||||||
|
$this->registerTranslations();
|
||||||
|
$this->registerConfig();
|
||||||
|
$this->registerViews();
|
||||||
|
$this->registerHelpers();
|
||||||
|
$this->registerCommands();
|
||||||
|
$this->loadMigrationsFrom(module_path(ModuleInfo::name(), 'Database/Migrations'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register the service provider.
|
||||||
|
*/
|
||||||
|
public function register(): void
|
||||||
|
{
|
||||||
|
$this->app->register(RouteServiceProvider::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register the helpers.
|
||||||
|
*/
|
||||||
|
protected function registerHelpers(): void
|
||||||
|
{
|
||||||
|
foreach (glob(__DIR__ . '/../Helpers/*.php') as $filename) {
|
||||||
|
require_once $filename;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dynamically Register Commands.
|
||||||
|
*/
|
||||||
|
public function registerCommands(): void
|
||||||
|
{
|
||||||
|
if (! $this->app->runningInConsole()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$commandPath = __DIR__ . '/../Console';
|
||||||
|
$commands = collect(File::allFiles($commandPath))
|
||||||
|
->map(function ($file) {
|
||||||
|
$class = 'Modules\\' . $this->moduleName . '\\Console\\' . $file->getFilenameWithoutExtension();
|
||||||
|
|
||||||
|
return $class;
|
||||||
|
})
|
||||||
|
->filter(function ($class) {
|
||||||
|
return class_exists($class);
|
||||||
|
})
|
||||||
|
->values()
|
||||||
|
->all();
|
||||||
|
$this->commands($commands);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register config.
|
||||||
|
*/
|
||||||
|
protected function registerConfig(): void
|
||||||
|
{
|
||||||
|
$this->publishes([
|
||||||
|
module_path(ModuleInfo::name(), 'Config/config.php') => config_path(ModuleInfo::nameLower() . '.php'),
|
||||||
|
], 'config');
|
||||||
|
$this->mergeConfigFrom(
|
||||||
|
module_path(ModuleInfo::name(), 'Config/config.php'),
|
||||||
|
ModuleInfo::nameLower(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register views.
|
||||||
|
*/
|
||||||
|
public function registerViews(): void
|
||||||
|
{
|
||||||
|
$viewPath = resource_path('views/modules/' . ModuleInfo::nameLower());
|
||||||
|
$sourcePath = module_path(ModuleInfo::name(), 'Resources/views');
|
||||||
|
$this->publishes([
|
||||||
|
$sourcePath => $viewPath,
|
||||||
|
], ['views', ModuleInfo::nameLower() . '-module-views']);
|
||||||
|
$this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), ModuleInfo::nameLower());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register translations.
|
||||||
|
*/
|
||||||
|
public function registerTranslations(): void
|
||||||
|
{
|
||||||
|
$langPath = resource_path('lang/modules/' . ModuleInfo::nameLower());
|
||||||
|
|
||||||
|
if (is_dir($langPath)) {
|
||||||
|
$this->loadTranslationsFrom($langPath, ModuleInfo::nameLower());
|
||||||
|
} else {
|
||||||
|
$this->loadTranslationsFrom(module_path(ModuleInfo::name(), 'Resources/lang'), ModuleInfo::nameLower());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Regsiter View Paths
|
||||||
|
*/
|
||||||
|
private function getPublishableViewPaths(): array
|
||||||
|
{
|
||||||
|
$paths = [];
|
||||||
|
foreach (Config::get('view.paths') as $path) {
|
||||||
|
if (is_dir($path . '/modules/' . ModuleInfo::nameLower())) {
|
||||||
|
$paths[] = $path . '/modules/' . ModuleInfo::nameLower();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $paths;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,69 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\AuditTrail\Providers;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
|
||||||
|
use Illuminate\Support\Facades\Route;
|
||||||
|
|
||||||
|
class RouteServiceProvider extends ServiceProvider
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The module namespace to assume when generating URLs to actions.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $moduleNamespace = 'Modules\AuditTrail\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('AuditTrail', '/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('AuditTrail', '/Routes/api.php'));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
@extends('audittrail::layouts.master')
|
||||||
|
|
||||||
|
@section('content')
|
||||||
|
<h1>Hello World</h1>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
This view is loaded from module: {!! config('audittrail.name') !!}
|
||||||
|
</p>
|
||||||
|
@endsection
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
<!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 AuditTrail</title>
|
||||||
|
|
||||||
|
{{-- Laravel Mix - CSS File --}}
|
||||||
|
{{-- <link rel="stylesheet" href="{{ mix('css/audittrail.css') }}"> --}}
|
||||||
|
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<div data-dusk="page-ready" style="position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0,0,0,0);"
|
||||||
|
aria-hidden="true"></div>
|
||||||
|
@yield('content')
|
||||||
|
|
||||||
|
{{-- Laravel Mix - JS File --}}
|
||||||
|
{{-- <script src="{{ mix('js/audittrail.js') }}"></script> --}}
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| 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::middleware('auth:api')->get('/audittrail', function (Request $request) {
|
||||||
|
return $request->user();
|
||||||
|
});
|
||||||
@@ -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('audittrail')->group(function () {
|
||||||
|
Route::get('/', 'AuditTrailController@index');
|
||||||
|
});
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\AuditTrail\Support;
|
||||||
|
|
||||||
|
class ModuleInfo
|
||||||
|
{
|
||||||
|
protected static string $moduleName = 'AuditTrail';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* defines the Module Name
|
||||||
|
*/
|
||||||
|
public static function name(): string
|
||||||
|
{
|
||||||
|
return static::$moduleName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* define the lowercase version
|
||||||
|
*/
|
||||||
|
public static function nameLower(): string
|
||||||
|
{
|
||||||
|
return strtolower(static::$moduleName);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
{
|
||||||
|
"name": "mpba/audittrail",
|
||||||
|
"description": "",
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Mark Gregory",
|
||||||
|
"email": "mark.gregory@mpba.co.uk"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"extra": {
|
||||||
|
"laravel": {
|
||||||
|
"providers": [],
|
||||||
|
"aliases": {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"Modules\\AuditTrail\\": ""
|
||||||
|
},
|
||||||
|
"autoload-dev": {
|
||||||
|
"psr-4": {
|
||||||
|
"Tests\\": "tests/",
|
||||||
|
"Modules\\AuditTrail\\Tests\\": "modules/AuditTrail/Tests/"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
{
|
||||||
|
"name": "AuditTrail",
|
||||||
|
"alias": "audittrail",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "",
|
||||||
|
"keywords": [],
|
||||||
|
"priority": 0,
|
||||||
|
"providers": [
|
||||||
|
"Modules\\AuditTrail\\Providers\\AuditTrailServiceProvider"
|
||||||
|
],
|
||||||
|
"aliases": {},
|
||||||
|
"files": [],
|
||||||
|
"requires": []
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"private": true,
|
||||||
|
"scripts": {
|
||||||
|
"dev": "npm run development",
|
||||||
|
"development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
|
||||||
|
"watch": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
|
||||||
|
"watch-poll": "npm run watch -- --watch-poll",
|
||||||
|
"hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js",
|
||||||
|
"prod": "npm run production",
|
||||||
|
"production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"cross-env": "^7.0",
|
||||||
|
"laravel-mix": "^5.0.1",
|
||||||
|
"laravel-mix-merge-manifest": "^0.1.2"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
const dotenvExpand = require('dotenv-expand');
|
||||||
|
dotenvExpand(require('dotenv').config({ path: '../../.env'/*, debug: true*/}));
|
||||||
|
|
||||||
|
const mix = require('laravel-mix');
|
||||||
|
|
||||||
|
mix.js(__dirname + '/Resources/assets/js/app.js', 'js/audittrail.js')
|
||||||
|
.sass( __dirname + '/Resources/assets/sass/app.scss', 'css/audittrail.css');
|
||||||
|
|
||||||
|
if (mix.inProduction()) {
|
||||||
|
mix.version();
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\CarrierManagement\Providers;
|
||||||
|
|
||||||
|
use Illuminate\Support\ServiceProvider;
|
||||||
|
|
||||||
|
class CarrierManagementServiceProvider extends ServiceProvider
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Bootstrap the module services.
|
||||||
|
*/
|
||||||
|
public function boot(): void
|
||||||
|
{
|
||||||
|
$this->loadRoutesFrom(__DIR__ . '/../Routes/web.php');
|
||||||
|
$this->loadViewsFrom(__DIR__ . '/../Resources/views', 'carriermanagement');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register the module services.
|
||||||
|
*/
|
||||||
|
public function register(): void
|
||||||
|
{
|
||||||
|
// Placeholder only.
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
# Carrier Management
|
||||||
|
|
||||||
|
Maintain carriers, services, and shipment routing master data.
|
||||||
|
|
||||||
|
Contains actual sample Blade views and placeholder service provider/routes only.
|
||||||
@@ -0,0 +1,120 @@
|
|||||||
|
<x-layouts::app :title="__('Carrier Management')">
|
||||||
|
<div class="container-fluid py-4 module-page module-carrier-management">
|
||||||
|
<div class="row g-4">
|
||||||
|
<div class="col-12">
|
||||||
|
<x-wms.page-hero eyebrow="Operations" title="Carrier Management"
|
||||||
|
description="Maintain carriers, services, and shipment routing master data."
|
||||||
|
icon="fa-solid fa-id-card" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-md-6 col-xl-3">
|
||||||
|
<div class="card h-100 border-0 shadow-sm module-metric-card">
|
||||||
|
<div class="card-body">
|
||||||
|
<div class="small text-uppercase text-muted fw-semibold mb-2">01</div>
|
||||||
|
<h3 class="h6 mb-2">Carrier Directory</h3>
|
||||||
|
<p class="small text-muted mb-0">Placeholder area for carrier directory.</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-6 col-xl-3">
|
||||||
|
<div class="card h-100 border-0 shadow-sm module-metric-card">
|
||||||
|
<div class="card-body">
|
||||||
|
<div class="small text-uppercase text-muted fw-semibold mb-2">02</div>
|
||||||
|
<h3 class="h6 mb-2">Carrier Service Levels</h3>
|
||||||
|
<p class="small text-muted mb-0">Placeholder area for carrier service levels.</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-6 col-xl-3">
|
||||||
|
<div class="card h-100 border-0 shadow-sm module-metric-card">
|
||||||
|
<div class="card-body">
|
||||||
|
<div class="small text-uppercase text-muted fw-semibold mb-2">03</div>
|
||||||
|
<h3 class="h6 mb-2">Carrier Rules</h3>
|
||||||
|
<p class="small text-muted mb-0">Placeholder area for carrier rules.</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-6 col-xl-3">
|
||||||
|
<div class="card h-100 border-0 shadow-sm module-metric-card">
|
||||||
|
<div class="card-body">
|
||||||
|
<div class="small text-uppercase text-muted fw-semibold mb-2">04</div>
|
||||||
|
<h3 class="h6 mb-2">Carrier Audit</h3>
|
||||||
|
<p class="small text-muted mb-0">Placeholder area for carrier audit.</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-12">
|
||||||
|
<section class="card border-0 shadow-sm">
|
||||||
|
<div class="card-header bg-white border-bottom">
|
||||||
|
<div class="d-flex flex-column flex-md-row justify-content-between gap-2">
|
||||||
|
<div>
|
||||||
|
<h2 class="h5 mb-1">Carrier Management workbench</h2>
|
||||||
|
<p class="small text-muted mb-0">Sample table layout ready to wire into controllers,
|
||||||
|
queries, DataTables, or Livewire.</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="d-flex gap-2">
|
||||||
|
<button type="button" class="btn btn-outline-secondary btn-sm">Export</button>
|
||||||
|
<button type="button" class="btn btn-primary btn-sm">Create</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="card-body">
|
||||||
|
<div class="table-responsive">
|
||||||
|
<table class="table table-hover align-middle mb-0">
|
||||||
|
<thead class="table-light">
|
||||||
|
<tr>
|
||||||
|
<th>Carrier</th>
|
||||||
|
<th>Service</th>
|
||||||
|
<th>Enabled</th>
|
||||||
|
<th class="text-end">Action</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td>Carrier Directory</td>
|
||||||
|
<td>Sample 1</td>
|
||||||
|
<td><span
|
||||||
|
class="badge bg-success-subtle text-success border border-success-subtle">Active</span>
|
||||||
|
</td>
|
||||||
|
<td class="text-end"><a href="#"
|
||||||
|
class="btn btn-sm btn-outline-primary">Open</a></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Carrier Service Levels</td>
|
||||||
|
<td>Sample 2</td>
|
||||||
|
<td><span
|
||||||
|
class="badge bg-success-subtle text-success border border-success-subtle">Active</span>
|
||||||
|
</td>
|
||||||
|
<td class="text-end"><a href="#"
|
||||||
|
class="btn btn-sm btn-outline-primary">Open</a></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Carrier Rules</td>
|
||||||
|
<td>Sample 3</td>
|
||||||
|
<td><span
|
||||||
|
class="badge bg-success-subtle text-success border border-success-subtle">Active</span>
|
||||||
|
</td>
|
||||||
|
<td class="text-end"><a href="#"
|
||||||
|
class="btn btn-sm btn-outline-primary">Open</a></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Carrier Audit</td>
|
||||||
|
<td>Sample 4</td>
|
||||||
|
<td><span
|
||||||
|
class="badge bg-success-subtle text-success border border-success-subtle">Active</span>
|
||||||
|
</td>
|
||||||
|
<td class="text-end"><a href="#"
|
||||||
|
class="btn btn-sm btn-outline-primary">Open</a></td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</x-layouts::app>
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
<a href="{{ route('carrier-management.index') }}" class="nav-link d-flex align-items-center gap-2">
|
||||||
|
<i class="bi bi-person-vcard"></i>
|
||||||
|
<span>Carrier Management</span>
|
||||||
|
</a>
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
// API routes can be added here when the module is implemented.
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Route;
|
||||||
|
|
||||||
|
Route::middleware(['web', 'auth'])
|
||||||
|
->prefix('carrier-management')
|
||||||
|
->name('carrier-management.')
|
||||||
|
->group(function (): void {
|
||||||
|
Route::view('/', 'carriermanagement::index')->name('index');
|
||||||
|
});
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"name": "CarrierManagement",
|
||||||
|
"alias": "carrier-management",
|
||||||
|
"description": "Maintain carriers, services, and shipment routing master data.",
|
||||||
|
"keywords": [],
|
||||||
|
"priority": 0,
|
||||||
|
"providers": [
|
||||||
|
"Modules\\CarrierManagement\\Providers\\CarrierManagementServiceProvider"
|
||||||
|
],
|
||||||
|
"files": []
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
return [
|
||||||
|
'name' => 'ChatGPT',
|
||||||
|
'features' => [
|
||||||
|
],
|
||||||
|
];
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\ChatGPT\Console;
|
||||||
|
|
||||||
|
use Illuminate\Console\Command;
|
||||||
|
use Modules\ChatGPT\Models\ChatGptApiSetting;
|
||||||
|
use Modules\ChatGPT\Services\OpenAiFileService;
|
||||||
|
use Throwable;
|
||||||
|
|
||||||
|
class DeleteOpenAiFilesCommand extends Command
|
||||||
|
{
|
||||||
|
protected $signature = 'chatgpt:delete-api-files {--dry-run : List files without deleting them}';
|
||||||
|
|
||||||
|
protected $description = 'Delete all OpenAI API files visible to the stored active API key.';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the console command.
|
||||||
|
*/
|
||||||
|
public function handle(): int
|
||||||
|
{
|
||||||
|
$setting = ChatGptApiSetting::active();
|
||||||
|
|
||||||
|
if (! $setting) {
|
||||||
|
$this->error('No active ChatGPT/OpenAI API key is stored.');
|
||||||
|
|
||||||
|
return self::FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
$service = new OpenAiFileService((string) $setting->api_key);
|
||||||
|
|
||||||
|
try {
|
||||||
|
if ((bool) $this->option('dry-run')) {
|
||||||
|
$files = $service->listFiles();
|
||||||
|
|
||||||
|
$this->info('Found ' . count($files) . ' OpenAI API file(s).');
|
||||||
|
|
||||||
|
foreach ($files as $file) {
|
||||||
|
$this->line(sprintf(
|
||||||
|
'- %s %s',
|
||||||
|
(string) ($file['id'] ?? 'unknown'),
|
||||||
|
(string) ($file['filename'] ?? 'unnamed'),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
return self::SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
$result = $service->deleteAllFiles();
|
||||||
|
|
||||||
|
$this->info("Listed: {$result['listed']}");
|
||||||
|
$this->info("Deleted: {$result['deleted']}");
|
||||||
|
$this->info("Failed: {$result['failed']}");
|
||||||
|
|
||||||
|
foreach ($result['failures'] as $failure) {
|
||||||
|
$this->error($failure['file_id'] . ': ' . $failure['error']);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result['failed'] === 0 ? self::SUCCESS : self::FAILURE;
|
||||||
|
} catch (Throwable $exception) {
|
||||||
|
$this->error($exception->getMessage());
|
||||||
|
|
||||||
|
return self::FAILURE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+30
@@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::create('chatgpt_api_settings', function (Blueprint $table): void {
|
||||||
|
$table->id();
|
||||||
|
$table->string('name')->default('OpenAI API Key');
|
||||||
|
$table->text('api_key');
|
||||||
|
$table->boolean('is_active')->default(true)->index();
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('chatgpt_api_settings');
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\ChatGPT\Database\Seeders;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Database\Seeder;
|
||||||
|
|
||||||
|
class ChatGPTDatabaseSeeder extends Seeder
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the database seeds.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function run()
|
||||||
|
{
|
||||||
|
Model::unguard();
|
||||||
|
|
||||||
|
// $this->call("OthersTableSeeder");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Modules\ChatGPT\Support\ModuleInfo;
|
||||||
|
|
||||||
|
if (! function_exists('chatgpt_feature_enabled')) {
|
||||||
|
/**
|
||||||
|
* Check if a feature is enabled in the config.
|
||||||
|
*/
|
||||||
|
function chatgpt_feature_enabled(string $key): bool
|
||||||
|
{
|
||||||
|
return (bool) config(ModuleInfo::nameLower() . ".features.{$key}", false);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,82 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\ChatGPT\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Contracts\Support\Renderable;
|
||||||
|
use Illuminate\Http\RedirectResponse;
|
||||||
|
use Illuminate\Routing\Controller;
|
||||||
|
use Modules\ChatGPT\Http\Requests\StoreChatGptApiSettingRequest;
|
||||||
|
use Modules\ChatGPT\Http\Requests\UpdateChatGptApiSettingRequest;
|
||||||
|
use Modules\ChatGPT\Models\ChatGptApiSetting;
|
||||||
|
|
||||||
|
class ChatGPTController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Display the ChatGPT module settings page.
|
||||||
|
*/
|
||||||
|
public function index(): Renderable
|
||||||
|
{
|
||||||
|
return view('chatgpt::index', [
|
||||||
|
'settings' => ChatGptApiSetting::query()->latest('id')->get(),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store a new encrypted OpenAI API key setting.
|
||||||
|
*/
|
||||||
|
public function store(StoreChatGptApiSettingRequest $request): RedirectResponse
|
||||||
|
{
|
||||||
|
$data = $request->validated();
|
||||||
|
|
||||||
|
ChatGptApiSetting::query()->update(['is_active' => false]);
|
||||||
|
|
||||||
|
ChatGptApiSetting::query()->create([
|
||||||
|
'name' => $data['name'] ?: 'OpenAI API Key',
|
||||||
|
'api_key' => $data['api_key'],
|
||||||
|
'is_active' => (bool) ($data['is_active'] ?? true),
|
||||||
|
]);
|
||||||
|
|
||||||
|
return redirect()
|
||||||
|
->route('chatgpt.index')
|
||||||
|
->with('status', 'OpenAI API key saved.');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update an encrypted OpenAI API key setting.
|
||||||
|
*/
|
||||||
|
public function update(UpdateChatGptApiSettingRequest $request, ChatGptApiSetting $setting): RedirectResponse
|
||||||
|
{
|
||||||
|
$data = $request->validated();
|
||||||
|
|
||||||
|
if ((bool) ($data['is_active'] ?? false)) {
|
||||||
|
ChatGptApiSetting::query()
|
||||||
|
->whereKeyNot($setting->getKey())
|
||||||
|
->update(['is_active' => false]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$setting->name = $data['name'] ?: $setting->name;
|
||||||
|
$setting->is_active = (bool) ($data['is_active'] ?? false);
|
||||||
|
|
||||||
|
if (! empty($data['api_key'])) {
|
||||||
|
$setting->api_key = $data['api_key'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$setting->save();
|
||||||
|
|
||||||
|
return redirect()
|
||||||
|
->route('chatgpt.index')
|
||||||
|
->with('status', 'OpenAI API key updated.');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete an encrypted OpenAI API key setting.
|
||||||
|
*/
|
||||||
|
public function destroy(ChatGptApiSetting $setting): RedirectResponse
|
||||||
|
{
|
||||||
|
$setting->delete();
|
||||||
|
|
||||||
|
return redirect()
|
||||||
|
->route('chatgpt.index')
|
||||||
|
->with('status', 'OpenAI API key deleted.');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\ChatGPT\Http\Requests;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
|
||||||
|
class StoreChatGptApiSettingRequest extends FormRequest
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Determine if the user is authorized to make this request.
|
||||||
|
*/
|
||||||
|
public function authorize(): bool
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the validation rules that apply to the request.
|
||||||
|
*
|
||||||
|
* @return array<string, mixed>
|
||||||
|
*/
|
||||||
|
public function rules(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'name' => ['nullable', 'string', 'max:255'],
|
||||||
|
'api_key' => ['required', 'string', 'min:20', 'max:500'],
|
||||||
|
'is_active' => ['nullable', 'boolean'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\ChatGPT\Http\Requests;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
|
||||||
|
class UpdateChatGptApiSettingRequest extends FormRequest
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Determine if the user is authorized to make this request.
|
||||||
|
*/
|
||||||
|
public function authorize(): bool
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the validation rules that apply to the request.
|
||||||
|
*
|
||||||
|
* @return array<string, mixed>
|
||||||
|
*/
|
||||||
|
public function rules(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'name' => ['nullable', 'string', 'max:255'],
|
||||||
|
'api_key' => ['nullable', 'string', 'min:20', 'max:500'],
|
||||||
|
'is_active' => ['nullable', 'boolean'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\ChatGPT\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class ChatGptApiSetting extends Model
|
||||||
|
{
|
||||||
|
use HasFactory;
|
||||||
|
|
||||||
|
protected $table = 'chatgpt_api_settings';
|
||||||
|
|
||||||
|
protected $fillable = [
|
||||||
|
'name',
|
||||||
|
'api_key',
|
||||||
|
'is_active',
|
||||||
|
];
|
||||||
|
|
||||||
|
protected $casts = [
|
||||||
|
'api_key' => 'encrypted',
|
||||||
|
'is_active' => 'boolean',
|
||||||
|
];
|
||||||
|
|
||||||
|
protected $hidden = [
|
||||||
|
'api_key',
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the currently active OpenAI API setting.
|
||||||
|
*/
|
||||||
|
public static function active(): ?self
|
||||||
|
{
|
||||||
|
return self::query()
|
||||||
|
->where('is_active', true)
|
||||||
|
->latest('id')
|
||||||
|
->first();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return a masked version of the stored API key for display.
|
||||||
|
*/
|
||||||
|
public function maskedApiKey(): string
|
||||||
|
{
|
||||||
|
$key = (string) $this->api_key;
|
||||||
|
|
||||||
|
if ($key === '') {
|
||||||
|
return 'Not set';
|
||||||
|
}
|
||||||
|
|
||||||
|
return substr($key, 0, 7) . '...' . substr($key, -4);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,157 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\ChatGPT\Providers;
|
||||||
|
|
||||||
|
use Config;
|
||||||
|
use Illuminate\Support\Facades\File;
|
||||||
|
use Illuminate\Support\ServiceProvider;
|
||||||
|
use Modules\ChatGPT\Support\ModuleInfo;
|
||||||
|
|
||||||
|
class ChatGPTServiceProvider extends ServiceProvider
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected string $moduleName = 'ChatGPT';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected string $moduleNameLower = 'chatgpt';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the services provided by the provider.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function provides(): array
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Boot the application events.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function boot(): void
|
||||||
|
{
|
||||||
|
$this->registerTranslations();
|
||||||
|
$this->registerConfig();
|
||||||
|
$this->registerViews();
|
||||||
|
$this->registerHelpers();
|
||||||
|
$this->registerCommands();
|
||||||
|
$this->loadMigrationsFrom(module_path(ModuleInfo::name(), 'Database/Migrations'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register the service provider.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function register(): void
|
||||||
|
{
|
||||||
|
$this->app->register(RouteServiceProvider::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register the helpers.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
protected function registerHelpers(): void
|
||||||
|
{
|
||||||
|
foreach (glob(__DIR__ . '/../Helpers/*.php') as $filename) {
|
||||||
|
require_once $filename;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dynamically Register Commands.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function registerCommands(): void
|
||||||
|
{
|
||||||
|
if (! $this->app->runningInConsole()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$commandPath = __DIR__ . '/../Console';
|
||||||
|
$commands = collect(File::allFiles($commandPath))
|
||||||
|
->map(function ($file) {
|
||||||
|
$class = 'Modules\\' . $this->moduleName . '\\Console\\' . $file->getFilenameWithoutExtension();
|
||||||
|
|
||||||
|
return $class;
|
||||||
|
})
|
||||||
|
->filter(function ($class) {
|
||||||
|
return class_exists($class);
|
||||||
|
})
|
||||||
|
->values()
|
||||||
|
->all();
|
||||||
|
$this->commands($commands);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register config.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
protected function registerConfig(): void
|
||||||
|
{
|
||||||
|
$this->publishes([
|
||||||
|
module_path(ModuleInfo::name(), 'Config/config.php') => config_path(ModuleInfo::nameLower() . '.php'),
|
||||||
|
], 'config');
|
||||||
|
$this->mergeConfigFrom(
|
||||||
|
module_path(ModuleInfo::name(), 'Config/config.php'),
|
||||||
|
ModuleInfo::nameLower(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register views.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function registerViews(): void
|
||||||
|
{
|
||||||
|
$viewPath = resource_path('views/modules/' . ModuleInfo::nameLower());
|
||||||
|
$sourcePath = module_path(ModuleInfo::name(), 'Resources/views');
|
||||||
|
$this->publishes([
|
||||||
|
$sourcePath => $viewPath,
|
||||||
|
], ['views', ModuleInfo::nameLower() . '-module-views']);
|
||||||
|
$this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), ModuleInfo::nameLower());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register translations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function registerTranslations(): void
|
||||||
|
{
|
||||||
|
$langPath = resource_path('lang/modules/' . ModuleInfo::nameLower());
|
||||||
|
|
||||||
|
if (is_dir($langPath)) {
|
||||||
|
$this->loadTranslationsFrom($langPath, ModuleInfo::nameLower());
|
||||||
|
} else {
|
||||||
|
$this->loadTranslationsFrom(module_path(ModuleInfo::name(), 'Resources/lang'), ModuleInfo::nameLower());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Regsiter View Paths
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
private function getPublishableViewPaths(): array
|
||||||
|
{
|
||||||
|
$paths = [];
|
||||||
|
foreach (Config::get('view.paths') as $path) {
|
||||||
|
if (is_dir($path . '/modules/' . ModuleInfo::nameLower())) {
|
||||||
|
$paths[] = $path . '/modules/' . ModuleInfo::nameLower();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $paths;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,69 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\ChatGPT\Providers;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
|
||||||
|
use Illuminate\Support\Facades\Route;
|
||||||
|
|
||||||
|
class RouteServiceProvider extends ServiceProvider
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The module namespace to assume when generating URLs to actions.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $moduleNamespace = 'Modules\ChatGPT\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('ChatGPT', '/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('ChatGPT', '/Routes/api.php'));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,171 @@
|
|||||||
|
@extends('chatgpt::layouts.master')
|
||||||
|
|
||||||
|
@section('content')
|
||||||
|
<section class="mx-auto max-w-5xl space-y-6 p-6">
|
||||||
|
<div class="rounded-2xl border border-slate-200 bg-white p-6 shadow-sm">
|
||||||
|
<div class="flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between">
|
||||||
|
<div>
|
||||||
|
<h1 class="text-2xl font-semibold text-slate-900">ChatGPT API Settings</h1>
|
||||||
|
<p class="mt-1 text-sm text-slate-600">
|
||||||
|
Store the OpenAI API key used by the module command. Keys are encrypted at rest by Laravel.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<code class="rounded-lg bg-slate-100 px-3 py-2 text-sm text-slate-700">
|
||||||
|
php artisan chatgpt:delete-api-files
|
||||||
|
</code>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@if (session('status'))
|
||||||
|
<div class="rounded-xl border border-green-200 bg-green-50 px-4 py-3 text-sm font-medium text-green-800">
|
||||||
|
{{ session('status') }}
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
@if ($errors->any())
|
||||||
|
<div class="rounded-xl border border-red-200 bg-red-50 px-4 py-3 text-sm text-red-800">
|
||||||
|
<strong>Unable to save the API key.</strong>
|
||||||
|
<ul class="mt-2 list-disc pl-5">
|
||||||
|
@foreach ($errors->all() as $error)
|
||||||
|
<li>{{ $error }}</li>
|
||||||
|
@endforeach
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
<div class="rounded-2xl border border-slate-200 bg-white p-6 shadow-sm">
|
||||||
|
<h2 class="text-lg font-semibold text-slate-900">Create API Key</h2>
|
||||||
|
|
||||||
|
<form method="POST" action="{{ route('chatgpt.settings.store') }}" class="mt-5 grid gap-4">
|
||||||
|
@csrf
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<label for="name" class="block text-sm font-medium text-slate-700">Name</label>
|
||||||
|
<input
|
||||||
|
id="name"
|
||||||
|
name="name"
|
||||||
|
type="text"
|
||||||
|
value="{{ old('name', 'OpenAI API Key') }}"
|
||||||
|
class="mt-1 w-full rounded-lg border-slate-300 shadow-sm focus:border-blue-500 focus:ring-blue-500"
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<label for="api_key" class="block text-sm font-medium text-slate-700">API Key</label>
|
||||||
|
<input
|
||||||
|
id="api_key"
|
||||||
|
name="api_key"
|
||||||
|
type="password"
|
||||||
|
value=""
|
||||||
|
autocomplete="new-password"
|
||||||
|
required
|
||||||
|
class="mt-1 w-full rounded-lg border-slate-300 shadow-sm focus:border-blue-500 focus:ring-blue-500"
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<label class="inline-flex items-center gap-2 text-sm text-slate-700">
|
||||||
|
<input type="checkbox" name="is_active" value="1" checked class="rounded border-slate-300 text-blue-600 focus:ring-blue-500">
|
||||||
|
Make active key
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<button type="submit" class="rounded-lg bg-blue-600 px-4 py-2 text-sm font-semibold text-white hover:bg-blue-700">
|
||||||
|
Save API Key
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="rounded-2xl border border-slate-200 bg-white p-6 shadow-sm">
|
||||||
|
<h2 class="text-lg font-semibold text-slate-900">Stored API Keys</h2>
|
||||||
|
|
||||||
|
<div class="mt-5 overflow-x-auto">
|
||||||
|
<table class="min-w-full divide-y divide-slate-200 text-sm">
|
||||||
|
<thead class="bg-slate-50 text-left text-xs font-semibold uppercase tracking-wide text-slate-500">
|
||||||
|
<tr>
|
||||||
|
<th class="px-4 py-3">Name</th>
|
||||||
|
<th class="px-4 py-3">Key</th>
|
||||||
|
<th class="px-4 py-3">Active</th>
|
||||||
|
<th class="px-4 py-3">Updated</th>
|
||||||
|
<th class="px-4 py-3 text-right">Actions</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody class="divide-y divide-slate-100 bg-white">
|
||||||
|
@forelse ($settings as $setting)
|
||||||
|
<tr>
|
||||||
|
<td class="px-4 py-4 align-top font-medium text-slate-900">
|
||||||
|
<form id="setting-update-{{ $setting->id }}" method="POST" action="{{ route('chatgpt.settings.update', $setting) }}" class="grid gap-3">
|
||||||
|
@csrf
|
||||||
|
@method('PUT')
|
||||||
|
|
||||||
|
<input
|
||||||
|
name="name"
|
||||||
|
type="text"
|
||||||
|
value="{{ old('name', $setting->name) }}"
|
||||||
|
class="w-full rounded-lg border-slate-300 text-sm shadow-sm focus:border-blue-500 focus:ring-blue-500"
|
||||||
|
>
|
||||||
|
|
||||||
|
<input
|
||||||
|
name="api_key"
|
||||||
|
type="password"
|
||||||
|
value=""
|
||||||
|
autocomplete="new-password"
|
||||||
|
placeholder="Leave blank to keep existing key"
|
||||||
|
class="w-full rounded-lg border-slate-300 text-sm shadow-sm focus:border-blue-500 focus:ring-blue-500"
|
||||||
|
>
|
||||||
|
|
||||||
|
<label class="inline-flex items-center gap-2 text-xs text-slate-600">
|
||||||
|
<input
|
||||||
|
type="checkbox"
|
||||||
|
name="is_active"
|
||||||
|
value="1"
|
||||||
|
@checked($setting->is_active)
|
||||||
|
class="rounded border-slate-300 text-blue-600 focus:ring-blue-500"
|
||||||
|
>
|
||||||
|
Active
|
||||||
|
</label>
|
||||||
|
</form>
|
||||||
|
</td>
|
||||||
|
<td class="px-4 py-4 align-top font-mono text-slate-700">{{ $setting->maskedApiKey() }}</td>
|
||||||
|
<td class="px-4 py-4 align-top">
|
||||||
|
@if ($setting->is_active)
|
||||||
|
<span class="rounded-full bg-green-100 px-2.5 py-1 text-xs font-semibold text-green-800">Yes</span>
|
||||||
|
@else
|
||||||
|
<span class="rounded-full bg-slate-100 px-2.5 py-1 text-xs font-semibold text-slate-600">No</span>
|
||||||
|
@endif
|
||||||
|
</td>
|
||||||
|
<td class="px-4 py-4 align-top text-slate-600">{{ $setting->updated_at?->format('d M Y H:i') }}</td>
|
||||||
|
<td class="px-4 py-4 align-top">
|
||||||
|
<div class="flex justify-end gap-2">
|
||||||
|
<button
|
||||||
|
type="submit"
|
||||||
|
form="setting-update-{{ $setting->id }}"
|
||||||
|
class="rounded-lg bg-blue-600 px-3 py-2 text-xs font-semibold text-white hover:bg-blue-700"
|
||||||
|
>
|
||||||
|
Update
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<form method="POST" action="{{ route('chatgpt.settings.destroy', $setting) }}">
|
||||||
|
@csrf
|
||||||
|
@method('DELETE')
|
||||||
|
<button type="submit" class="rounded-lg bg-red-600 px-3 py-2 text-xs font-semibold text-white hover:bg-red-700">
|
||||||
|
Delete
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
@empty
|
||||||
|
<tr>
|
||||||
|
<td colspan="5" class="px-4 py-8 text-center text-slate-500">
|
||||||
|
No API keys have been stored yet.
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
@endforelse
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
@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 ChatGPT</title>
|
||||||
|
|
||||||
|
{{-- Laravel Mix - CSS File --}}
|
||||||
|
{{-- <link rel="stylesheet" href="{{ mix('css/chatgpt.css') }}"> --}}
|
||||||
|
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
@yield('content')
|
||||||
|
|
||||||
|
{{-- Laravel Mix - JS File --}}
|
||||||
|
{{-- <script src="{{ mix('js/chatgpt.js') }}"></script> --}}
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| 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::middleware('auth:api')->get('/chatgpt', function (Request $request) {
|
||||||
|
return $request->user();
|
||||||
|
});
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Route;
|
||||||
|
use Modules\ChatGPT\Http\Controllers\ChatGPTController;
|
||||||
|
|
||||||
|
Route::middleware(['web', 'auth'])
|
||||||
|
->prefix('chatgpt')
|
||||||
|
->name('chatgpt.')
|
||||||
|
->group(function (): void {
|
||||||
|
Route::get('/', [ChatGPTController::class, 'index'])->name('index');
|
||||||
|
Route::post('/settings', [ChatGPTController::class, 'store'])->name('settings.store');
|
||||||
|
Route::put('/settings/{setting}', [ChatGPTController::class, 'update'])->name('settings.update');
|
||||||
|
Route::delete('/settings/{setting}', [ChatGPTController::class, 'destroy'])->name('settings.destroy');
|
||||||
|
});
|
||||||
@@ -0,0 +1,119 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\ChatGPT\Services;
|
||||||
|
|
||||||
|
use Illuminate\Http\Client\PendingRequest;
|
||||||
|
use Illuminate\Support\Facades\Http;
|
||||||
|
use RuntimeException;
|
||||||
|
|
||||||
|
class OpenAiFileService
|
||||||
|
{
|
||||||
|
private const BASE_URL = 'https://api.openai.com/v1';
|
||||||
|
|
||||||
|
public function __construct(private readonly string $apiKey) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List all OpenAI API files visible to the configured API key.
|
||||||
|
*
|
||||||
|
* @return array<int, array<string, mixed>>
|
||||||
|
*/
|
||||||
|
public function listFiles(): array
|
||||||
|
{
|
||||||
|
$files = [];
|
||||||
|
$after = null;
|
||||||
|
|
||||||
|
do {
|
||||||
|
$query = ['limit' => 100];
|
||||||
|
|
||||||
|
if (is_string($after) && $after !== '') {
|
||||||
|
$query['after'] = $after;
|
||||||
|
}
|
||||||
|
|
||||||
|
$response = $this->client()
|
||||||
|
->get(self::BASE_URL . '/files', $query);
|
||||||
|
|
||||||
|
if ($response->failed()) {
|
||||||
|
throw new RuntimeException('OpenAI file list request failed: ' . $response->body());
|
||||||
|
}
|
||||||
|
|
||||||
|
$payload = $response->json();
|
||||||
|
$batch = $payload['data'] ?? [];
|
||||||
|
|
||||||
|
foreach ($batch as $file) {
|
||||||
|
if (is_array($file)) {
|
||||||
|
$files[] = $file;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$hasMore = (bool) ($payload['has_more'] ?? false);
|
||||||
|
$after = $payload['last_id'] ?? null;
|
||||||
|
} while ($hasMore && is_string($after) && $after !== '');
|
||||||
|
|
||||||
|
return $files;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete one OpenAI API file by ID.
|
||||||
|
*
|
||||||
|
* @return array<string, mixed>
|
||||||
|
*/
|
||||||
|
public function deleteFile(string $fileId): array
|
||||||
|
{
|
||||||
|
$response = $this->client()
|
||||||
|
->delete(self::BASE_URL . '/files/' . rawurlencode($fileId));
|
||||||
|
|
||||||
|
if ($response->failed()) {
|
||||||
|
throw new RuntimeException("OpenAI file delete request failed for {$fileId}: " . $response->body());
|
||||||
|
}
|
||||||
|
|
||||||
|
return $response->json() ?? [];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete every OpenAI API file visible to the configured API key.
|
||||||
|
*
|
||||||
|
* @return array{listed:int, deleted:int, failed:int, failures:array<int, array{file_id:string, error:string}>}
|
||||||
|
*/
|
||||||
|
public function deleteAllFiles(): array
|
||||||
|
{
|
||||||
|
$files = $this->listFiles();
|
||||||
|
$deleted = 0;
|
||||||
|
$failures = [];
|
||||||
|
|
||||||
|
foreach ($files as $file) {
|
||||||
|
$fileId = (string) ($file['id'] ?? '');
|
||||||
|
|
||||||
|
if ($fileId === '') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
$this->deleteFile($fileId);
|
||||||
|
$deleted++;
|
||||||
|
} catch (RuntimeException $exception) {
|
||||||
|
$failures[] = [
|
||||||
|
'file_id' => $fileId,
|
||||||
|
'error' => $exception->getMessage(),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return [
|
||||||
|
'listed' => count($files),
|
||||||
|
'deleted' => $deleted,
|
||||||
|
'failed' => count($failures),
|
||||||
|
'failures' => $failures,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Build the authenticated OpenAI HTTP client.
|
||||||
|
*/
|
||||||
|
private function client(): PendingRequest
|
||||||
|
{
|
||||||
|
return Http::withToken($this->apiKey)
|
||||||
|
->acceptJson()
|
||||||
|
->timeout(60)
|
||||||
|
->retry(2, 500);
|
||||||
|
}
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user