firstcommit

This commit is contained in:
2025-08-17 16:23:14 +05:45
commit 76bf4c0a18
2648 changed files with 362795 additions and 0 deletions

View File

@@ -0,0 +1,119 @@
<?php
namespace Modules\Subscription\app\Http\Controllers;
use Illuminate\Http\Request;
use App\Services\LogoService;
use Illuminate\Http\Response;
use App\Http\Controllers\Controller;
use App\Jobs\SendSubscriptionMailJob;
use Illuminate\Http\RedirectResponse;
use Modules\Setting\app\Models\Setting;
use Modules\Subscription\app\Repositories\SubscriptionRepository;
class SubscriptionController extends Controller
{
protected $subscriptionRepository;
public function __construct()
{
$this->subscriptionRepository = new SubscriptionRepository();
}
/**
* Display a listing of the resource.
*/
public function index(Request $request)
{
$perPage = $request->has('per-page') ? $request->input('per-page') : null;
$filter = $request->has('filter') ? $request->input('filter') : [];
$subscription = $this->subscriptionRepository->allSubscriptionsEmail($perPage, $filter);
return view('subscription::index', compact('subscription'));
}
/**
* Show the form for creating a new resource.
*/
public function create()
{
return view('subscription::create');
}
/**
* Store a newly created resource in storage.
*/
public function store(LogoService $logoService, Request $request)
{
$validated = $request->validate([
'email' => 'required|email|unique:subscriptions,email',
]);
try {
$subscription = $this->subscriptionRepository->storeSubscription($validated);
$thumbImage = asset('frontend/images/mail/thumb.png');
dispatch(new SendSubscriptionMailJob(
citizenEmail: $subscription->email,
siteLogo: $logoService->getSiteLogo(),
thumbImage: $thumbImage ?? ''
));
toastr()->success('Thanks for subscribe');
return redirect()->route('home');
} catch (\Throwable $th) {
report($th);
toastr()->error('Something went wrong.');
return back()->withInput();
}
}
/**
* Show the specified resource.
*/
public function show($id)
{
return view('subscription::show');
}
/**
* Show the form for editing the specified resource.
*/
public function edit($id)
{
return view('subscription::edit');
}
/**
* Update the specified resource in storage.
*/
public function update(Request $request, $id): RedirectResponse
{
//
}
/**
* Remove the specified resource from storage.
*/
public function destroy($uuid)
{
try {
$subscription = $this->subscriptionRepository->deleteSubscriptionEmail($uuid);
if (!$subscription) {
toastr()->error('Subscription email not found.');
return back();
}
toastr()->success('Subscription email deleted successfully.');
return redirect()->route('cms.subscription.index');
} catch (\Throwable $th) {
report($th);
toastr()->error('Something went wrong.');
return back();
}
}
}

View File

@@ -0,0 +1,26 @@
<?php
namespace Modules\Subscription\app\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class CreateSubscriptionRequest extends FormRequest
{
/**
* Get the validation rules that apply to the request.
*/
public function rules(): array
{
return [
'email' => 'required|email',
];
}
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return true;
}
}

View File

View File

@@ -0,0 +1,28 @@
<?php
namespace Modules\Subscription\app\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Modules\Subscription\Database\factories\SubscriptionFactory;
class Subscription extends Model
{
// use HasFactory;
use SoftDeletes;
/**
* The attributes that are mass assignable.
*/
protected $fillable = [
'uuid',
'email',
];
protected static function newFactory(): SubscriptionFactory
{
//return SubscriptionFactory::new();
}
}

View File

@@ -0,0 +1,59 @@
<?php
namespace Modules\Subscription\app\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.
*/
protected string $moduleNamespace = 'Modules\Subscription\app\Http\Controllers';
/**
* Called before routes are registered.
*
* Register any model bindings or pattern based filters.
*/
public function boot(): void
{
parent::boot();
}
/**
* Define the routes for the application.
*/
public function map(): void
{
$this->mapApiRoutes();
$this->mapWebRoutes();
}
/**
* Define the "web" routes for the application.
*
* These routes all receive session state, CSRF protection, etc.
*/
protected function mapWebRoutes(): void
{
Route::middleware('web')
->namespace($this->moduleNamespace)
->group(module_path('Subscription', '/routes/web.php'));
}
/**
* Define the "api" routes for the application.
*
* These routes are typically stateless.
*/
protected function mapApiRoutes(): void
{
Route::prefix('api')
->middleware('api')
->namespace($this->moduleNamespace)
->group(module_path('Subscription', '/routes/api.php'));
}
}

View File

@@ -0,0 +1,114 @@
<?php
namespace Modules\Subscription\app\Providers;
use Illuminate\Support\Facades\Blade;
use Illuminate\Support\ServiceProvider;
class SubscriptionServiceProvider extends ServiceProvider
{
protected string $moduleName = 'Subscription';
protected string $moduleNameLower = 'subscription';
/**
* Boot the application events.
*/
public function boot(): void
{
$this->registerCommands();
$this->registerCommandSchedules();
$this->registerTranslations();
$this->registerConfig();
$this->registerViews();
$this->loadMigrationsFrom(module_path($this->moduleName, 'database/migrations'));
}
/**
* Register the service provider.
*/
public function register(): void
{
$this->app->register(RouteServiceProvider::class);
}
/**
* Register commands in the format of Command::class
*/
protected function registerCommands(): void
{
// $this->commands([]);
}
/**
* Register command Schedules.
*/
protected function registerCommandSchedules(): void
{
// $this->app->booted(function () {
// $schedule = $this->app->make(Schedule::class);
// $schedule->command('inspire')->hourly();
// });
}
/**
* Register translations.
*/
public function registerTranslations(): void
{
$langPath = resource_path('lang/modules/'.$this->moduleNameLower);
if (is_dir($langPath)) {
$this->loadTranslationsFrom($langPath, $this->moduleNameLower);
$this->loadJsonTranslationsFrom($langPath);
} else {
$this->loadTranslationsFrom(module_path($this->moduleName, 'lang'), $this->moduleNameLower);
$this->loadJsonTranslationsFrom(module_path($this->moduleName, 'lang'));
}
}
/**
* Register config.
*/
protected function registerConfig(): void
{
$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.
*/
public function registerViews(): void
{
$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);
$componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.config('modules.paths.generator.component-class.path'));
Blade::componentNamespace($componentNamespace, $this->moduleNameLower);
}
/**
* Get the services provided by the provider.
*/
public function provides(): array
{
return [];
}
private function getPublishableViewPaths(): array
{
$paths = [];
foreach (config('view.paths') as $path) {
if (is_dir($path.'/modules/'.$this->moduleNameLower)) {
$paths[] = $path.'/modules/'.$this->moduleNameLower;
}
}
return $paths;
}
}

View File

@@ -0,0 +1,68 @@
<?php
namespace Modules\Subscription\app\Repositories;
use Illuminate\Support\Str;
use Illuminate\Support\Facades\DB;
use Modules\Subscription\app\Models\Subscription;
class SubscriptionRepository
{
public function allSubscriptionsEmail($perPage = null, $filter = [], $sort = ['by' => 'id', 'sort' => 'DESC'])
{
return Subscription::when(array_keys($filter, true), function ($query) use ($filter) {
if (!empty($filter['email'])) {
$query->where('email', $filter['email']);
}
})
->orderBy($sort['by'], $sort['sort'])
->paginate($perPage ?: env('PAGE_LIMIT', 999));
}
public function storeSubscription($validated)
{
$result = false;
DB::beginTransaction();
try {
$validated['uuid'] = Str::uuid();
$result = Subscription::create($validated);
if ($result) {
DB::commit();
}
} catch (\Throwable $th) {
report($th);
DB::rollback();
}
return $result;
}
public function findSubscriptionEmailByUuid($uuid)
{
return Subscription::where('uuid', $uuid)->first();
}
public function deleteSubscriptionEmail($uuid)
{
DB::beginTransaction();
try {
$subscription = $this->findSubscriptionEmailByUuid($uuid);
if (!$subscription) {
return null;
}
$subscription->delete();
DB::commit();
return true;
} catch (\Throwable $th) {
DB::rollback();
report($th);
return null;
}
}
}

View File

@@ -0,0 +1,31 @@
{
"name": "nwidart/subscription",
"description": "",
"authors": [
{
"name": "Nicolas Widart",
"email": "n.widart@gmail.com"
}
],
"extra": {
"laravel": {
"providers": [],
"aliases": {
}
}
},
"autoload": {
"psr-4": {
"Modules\\Subscription\\": "",
"Modules\\Subscription\\App\\": "app/",
"Modules\\Subscription\\Database\\Factories\\": "database/factories/",
"Modules\\Subscription\\Database\\Seeders\\": "database/seeders/"
}
},
"autoload-dev": {
"psr-4": {
"Modules\\Subscription\\Tests\\": "tests/"
}
}
}

View File

View File

@@ -0,0 +1,5 @@
<?php
return [
'name' => 'Subscription',
];

View File

@@ -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('subscriptions', function (Blueprint $table) {
$table->id();
$table->uuid();
$table->string('email');
$table->softDeletes();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('subscriptions');
}
};

View File

@@ -0,0 +1,32 @@
<?php
namespace Modules\Subscription\database\seeders;
use Illuminate\Support\Str;
use Illuminate\Database\Seeder;
use Modules\Subscription\app\Models\Subscription;
class SubscriptionDatabaseSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
$subscription = [
[
'email' => 'admin@jhigutech.com',
],
[
'email' => 'staff@jhigutech.com',
],
];
foreach ($subscription as $subscription) {
$subscription = Subscription::create([
'uuid' => Str::uuid(),
'email' => $subscription['email'],
]);
}
}
}

View File

View File

@@ -0,0 +1,11 @@
{
"name": "Subscription",
"alias": "subscription",
"description": "",
"keywords": [],
"priority": 0,
"providers": [
"Modules\\Subscription\\app\\Providers\\SubscriptionServiceProvider"
],
"files": []
}

View File

@@ -0,0 +1,15 @@
{
"private": true,
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build"
},
"devDependencies": {
"axios": "^1.1.2",
"laravel-vite-plugin": "^0.7.5",
"sass": "^1.69.5",
"postcss": "^8.3.7",
"vite": "^4.0.0"
}
}

View File

@@ -0,0 +1,110 @@
@extends('admin::layouts.master')
@section('title')
Subscription
@endsection
@section('breadcrumb')
@php
$breadcrumbData = [
[
'title' => 'Subscription',
'link' => 'null',
],
[
'title' => 'Dashboard',
'link' => route('dashboard'),
],
[
'title' => 'Subscription',
'link' => null,
],
];
@endphp
@include('admin::layouts.partials.breadcrumb', $breadcrumbData)
@endsection
@section('content')
<!-- banners List Table -->
<div class="card">
<div class="row">
<div class="col-md-6">
<h4 class="card-header">List of Subscription Email</h4>
</div>
{{-- <div class="col-md-6">
<div class="flex-column flex-md-row">
<div class="dt-action-buttons text-end pt-3 px-3">
<div class="dt-buttons btn-group flex-wrap">
<a href="{{ route('cms.banners.create') }}"
class="btn btn-secondary create-new btn-primary d-none d-sm-inline-block text-white">
<i class="bx bx-plus me-sm-1"></i>
Add New
</a>
</div>
</div>
</div>
</div> --}}
</div>
<div class="card-datatable table-responsive">
<table class="table">
<thead class="table-light">
<tr>
<th>S.N</th>
<th>Email</th>
<th>Created At</th>
<th>Actions</th>
</tr>
</thead>
<tbody class="table-border-bottom-0">
@if (count($subscription) > 0)
@foreach ($subscription ?? [] as $subscription)
<tr>
<td>
#{{ $loop->iteration }}
</td>
<td>
<div class="d-flex align-items-center me-3">
<div class="card-title mb-0 px-3">
<h6 class="mb-0"> {{ $subscription->email }}</h6>
</div>
</div>
</td>
<td>
{{ $subscription->created_at->toFormattedDateString() }}
</td>
<td>
<form method="POST"
action="{{ route('cms.subscription.delete', ['uuid' => $subscription->uuid]) }}"
id="deleteForm_{{ $subscription->uuid }}" class="dropdown-item">
@csrf
@method('DELETE')
<button type="submit" class="border-0 bg-transparent deleteBtn"
style="color:inherit"><i class="bx bx-trash me-1"></i> </button>
</form>
</td>
</tr>
@endforeach
@else
<tr>
<td colspan="7">No record found.</td>
</tr>
@endif
</tbody>
</table>
</div>
<div class="px-3">
{{-- {{ $subscription->links('admin::layouts.partials.pagination') }} --}}
</div>
</div>
@endsection
{{-- style --}}
@push('required-styles')
@include('admin::vendor.dataTables.style')
@endpush
{{-- script --}}
@push('required-scripts')
@include('admin::vendor.dataTables.script')
@endpush

View File

@@ -0,0 +1,29 @@
<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="csrf-token" content="{{ csrf_token() }}">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Subscription Module - {{ config('app.name', 'Laravel') }}</title>
<meta name="description" content="{{ $description ?? '' }}">
<meta name="keywords" content="{{ $keywords ?? '' }}">
<meta name="author" content="{{ $author ?? '' }}">
<!-- Fonts -->
<link rel="preconnect" href="https://fonts.bunny.net">
<link href="https://fonts.bunny.net/css?family=figtree:400,500,600&display=swap" rel="stylesheet" />
{{-- Vite CSS --}}
{{-- {{ module_vite('build-subscription', 'resources/assets/sass/app.scss') }} --}}
</head>
<body>
@yield('content')
{{-- Vite JS --}}
{{-- {{ module_vite('build-subscription', 'resources/assets/js/app.js') }} --}}
</body>

View File

View File

@@ -0,0 +1,19 @@
<?php
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;
/*
|--------------------------------------------------------------------------
| 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:sanctum'])->prefix('v1')->name('api.')->group(function () {
Route::get('subscription', fn (Request $request) => $request->user())->name('subscription');
});

View File

@@ -0,0 +1,42 @@
<?php
use Illuminate\Support\Facades\Route;
use Modules\Subscription\app\Http\Controllers\SubscriptionController;
/*
|--------------------------------------------------------------------------
| 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::group([], function () {
Route::post('subscriptions/store', [SubscriptionController::class, 'store'])->name('subscription.store');
// Route::resource('subscription', SubscriptionController::class)->names('subscription');
});
Route::group(
[
'prefix' => 'apanel',
'middleware' => ['auth'],
'as' => 'cms.',
],
function () {
Route::group(
[
'prefix' => 'cms',
'as' => 'subscription.',
'controller' => 'SubscriptionController',
],
function () {
Route::get('subscription', 'index')->name('index');
Route::delete('subscription/{uuid}/delete', 'destroy')->name('delete');
}
);
}
);

View File

View File

@@ -0,0 +1,26 @@
import { defineConfig } from 'vite';
import laravel from 'laravel-vite-plugin';
export default defineConfig({
build: {
outDir: '../../public/build-subscription',
emptyOutDir: true,
manifest: true,
},
plugins: [
laravel({
publicDirectory: '../../public',
buildDirectory: 'build-subscription',
input: [
__dirname + '/resources/assets/sass/app.scss',
__dirname + '/resources/assets/js/app.js'
],
refresh: true,
}),
],
});
//export const paths = [
// 'Modules/$STUDLY_NAME$/resources/assets/sass/app.scss',
// 'Modules/$STUDLY_NAME$/resources/assets/js/app.js',
//];