diff --git a/app/Http/Controllers/DemandController.php b/app/Http/Controllers/DemandController.php index d28127b3..f10e3bb9 100644 --- a/app/Http/Controllers/DemandController.php +++ b/app/Http/Controllers/DemandController.php @@ -173,7 +173,6 @@ public function show($id): View $demand->fte = $demand_raw->first()->fte; - Log::info("demand: " . print_r($demand, true)); return view('demand.show', compact('demand')); } @@ -204,6 +203,23 @@ public function edit($project_id, Request $request): RedirectResponse ->with('success', 'Resource assigned to project successfully.'); } + + /** + * Show the form for editing the specified resource. + * - TODO we need to make sure we don't wipe out other demands + * - TODO we should run to the end of the demand, or deal with each month by itself + */ + public function editFullDemand($project_id): View + { + $demandArray = Demand::where('projects_id', $project_id) + ->whereBetween('demand_date', [now()->startOfYear(), now()->endOfYear()->addYear()]) + ->get(); + + $resources = Resource::all(); + + return view('demand.editFullDemand', compact('demandArray', 'resources')); + } + /** * Update the specified resource in storage. */ diff --git a/app/Http/Controllers/ProjectController.php b/app/Http/Controllers/ProjectController.php index a8708c9d..27b079fb 100644 --- a/app/Http/Controllers/ProjectController.php +++ b/app/Http/Controllers/ProjectController.php @@ -8,6 +8,7 @@ use App\Http\Requests\ProjectRequest; use Illuminate\Support\Facades\Redirect; use Illuminate\View\View; +use Illuminate\Support\Facades\Log; class ProjectController extends Controller { @@ -25,10 +26,15 @@ public function index(Request $request): View /** * Show the form for creating a new resource. */ - public function create(): View + public function create(Request $request): View { $project = new Project(); - + + if ($request->has('name')) { + $project->name = $request->query('name'); + } + Log::info("project: ". json_encode($project)); + return view('project.create', compact('project')); } diff --git a/resources/views/demand/form.blade.php b/resources/views/demand/form.blade.php index 0d198781..06230262 100644 --- a/resources/views/demand/form.blade.php +++ b/resources/views/demand/form.blade.php @@ -3,14 +3,29 @@
- +
+ + +
+
+ @foreach ($projects as $project) - - @endforeach - + @endforeach + {!! $errors->first('projects_id', '') !!} diff --git a/resources/views/demand/index.blade.php b/resources/views/demand/index.blade.php index 549ec227..d88c320e 100644 --- a/resources/views/demand/index.blade.php +++ b/resources/views/demand/index.blade.php @@ -83,7 +83,7 @@ class="fa fa-fw fa-edit"> {{ __('Assign') }} href="{{ route('demands.show', $project->id) }}"> {{ __('Show') }} {{ __('Edit') }} @csrf @method('DELETE') diff --git a/routes/web.php b/routes/web.php index 4f03fc39..309ffe3b 100644 --- a/routes/web.php +++ b/routes/web.php @@ -47,10 +47,11 @@ //additional functions Route::post('/allocations-upload', [AllocationController::class, 'populateAllocations'])->name('allocations.upload'); Route::resource('contracts', ContractController::class); - Route::get('/demands-export', [DemandController::class, 'exportDemands'])->name('demands.export'); + Route::get('/demands/export', [DemandController::class, 'exportDemands'])->name('demands.export'); + Route::get('/demands/{project}/editFullDemand', [DemandController::class, 'editFullDemand'])->name('demands.editFullDemand'); Route::resource('demands', DemandController::class); Route::resource('leaves', LeaveController::class); - Route::resource('projects', ProjectController::class); + Route::resource('projects', ProjectController::class); Route::get('/resources/{resource}/allocations', [ResourceController::class, 'allocations'])->name('resources.allocations'); Route::resource('resources', ResourceController::class); Route::resource('skills', SkillController::class);