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,105 @@
<?php
namespace Modules\Order\Http\Controllers;
use App\Http\Controllers\Controller;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Modules\Customer\Repositories\CustomerInterface;
use Modules\Product\Repositories\ProductInterface;
use Modules\Supplier\Repositories\SupplierInterface;
class OrderController extends Controller
{
private $supplierRepository;
private $productRepository;
private $customerRepository;
public function __construct(SupplierInterface $supplierRepository, ProductInterface $productRepository, CustomerInterface $customerRepository )
{
$this->supplierRepository = $supplierRepository;
$this->productRepository = $productRepository;
$this->customerRepository = $customerRepository;
}
/**
* Display a listing of the resource.
*/
public function index()
{
$data['title'] = 'Order List';
$data['orders'] = [];
return view('order::order.index', $data);
}
/**
* Show the form for creating a new resource.
*/
public function create()
{
$data['title'] = 'Create Order';
$data['productList'] = $this->productRepository->pluck();
$data['supplierList'] = $this->supplierRepository->pluck();
$data['customerList'] = $this->customerRepository->pluck();
return view('order::order.create', $data);
}
/**
* Store a newly created resource in storage.
*/
public function store(Request $request): RedirectResponse
{
//
}
/**
* Show the specified resource.
*/
public function show($id)
{
return view('order::order.show');
}
/**
* Show the form for editing the specified resource.
*/
public function edit($id)
{
return view('order::order.edit');
}
/**
* Update the specified resource in storage.
*/
public function update(Request $request, $id): RedirectResponse
{
//
}
/**
* Remove the specified resource from storage.
*/
public function destroy($id)
{
//
}
public function cloneProduct(Request $request)
{
$data = [];
$numInc = $request->numberInc;
$script = true;
$productList= $this->productRepository->pluck();
return response()->json([
'view' => view('order::order.clone-product', compact('data', 'numInc', 'script', 'productList'))->render(),
]);
}
}

View File

View File

View File

@ -0,0 +1,24 @@
<?php
namespace Modules\Order\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Modules\Order\Database\Factories\OrderFactory;
class Order extends Model
{
use HasFactory;
/**
* The attributes that are mass assignable.
*/
protected $table = 'tbl_orders';
protected $guarded = [];
protected static function newFactory(): OrderFactory
{
//return OrderFactory::new();
}
}

View File

@ -0,0 +1,22 @@
<?php
namespace Modules\Order\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Modules\Order\Database\Factories\OrderDetailFactory;
class OrderDetail extends Model
{
use HasFactory;
/**
* The attributes that are mass assignable.
*/
protected $fillable = [];
protected static function newFactory(): OrderDetailFactory
{
//return OrderDetailFactory::new();
}
}

View File

View File

View File

@ -0,0 +1,114 @@
<?php
namespace Modules\Order\Providers;
use Illuminate\Support\Facades\Blade;
use Illuminate\Support\ServiceProvider;
class OrderServiceProvider extends ServiceProvider
{
protected string $moduleName = 'Order';
protected string $moduleNameLower = 'order';
/**
* 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 . '\\' . 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\Order\Providers;
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
use Illuminate\Support\Facades\Route;
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('Order', '/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('Order', '/routes/api.php'));
}
}

View File

View File

@ -0,0 +1,15 @@
<?php
namespace Modules\Employee\Repositories;
interface EmployeeInterface
{
public function findAll();
public function getEmployeeById($employeeId);
public function getEmployeeByEmail($email);
public function delete($employeeId);
public function create($EmployeeDetails);
public function update($employeeId, array $newDetails);
public function pluck();
}

View File

@ -0,0 +1,64 @@
<?php
namespace Modules\Employee\Repositories;
use Modules\Employee\Models\Employee;
class EmployeeRepository implements EmployeeInterface
{
public function findAll()
{
return Employee::when(true, function ($query) {
if (auth()->user()->hasRole('employee')) {
$user = \Auth::user();
dd($user, $user->employee_id);
$query->where('id', $user->employee_id);
}
})->paginate(20);
}
public function getEmployeeById($employeeId)
{
return Employee::findOrFail($employeeId);
}
public function getEmployeeByEmail($email)
{
return Employee::where('email', $email)->first();
}
public function delete($employeeId)
{
Employee::destroy($employeeId);
}
public function create($employeeDetails)
{
return Employee::create($employeeDetails);
}
public function update($employeeId, array $newDetails)
{
return Employee::whereId($employeeId)->update($newDetails);
}
public function pluck()
{
return Employee::pluck('first_name', 'id');
}
// public function uploadImage($file)
// {
// if ($req->file()) {
// $fileName = time() . '_' . $req->file->getClientOriginalName();
// $filePath = $req->file('file')->storeAs('uploads', $fileName, 'public');
// $fileModel->name = time() . '_' . $req->file->getClientOriginalName();
// $fileModel->file_path = '/storage/' . $filePath;
// $fileModel->save();
// return back()
// ->with('success', 'File has been uploaded.')
// ->with('file', $fileName);
// }
// }
}

View File

@ -0,0 +1,15 @@
<?php
namespace Modules\Order\Repositories;
interface OrderInterface
{
public function findAll();
public function getOrderById($OrderId);
public function getOrderByEmail($email);
public function delete($OrderId);
public function create($OrderDetails);
public function update($OrderId, array $newDetails);
public function pluck();
}

View File

@ -0,0 +1,46 @@
<?php
namespace Modules\Order\Repositories;
use Modules\Order\Models\Order;
class OrderRepository implements OrderInterface
{
public function findAll()
{
return Order::when(true, function ($query) {
})->paginate(20);
}
public function getOrderById($OrderId)
{
return Order::findOrFail($OrderId);
}
public function getOrderByEmail($email)
{
return Order::where('email', $email)->first();
}
public function delete($OrderId)
{
Order::destroy($OrderId);
}
public function create($OrderDetails)
{
return Order::create($OrderDetails);
}
public function update($OrderId, array $newDetails)
{
return Order::whereId($OrderId)->update($newDetails);
}
public function pluck()
{
return Order::pluck('name', 'id');
}
}