firstcommit
This commit is contained in:
0
Modules/Estimate/app/Http/Controllers/.gitkeep
Normal file
0
Modules/Estimate/app/Http/Controllers/.gitkeep
Normal file
194
Modules/Estimate/app/Http/Controllers/EstimateController.php
Normal file
194
Modules/Estimate/app/Http/Controllers/EstimateController.php
Normal file
@ -0,0 +1,194 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Estimate\Http\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Modules\Billing\Repositories\BillingComponentInterface;
|
||||
use Modules\Customer\Repositories\CustomerInterface;
|
||||
use Modules\Estimate\Models\Estimate;
|
||||
use Modules\Estimate\Models\EstimateDetail;
|
||||
use Modules\Estimate\Repositories\EstimateDetailInterface;
|
||||
use Modules\Estimate\Repositories\EstimateInterface;
|
||||
|
||||
class EstimateController extends Controller
|
||||
{
|
||||
private $estimateRepository;
|
||||
private $estimateDetailRepository;
|
||||
private $customerRepository;
|
||||
private $billingComponentRepository;
|
||||
|
||||
public function __construct(
|
||||
EstimateInterface $estimateRepository,
|
||||
BillingComponentInterface $billingComponentRepository,
|
||||
CustomerInterface $customerRepository
|
||||
) {
|
||||
$this->estimateRepository = $estimateRepository;
|
||||
$this->customerRepository = $customerRepository;
|
||||
$this->billingComponentRepository = $billingComponentRepository;
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$data['title'] = 'Estimate List';
|
||||
$data['statusList'] = Estimate::APPROVAL_STATUS;
|
||||
$data['estimates'] = $this->estimateRepository->findAll();
|
||||
return view('estimate::estimate.index', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
$data['title'] = 'Create Estimate';
|
||||
$data['editable'] = false;
|
||||
$data['customerList'] = $this->customerRepository->pluck();
|
||||
$data['billingComponentList'] = $this->billingComponentRepository->pluck();
|
||||
return view('estimate::estimate.create', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function store(Request $request): RedirectResponse
|
||||
{
|
||||
|
||||
$request->merge([
|
||||
'approval_status' => 1,
|
||||
]);
|
||||
|
||||
try {
|
||||
|
||||
DB::beginTransaction();
|
||||
|
||||
$estimateData = $request->only(Estimate::getFillableFields());
|
||||
|
||||
$estimate = $this->estimateRepository->create($estimateData);
|
||||
|
||||
$estimateDetails = json_decode($request->estimateDetails);
|
||||
|
||||
foreach ($estimateDetails as $item) {
|
||||
|
||||
$estimateDetailData = [
|
||||
'estimate_id' => $estimate->id,
|
||||
'billing_component_id' => $item->billing_component_id,
|
||||
'price' => $item->price,
|
||||
'qty' => $item->qty,
|
||||
'tax_amount' => $item->tax_amount,
|
||||
];
|
||||
|
||||
EstimateDetail::create($estimateDetailData);
|
||||
|
||||
}
|
||||
|
||||
toastr()->success('Estimate created succesfully');
|
||||
|
||||
DB::commit();
|
||||
|
||||
} catch (\Throwable $th) {
|
||||
|
||||
echo $th->getMessage();
|
||||
|
||||
DB::rollback();
|
||||
|
||||
toastr()->error($th->getMessage());
|
||||
|
||||
}
|
||||
|
||||
return redirect()->route('estimate.index');
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the specified resource.
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
$data['title'] = 'Show Estimate';
|
||||
$data['estimate'] = $this->estimateRepository->getEstimateById($id);
|
||||
$data['statusList'] = Estimate::APPROVAL_STATUS;
|
||||
$data['customerList'] = $this->customerRepository->pluck();
|
||||
return view('estimate::estimate.show', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
$data['title'] = 'Edit Estimate';
|
||||
$data['editable'] = true;
|
||||
$data['estimate'] = $this->estimateRepository->getEstimateById($id);
|
||||
$data['customerList'] = $this->customerRepository->pluck();
|
||||
$data['billingComponentList'] = $this->billingComponentRepository->pluck();
|
||||
return view('estimate::estimate.edit', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function update(Request $request, $id): RedirectResponse
|
||||
{
|
||||
$estimateData = $request->only(Estimate::getFillableFields());
|
||||
|
||||
try {
|
||||
|
||||
$this->estimateRepository->update($id, $estimateData);
|
||||
|
||||
flash()->success('Estimate updated succesfully');
|
||||
|
||||
} catch (\Throwable $th) {
|
||||
|
||||
echo $th->getMessage();
|
||||
|
||||
flash()->error($th->getMessage());
|
||||
}
|
||||
|
||||
return redirect()->route('estimate.index');
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
try {
|
||||
$EstimateModel = $this->estimateRepository->getEstimateById($id);
|
||||
|
||||
$EstimateModel->delete();
|
||||
|
||||
flash()->success('Estimate deleted succesfully');
|
||||
|
||||
} catch (\Throwable $th) {
|
||||
|
||||
flash()->error($th->getMessage());
|
||||
}
|
||||
|
||||
return response()->json(['status' => true, 'message' => 'Estimate deleted succesfully']);
|
||||
|
||||
}
|
||||
|
||||
public function changeStatus(Request $request)
|
||||
{
|
||||
try {
|
||||
$estimate = $this->estimateRepository->getEstimateById($request->estimate_id);
|
||||
$estimate->update([
|
||||
'approval_status' => $request->approval_status,
|
||||
'approval_remarks' => $request->approval_remarks,
|
||||
'approval_on' => now(),
|
||||
'approval_by' => auth()->user()->id,
|
||||
]);
|
||||
|
||||
return redirect()->back();
|
||||
|
||||
} catch (\Throwable $th) {
|
||||
flash()->error($th->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,129 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Estimate\Http\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Modules\Customer\Repositories\CustomerInterface;
|
||||
use Modules\Estimate\Models\EstimateDetail;
|
||||
use Modules\Estimate\Repositories\EstimateDetailInterface;
|
||||
|
||||
class EstimateDetailController extends Controller
|
||||
{
|
||||
private $estimateDetailRepository;
|
||||
private $customerRepository;
|
||||
|
||||
public function __construct(
|
||||
EstimateDetailInterface $estimateDetailRepository,
|
||||
CustomerInterface $customerRepository
|
||||
) {
|
||||
$this->estimateDetailRepository = $estimateDetailRepository;
|
||||
$this->customerRepository = $customerRepository;
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$data['title'] = 'Estimate Detail List';
|
||||
$data['estimateDetails'] = $this->estimateDetailRepository->findAll();
|
||||
return view('estimate::estimateDetail.index', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
$data['title'] = 'Create EstimateDetail';
|
||||
$data['editable'] = false;
|
||||
$data['customerList'] = $this->customerRepository->pluck();
|
||||
return view('estimate::estimateDetail.create', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function store(Request $request): RedirectResponse
|
||||
{
|
||||
try {
|
||||
|
||||
$inputData = $request->all();
|
||||
|
||||
$this->estimateDetailRepository->create($inputData);
|
||||
|
||||
toastr()->success('EstimateDetail created succesfully');
|
||||
|
||||
} catch (\Throwable $th) {
|
||||
|
||||
toastr()->error($th->getMessage());
|
||||
}
|
||||
|
||||
return redirect()->route('estimateDetail.index');
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the specified resource.
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
$data['title'] = 'Show EstimateDetail';
|
||||
$data['estimateDetail'] = $this->estimateDetailRepository->getEstimateDetailById($id);
|
||||
$data['customerList'] = $this->customerRepository->pluck();
|
||||
return view('estimate::estimateDetail.show', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
$data['title'] = 'Edit EstimateDetail';
|
||||
$data['editable'] = true;
|
||||
$data['estimateDetail'] = $this->estimateDetailRepository->getEstimateDetailById($id);
|
||||
return view('estimate::estimateDetail.edit', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function update(Request $request, $id): RedirectResponse
|
||||
{
|
||||
$inputData = $request->except(['_method', '_token']);
|
||||
try {
|
||||
|
||||
$this->estimateDetailRepository->update($id, $inputData);
|
||||
|
||||
flash()->success('EstimateDetail updated succesfully');
|
||||
|
||||
} catch (\Throwable $th) {
|
||||
|
||||
flash()->error($th->getMessage());
|
||||
}
|
||||
return redirect()->route('EstimateDetail.index');
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
try {
|
||||
$EstimateDetailModel = $this->estimateDetailRepository->getEstimateDetailById($id);
|
||||
|
||||
$EstimateDetailModel->delete();
|
||||
|
||||
flash()->success('EstimateDetail deleted succesfully');
|
||||
|
||||
} catch (\Throwable $th) {
|
||||
|
||||
flash()->error($th->getMessage());
|
||||
}
|
||||
|
||||
return response()->json(['status' => true, 'message' => 'EstimateDetail deleted succesfully']);
|
||||
|
||||
}
|
||||
}
|
0
Modules/Estimate/app/Http/Requests/.gitkeep
Normal file
0
Modules/Estimate/app/Http/Requests/.gitkeep
Normal file
0
Modules/Estimate/app/Models/.gitkeep
Normal file
0
Modules/Estimate/app/Models/.gitkeep
Normal file
70
Modules/Estimate/app/Models/Estimate.php
Normal file
70
Modules/Estimate/app/Models/Estimate.php
Normal file
@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Estimate\Models;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Modules\Customer\Models\Customer;
|
||||
|
||||
class Estimate extends Model
|
||||
{
|
||||
use HasFactory, SoftDeletes;
|
||||
|
||||
protected $table = "tbl_estimates";
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*/
|
||||
protected $fillable = [
|
||||
'title',
|
||||
'estimate_no',
|
||||
'date',
|
||||
'customer_id',
|
||||
'fiscal_year_id',
|
||||
'validity',
|
||||
'conditions',
|
||||
'approval_status',
|
||||
'approval_by',
|
||||
'approval_remarks',
|
||||
'approval_on',
|
||||
'description',
|
||||
'createdBy',
|
||||
'updatedBy',
|
||||
'status',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'date' => 'datetime',
|
||||
'validity' => 'datetime',
|
||||
'approval_on' => 'datetime',
|
||||
'estimate_no' => 'integer',
|
||||
];
|
||||
|
||||
const APPROVAL_STATUS = [
|
||||
1 => 'Pending',
|
||||
2 => 'Approved',
|
||||
3 => 'Rejected',
|
||||
];
|
||||
|
||||
public function customer()
|
||||
{
|
||||
return $this->belongsTo(Customer::class, 'customer_id');
|
||||
}
|
||||
|
||||
public function approver()
|
||||
{
|
||||
return $this->belongsTo(Customer::class, 'approval_by');
|
||||
}
|
||||
|
||||
public function estimateDetails()
|
||||
{
|
||||
return $this->hasMany(EstimateDetail::class, 'estimate_id');
|
||||
}
|
||||
|
||||
public static function getFillableFields()
|
||||
{
|
||||
return (new self())->fillable;
|
||||
}
|
||||
}
|
48
Modules/Estimate/app/Models/EstimateDetail.php
Normal file
48
Modules/Estimate/app/Models/EstimateDetail.php
Normal file
@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Estimate\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Modules\Billing\Models\BillingComponent;
|
||||
use Modules\Estimate\Database\Factories\EstimateDetailFactory;
|
||||
|
||||
class EstimateDetail extends Model
|
||||
{
|
||||
use HasFactory, SoftDeletes;
|
||||
|
||||
protected $table = "tbl_estimate_details";
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*/
|
||||
protected $fillable = [
|
||||
'title',
|
||||
'estimate_id',
|
||||
'billing_component_id',
|
||||
'fiscal_year_id',
|
||||
'price',
|
||||
'qty',
|
||||
'tax_amount',
|
||||
'createdBy',
|
||||
'updatedBy',
|
||||
'remarks',
|
||||
'status',
|
||||
];
|
||||
|
||||
|
||||
public function estimate()
|
||||
{
|
||||
return $this->belongsTo(Estimate::class, 'estimate_id')->withDefault();
|
||||
}
|
||||
|
||||
public function billingComponent()
|
||||
{
|
||||
return $this->belongsTo(BillingComponent::class, 'billing_component_id')->withDefault();
|
||||
}
|
||||
|
||||
public function getFillableFields()
|
||||
{
|
||||
return (new self())->fillable;
|
||||
}
|
||||
}
|
0
Modules/Estimate/app/Observers/.gitkeep
Normal file
0
Modules/Estimate/app/Observers/.gitkeep
Normal file
0
Modules/Estimate/app/Providers/.gitkeep
Normal file
0
Modules/Estimate/app/Providers/.gitkeep
Normal file
126
Modules/Estimate/app/Providers/EstimateServiceProvider.php
Normal file
126
Modules/Estimate/app/Providers/EstimateServiceProvider.php
Normal file
@ -0,0 +1,126 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Estimate\Providers;
|
||||
|
||||
use Illuminate\Support\Facades\Blade;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Modules\Estimate\Repositories\EstimateDetailInterface;
|
||||
use Modules\Estimate\Repositories\EstimateDetailRepository;
|
||||
use Modules\Estimate\Repositories\EstimateInterface;
|
||||
use Modules\Estimate\Repositories\EstimateRepository;
|
||||
|
||||
class EstimateServiceProvider extends ServiceProvider
|
||||
{
|
||||
protected string $moduleName = 'Estimate';
|
||||
|
||||
protected string $moduleNameLower = 'estimate';
|
||||
|
||||
/**
|
||||
* 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(EstimateInterface::class, EstimateRepository::class);
|
||||
$this->app->bind(EstimateDetailInterface::class, EstimateDetailRepository::class);
|
||||
$this->app->register(EventServiceProvider::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.
|
||||
*
|
||||
* @return array<string>
|
||||
*/
|
||||
public function provides(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string>
|
||||
*/
|
||||
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;
|
||||
}
|
||||
}
|
32
Modules/Estimate/app/Providers/EventServiceProvider.php
Normal file
32
Modules/Estimate/app/Providers/EventServiceProvider.php
Normal file
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Estimate\Providers;
|
||||
|
||||
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
|
||||
|
||||
class EventServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* The event handler mappings for the application.
|
||||
*
|
||||
* @var array<string, array<int, string>>
|
||||
*/
|
||||
protected $listen = [];
|
||||
|
||||
/**
|
||||
* Indicates if events should be discovered.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected static $shouldDiscoverEvents = true;
|
||||
|
||||
/**
|
||||
* Configure the proper event listeners for email verification.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function configureEmailVerification(): void
|
||||
{
|
||||
|
||||
}
|
||||
}
|
49
Modules/Estimate/app/Providers/RouteServiceProvider.php
Normal file
49
Modules/Estimate/app/Providers/RouteServiceProvider.php
Normal file
@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Estimate\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('Estimate', '/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('Estimate', '/routes/api.php'));
|
||||
}
|
||||
}
|
0
Modules/Estimate/app/Repositories/.gitkeep
Normal file
0
Modules/Estimate/app/Repositories/.gitkeep
Normal file
@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Estimate\Repositories;
|
||||
|
||||
interface EstimateDetailInterface
|
||||
{
|
||||
public function findAll();
|
||||
public function getEstimateDetailById($EstimateDetailId);
|
||||
public function delete($EstimateDetailId);
|
||||
public function create($EstimateDetailDetails);
|
||||
public function update($EstimateDetailId, array $newDetails);
|
||||
public function pluck();
|
||||
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Estimate\Repositories;
|
||||
|
||||
use Modules\Estimate\Models\EstimateDetail;
|
||||
|
||||
class EstimateDetailRepository implements EstimateDetailInterface
|
||||
{
|
||||
public function findAll()
|
||||
{
|
||||
return EstimateDetail::all();
|
||||
}
|
||||
|
||||
public function getEstimateDetailById($EstimateDetailId)
|
||||
{
|
||||
return EstimateDetail::findOrFail($EstimateDetailId);
|
||||
}
|
||||
|
||||
|
||||
public function delete($EstimateDetailId)
|
||||
{
|
||||
EstimateDetail::destroy($EstimateDetailId);
|
||||
}
|
||||
|
||||
public function create($EstimateDetailDetails)
|
||||
{
|
||||
return EstimateDetail::create($EstimateDetailDetails);
|
||||
}
|
||||
|
||||
public function update($EstimateDetailId, array $newDetails)
|
||||
{
|
||||
return EstimateDetail::whereId($EstimateDetailId)->update($newDetails);
|
||||
}
|
||||
|
||||
public function pluck()
|
||||
{
|
||||
return EstimateDetail::pluck('title', 'id');
|
||||
}
|
||||
|
||||
}
|
14
Modules/Estimate/app/Repositories/EstimateInterface.php
Normal file
14
Modules/Estimate/app/Repositories/EstimateInterface.php
Normal file
@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Estimate\Repositories;
|
||||
|
||||
interface EstimateInterface
|
||||
{
|
||||
public function findAll();
|
||||
public function getEstimateById($EstimateId);
|
||||
public function delete($EstimateId);
|
||||
public function create($EstimateDetails);
|
||||
public function update($EstimateId, array $newDetails);
|
||||
public function pluck();
|
||||
|
||||
}
|
40
Modules/Estimate/app/Repositories/EstimateRepository.php
Normal file
40
Modules/Estimate/app/Repositories/EstimateRepository.php
Normal file
@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Estimate\Repositories;
|
||||
|
||||
use Modules\Estimate\Models\Estimate;
|
||||
|
||||
class EstimateRepository implements EstimateInterface
|
||||
{
|
||||
public function findAll()
|
||||
{
|
||||
return Estimate::all();
|
||||
}
|
||||
|
||||
public function getEstimateById($EstimateId)
|
||||
{
|
||||
return Estimate::with('estimateDetails')->findOrFail($EstimateId);
|
||||
}
|
||||
|
||||
|
||||
public function delete($EstimateId)
|
||||
{
|
||||
Estimate::destroy($EstimateId);
|
||||
}
|
||||
|
||||
public function create($EstimateDetails)
|
||||
{
|
||||
return Estimate::create($EstimateDetails);
|
||||
}
|
||||
|
||||
public function update($EstimateId, array $newDetails)
|
||||
{
|
||||
return Estimate::whereId($EstimateId)->update($newDetails);
|
||||
}
|
||||
|
||||
public function pluck()
|
||||
{
|
||||
return Estimate::pluck('title', 'id');
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user