first commit

This commit is contained in:
Sampanna Rimal
2024-08-27 17:48:06 +05:45
commit 53c0140f58
10839 changed files with 1125847 additions and 0 deletions

View File

@ -0,0 +1,114 @@
<?php
namespace Modules\Meeting\Http\Controllers;
use App\Http\Controllers\Controller;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Modules\Employee\Repositories\EmployeeInterface;
use Modules\Employee\Repositories\EmployeeRepository;
use Modules\Meeting\Repositories\MeetingInterface;
use Modules\Meeting\Repositories\MeetingRepository;
use Modules\PMS\Repositories\ClientInterface;
use Modules\PMS\Repositories\ClientRepository;
class MeetingController extends Controller
{
private $meetingRepository;
private $employeeRepository;
private $clientRepository;
/**
* Display a listing of the resource.
*/
public function __construct(
MeetingInterface $meetingRepository,
EmployeeInterface $employeeRepository,
ClientInterface $clientRepository
) {
$this->meetingRepository = $meetingRepository;
$this->employeeRepository = $employeeRepository;
$this->clientRepository = $clientRepository;
}
public function index()
{
$data['title'] = 'Meeting Lists';
$data['meetingLists'] = $this->meetingRepository->findAll();
return view('meeting::meeting.index', $data);
}
/**
* Show the form for creating a new resource.
*/
public function create()
{
$data['title'] = 'Create Meeting';
$data['editable'] = false;
$data['memberList'] = $this->employeeRepository->pluck();
$data['clientList'] = $this->clientRepository->pluck();
return view('meeting::meeting.create', $data);
}
/**
* Store a newly created resource in storage.
*/
public function store(Request $request): RedirectResponse
{
try {
$this->meetingRepository->create($request->all());
toastr()->success('Meeting created successfully');
} catch (\Throwable $th) {
toastr()->error($th->getMessage());
}
return redirect()->route('meeting.index');
}
/**
* Show the specified resource.
*/
public function show($id)
{
$data['title'] = 'Meeting Details';
$data['item'] = $this->meetingRepository->getMeetingById($id);
return view('meeting::meeting.show', $data);
}
/**
* Show the form for editing the specified resource.
*/
public function edit($id)
{
$data['title'] = 'Edit Leave';
$data['editable'] = true;
$data['meeting'] = $this->meetingRepository->getMeetingById($id);
return view('meeting::edit', $data);
}
/**
* Update the specified resource in storage.
*/
public function update(Request $request, $id): RedirectResponse
{
$inputData = $request->except(['_method', '_token']);
$this->meetingRepository->update($id, $inputData);
toastr()->success('Meeting Updated Succesfully');
return redirect()->route('meeting.index');
}
/**
* Remove the specified resource from storage.
*/
public function destroy($id)
{
$this->meetingRepository->delete($id);
toastr()->success('Meeting Deleted Succesfully');
}
}

View File

View File

@ -0,0 +1,41 @@
<?php
namespace Modules\Meeting\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Modules\PMS\Models\Client;
class Meeting extends Model
{
use HasFactory;
/**
* The attributes that are mass assignable.
*/
protected $table = 'tbl_meetings';
protected $fillable = [
'title',
'date',
'meeting_with',
'client_id',
'members',
'start_time',
'end_time',
'location',
'description',
];
protected $casts = [
'members' => 'array',
'date' => 'date',
];
public $appends = [];
public function client()
{
return $this->belongsTo(Client::class, 'client_id');
}
}

View File

View File

View File

@ -0,0 +1,117 @@
<?php
namespace Modules\Meeting\Providers;
use Illuminate\Support\Facades\Blade;
use Illuminate\Support\ServiceProvider;
use Modules\Meeting\Repositories\MeetingInterface;
use Modules\Meeting\Repositories\MeetingRepository;
class MeetingServiceProvider extends ServiceProvider
{
protected string $moduleName = 'Meeting';
protected string $moduleNameLower = 'meeting';
/**
* 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->bind(MeetingInterface::class, MeetingRepository::class);
$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.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder','')));
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,49 @@
<?php
namespace Modules\Meeting\Providers;
use Illuminate\Support\Facades\Route;
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
class RouteServiceProvider extends ServiceProvider
{
/**
* 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')->group(module_path('Meeting', '/routes/web.php'));
}
/**
* Define the "api" routes for the application.
*
* These routes are typically stateless.
*/
protected function mapApiRoutes(): void
{
Route::middleware('api')->prefix('api')->name('api.')->group(module_path('Meeting', '/routes/api.php'));
}
}

View File

@ -0,0 +1,12 @@
<?php
namespace Modules\Meeting\Repositories;
interface MeetingInterface
{
public function findAll();
public function getMeetingById($meetingId);
public function delete($meetingId);
public function create(array $meetingDetails);
public function update($meetingId, array $newDetails);
}

View File

@ -0,0 +1,35 @@
<?php
namespace Modules\Meeting\Repositories;
use Modules\Meeting\Models\Meeting;
class MeetingRepository implements MeetingInterface
{
public function findAll()
{
return Meeting::get();
}
public function getMeetingById($meetingId)
{
return Meeting::findOrFail($meetingId);
}
public function delete($meetingId)
{
Meeting::destroy($meetingId);
}
public function create(array $meetingDetails)
{
return Meeting::create($meetingDetails);
}
public function update($meetingId, array $newDetails)
{
return Meeting::whereId($meetingId)->update($newDetails);
}
}