project select ready
This commit is contained in:
@@ -10,11 +10,12 @@ class MMCController extends Controller
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @param int $project_id
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index($project_id)
|
||||
public function index(Request $request)
|
||||
{
|
||||
$project_id = $request->session()->get('project_id');
|
||||
$project = Project::find($project_id);
|
||||
return view('mmc.show', ['project' => $project]);
|
||||
}
|
||||
@@ -22,23 +23,23 @@ class MMCController extends Controller
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @param int $project_id
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function create($project_id)
|
||||
public function create(Request $request)
|
||||
{
|
||||
$project_id = $request->session()->get('project_id');
|
||||
$project = Project::find($project_id);
|
||||
return view('mmc.create',['project' => $project]);
|
||||
return view('mmc.create', ['project' => $project]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param int $project_id
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store($project_id,Request $request)
|
||||
public function store(Request $request)
|
||||
{
|
||||
// $request->validate([
|
||||
// 'username' => ['required', 'string', 'max:255'],
|
||||
@@ -61,11 +62,11 @@ class MMCController extends Controller
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param int $project_id
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function show($project_id,$id)
|
||||
public function show(Request $request, $id)
|
||||
{
|
||||
// $user = User::find($id);
|
||||
// return view('admin.users.show', ['user' => $user]);
|
||||
@@ -74,10 +75,11 @@ class MMCController extends Controller
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit($id)
|
||||
public function edit(Request $request, $id)
|
||||
{
|
||||
// $user = User::find($id);
|
||||
// return view('admin.users.edit', ['user' => $user]);
|
||||
@@ -111,10 +113,11 @@ class MMCController extends Controller
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy($id)
|
||||
public function destroy(Request $request, $id)
|
||||
{
|
||||
// User::findOrFail($id)->delete();
|
||||
// return redirect()->route('users.index');
|
||||
|
||||
30
app/Http/Controllers/SelectProjectController.php
Normal file
30
app/Http/Controllers/SelectProjectController.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\ProjectController;
|
||||
use App\Models\Project;
|
||||
|
||||
class SelectProjectController extends Controller
|
||||
{
|
||||
/**
|
||||
* Provision a new web server.
|
||||
*
|
||||
* @param int $project_id
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function __invoke($project_id,Request $request)
|
||||
{
|
||||
if(Project::find($project_id)->exists())
|
||||
{
|
||||
$request->session()->put('project_id',$project_id);
|
||||
}
|
||||
else
|
||||
{
|
||||
$request->session()->forget('project_id');
|
||||
}
|
||||
return view('dashboard');
|
||||
}
|
||||
}
|
||||
@@ -17,6 +17,9 @@ $projects = Project::all()->sortBy('id');
|
||||
<div align="center" class="pt-4">
|
||||
<table class="table table-sm border-b border-gray-200">
|
||||
<tr class="border border-gray-200">
|
||||
<th class="p-2 border border-gray-200">
|
||||
|
||||
</th>
|
||||
<th class="p-2 border border-gray-200">
|
||||
{{ __('Title') }}
|
||||
</th>
|
||||
@@ -29,7 +32,27 @@ $projects = Project::all()->sortBy('id');
|
||||
</tr>
|
||||
@forelse ($projects as $project)
|
||||
<tr class="border border-gray-200">
|
||||
<td class="p-2 border border-gray-200"><a href="{{ route('mmc.index',$project->id) }}" class="underline">{{ $project->name }}</a></td>
|
||||
<td class="p-2 border border-gray-200">
|
||||
<form action="{{ route('project.select', $project->id) }}" method="POST">
|
||||
<input type="hidden" name="_token" value="{{ csrf_token() }}">
|
||||
@if (session()->get('project_id') !== null)
|
||||
@if (session()->get('project_id') == $project->id)
|
||||
<button
|
||||
class="fa fa-square-check text-green-500 hover:text-green-700 px-2 text-lg"
|
||||
type="submit"></button>
|
||||
@else
|
||||
<button
|
||||
class="far fa-square text-gray-500 hover:text-gray-700 px-2 text-lg"
|
||||
type="submit"></button>
|
||||
@endif
|
||||
@else
|
||||
<button
|
||||
class="far fa-square text-gray-500 hover:text-gray-700 px-2 text-lg"
|
||||
type="submit"></button>
|
||||
@endif
|
||||
</form>
|
||||
</td>
|
||||
<td class="p-2 border border-gray-200">{{ $project->name }}</td>
|
||||
<td class="p-2 border border-gray-200">{{ $project->description }}</td>
|
||||
<td class="p-2 border border-gray-200">{{ $project->mmc_path }}</td>
|
||||
</tr>
|
||||
|
||||
61
resources/views/documents/create.blade.php
Normal file
61
resources/views/documents/create.blade.php
Normal file
@@ -0,0 +1,61 @@
|
||||
<x-app-layout>
|
||||
<x-slot name="header">
|
||||
<h2 class="font-semibold text-xl text-gray-800 leading-tight">
|
||||
{{ __('Create project') }}
|
||||
</h2>
|
||||
</x-slot>
|
||||
|
||||
<div class="py-12">
|
||||
<div class="max-w-7xl mx-auto sm:px-6 lg:px-8">
|
||||
<div class="bg-white overflow-hidden shadow-sm sm:rounded-lg">
|
||||
<div class="p-6 bg-white border-b border-gray-200">
|
||||
<div class="w-96 mx-auto">
|
||||
@if ($errors->any())
|
||||
<div class="alert alert-danger text-red-500 p-2">
|
||||
<ul class="list-unstyled alert alert-danger">
|
||||
@foreach ($errors->all() as $error)
|
||||
<li>{{ $error }}</li>
|
||||
@endforeach
|
||||
</ul>
|
||||
</div>
|
||||
@endif
|
||||
<form method="POST" action="{{ route('projects.store') }}">
|
||||
@csrf
|
||||
<!-- Project name -->
|
||||
<div>
|
||||
<x-label for="name" :value="__('Title')" />
|
||||
|
||||
<x-input id="name" class="block mt-1 w-full" type="text" name="name" :value="old('name')" required autofocus />
|
||||
</div>
|
||||
|
||||
<!-- Description -->
|
||||
<div class="mt-4">
|
||||
<x-label for="description" :value="__('Description')" />
|
||||
|
||||
<x-input id="description" class="block mt-1 w-full" type="text" name="description" :value="old('description')" required />
|
||||
</div>
|
||||
|
||||
<!-- MMC Path -->
|
||||
<div class="mt-4">
|
||||
<x-label for="mmc_path" :value="__('MMC Path')" />
|
||||
|
||||
<x-input id="mmc_path" class="block mt-1 w-full" type="text" name="mmc_path" :value="old('mmc_path')" required />
|
||||
</div>
|
||||
|
||||
<div class="flex items-center justify-end mt-4">
|
||||
<button class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded-full">
|
||||
<i class="fa fa-add pr-2"></i>{{ __('Create project') }}
|
||||
</button>
|
||||
<div class="pl-2">
|
||||
<a href="{{ route('projects.index') }}" class="btn bg-gray-500 hover:bg-gray-700 text-white font-bold py-2 px-4 rounded-full">
|
||||
<i class="fa fa-cancel pr-2"></i>{{__('Cancel')}}
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</x-app-layout>
|
||||
57
resources/views/documents/edit.blade.php
Normal file
57
resources/views/documents/edit.blade.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<x-app-layout>
|
||||
<x-slot name="header">
|
||||
<h2 class="font-semibold text-xl text-gray-800 leading-tight">
|
||||
{{ __('Edit project') }}
|
||||
</h2>
|
||||
</x-slot>
|
||||
|
||||
<div class="py-12">
|
||||
<div class="max-w-7xl mx-auto sm:px-6 lg:px-8">
|
||||
<div class="bg-white overflow-hidden shadow-sm sm:rounded-lg">
|
||||
<div class="p-6 bg-white border-b border-gray-200">
|
||||
<div class="w-96 mx-auto">
|
||||
@if ($errors->any())
|
||||
<div class="alert alert-danger text-red-500 p-2">
|
||||
<ul class="list-unstyled alert alert-danger">
|
||||
@foreach ($errors->all() as $error)
|
||||
<li>{{ $error }}</li>
|
||||
@endforeach
|
||||
</ul>
|
||||
</div>
|
||||
@endif
|
||||
<form method="POST" action="{{ route('projects.update',$project->id) }}">
|
||||
@csrf
|
||||
@method('PUT')
|
||||
<div>
|
||||
<x-label for="name" :value="__('Title')" />
|
||||
|
||||
<x-input id="name" class="block mt-1 w-full" type="text" name="name" value="{{ $project->name }}" required autofocus />
|
||||
</div>
|
||||
<div class="mt-4">
|
||||
<x-label for="description" :value="__('Description')" />
|
||||
|
||||
<x-input id="description" class="block mt-1 w-full" type="text" name="description" value="{{ $project->description }}" required />
|
||||
</div>
|
||||
<div class="mt-4">
|
||||
<x-label for="mmc_path" :value="__('MMC Path')" />
|
||||
|
||||
<x-input id="mmc_path" class="block mt-1 w-full" type="text" name="mmc_path" value="{{ $project->mmc_path }}" required />
|
||||
</div>
|
||||
|
||||
<div class="flex items-center justify-end mt-4">
|
||||
<button class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded-full">
|
||||
<i class="fa fa-add pr-2"></i>{{ __('Save') }}
|
||||
</button>
|
||||
<div class="pl-2">
|
||||
<a href="{{ route('projects.index') }}" class="btn bg-gray-500 hover:bg-gray-700 text-white font-bold py-2 px-4 rounded-full">
|
||||
<i class="fa fa-cancel pr-2"></i>{{__('Cancel')}}
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</x-app-layout>
|
||||
68
resources/views/documents/list.blade.php
Normal file
68
resources/views/documents/list.blade.php
Normal file
@@ -0,0 +1,68 @@
|
||||
<x-app-layout>
|
||||
<x-slot name="header">
|
||||
<h2 class="font-semibold text-xl text-gray-800 leading-tight">
|
||||
{{ __('Project list') }}
|
||||
</h2>
|
||||
</x-slot>
|
||||
|
||||
<div class="py-12">
|
||||
<div class="max-w-7xl mx-auto sm:px-6 lg:px-8">
|
||||
<div class="bg-white overflow-hidden shadow-sm sm:rounded-lg">
|
||||
<div class="p-6 bg-white border-b border-gray-200">
|
||||
<a href="{{ route('projects.create')}}">
|
||||
<button class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded-full">
|
||||
<i class="fa fa-add pr-2"></i>{{__('Create project')}}
|
||||
</button>
|
||||
</a>
|
||||
|
||||
<div align="center" class="pt-4">
|
||||
<table class="table table-sm border-b border-gray-200">
|
||||
<tr class="border border-gray-200">
|
||||
<th class="p-2 border border-gray-200">
|
||||
{{ __('Title')}}
|
||||
</th>
|
||||
<th class="p-2 border border-gray-200">
|
||||
{{ __('Comment')}}
|
||||
</th>
|
||||
<th class="p-2 border border-gray-200">
|
||||
{{ __('MMC Path')}}
|
||||
</th>
|
||||
<th class="p-2 border border-gray-200">
|
||||
{{ __('Actions')}}
|
||||
</th>
|
||||
</tr>
|
||||
@forelse ( $projects as $project)
|
||||
<tr class="border border-gray-200">
|
||||
<td class="p-2 border border-gray-200">{{ $project->name }}</td>
|
||||
<td class="p-2 border border-gray-200">{{ $project->description }}</td>
|
||||
<td class="p-2 border border-gray-200">{{ $project->mmc_path }}</td>
|
||||
<td class="p-2 border border-gray-200">
|
||||
<div class="text-center">
|
||||
<a href="{{ route('projects.show',$project->id) }}">
|
||||
<i class="fa fa-eye text-green-500 hover:text-green-700 px-2 text-lg"></i>
|
||||
</a>
|
||||
<a href="{{ route('projects.edit',$project->id) }}">
|
||||
<i class="fa fa-edit text-blue-500 hover:text-blue-700 px-2 text-lg"></i>
|
||||
</a>
|
||||
<form class="inline-block" action="{{ route('projects.destroy', $project->id) }}" method="POST" onsubmit="return confirm('{{ __('Are you sure remove project ').$project->name.'?' }}');">
|
||||
<input type="hidden" name="_method" value="DELETE">
|
||||
<input type="hidden" name="_token" value="{{ csrf_token() }}">
|
||||
<button type="submit">
|
||||
<i class="fa fa-trash text-red-500 hover:text-red-700 px-2 text-lg"></i>
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
@empty
|
||||
<tr>
|
||||
<td colspan="4" class="p-2 border border-gray-200 text-center">No Projects!</td>
|
||||
</tr>
|
||||
@endforelse
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</x-app-layout>
|
||||
51
resources/views/documents/show.blade.php
Normal file
51
resources/views/documents/show.blade.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<x-app-layout>
|
||||
<x-slot name="header">
|
||||
<h2 class="font-semibold text-xl text-gray-800 leading-tight">
|
||||
{{ __('Show project') }}
|
||||
</h2>
|
||||
</x-slot>
|
||||
|
||||
<div class="py-12">
|
||||
<div class="max-w-7xl mx-auto sm:px-6 lg:px-8">
|
||||
<div class="bg-white overflow-hidden shadow-sm sm:rounded-lg">
|
||||
<div class="p-6 bg-white border-b border-gray-200">
|
||||
<div class="w-96 mx-auto">
|
||||
<div>
|
||||
<x-label for="name" :value="__('Title')" />
|
||||
|
||||
<x-input id="name" class="block mt-1 w-full" type="text" name="name" value="{{ $project->name }}" readonly />
|
||||
</div>
|
||||
|
||||
<!-- Description -->
|
||||
<div class="mt-4">
|
||||
<x-label for="description" :value="__('Description')" />
|
||||
|
||||
<x-input id="description" class="block mt-1 w-full" type="text" name="description" value="{{ $project->description }}" readonly />
|
||||
</div>
|
||||
|
||||
<!-- MMC Path -->
|
||||
<div class="mt-4">
|
||||
<x-label for="mmc_path" :value="__('MMC Path')" />
|
||||
|
||||
<x-input id="mmc_path" class="block mt-1 w-full" type="text" name="mmc_path" value="{{ $project->mmc_path }}" readonly />
|
||||
</div>
|
||||
|
||||
<div class="flex items-center justify-end mt-4">
|
||||
<div class="pl-2">
|
||||
<a href="{{ route('projects.edit',$project->id) }}" class="btn bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded-full">
|
||||
<i class="fa fa-edit pr-2"></i>{{__('Edit project')}}
|
||||
</a>
|
||||
</div>
|
||||
<div class="pl-2">
|
||||
<a href="{{ route('projects.index') }}" class="btn bg-gray-500 hover:bg-gray-700 text-white font-bold py-2 px-4 rounded-full">
|
||||
<i class="fa fa-cancel pr-2"></i>{{__('Cancel')}}
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</x-app-layout>
|
||||
@@ -28,7 +28,7 @@
|
||||
{{ __('Projects') }}
|
||||
</x-nav-link>
|
||||
</div>
|
||||
@isset($project)
|
||||
@if (session()->get('project_id') !== null)
|
||||
<div class="hidden space-x-8 sm:-my-px sm:ml-10 sm:flex">
|
||||
<x-nav-link :href="route('mmc.index')" :active="request()->routeIs('mmc.index')|request()->routeIs('mmc.create')|request()->routeIs('mmc.show')|request()->routeIs('mmc.edit')">
|
||||
{{ __('MMC') }}
|
||||
@@ -44,7 +44,7 @@
|
||||
{{ __('AUK') }}
|
||||
</x-nav-link>
|
||||
</div>
|
||||
@endisset
|
||||
@endif
|
||||
</div>
|
||||
|
||||
<!-- Settings Dropdown -->
|
||||
|
||||
@@ -6,6 +6,7 @@ use App\Http\Controllers\MMCController;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use App\Http\Controllers\UserController;
|
||||
use App\Http\Controllers\ProjectController;
|
||||
use App\Http\Controllers\SelectProjectController;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
@@ -34,13 +35,12 @@ Route::prefix('admin')->middleware(['admin'])->group(function () {
|
||||
|
||||
// Projects
|
||||
Route::resource('/projects', ProjectController::class)->middleware(['auth']);
|
||||
Route::post('/project/{project}/select',SelectProjectController::class)->middleware(['auth'])->name('project.select');
|
||||
|
||||
Route::get('project/{project}/mmc', [MMCController::class, 'index'])->middleware(['auth'])->name('mmc.index');
|
||||
Route::get('project/{project}/mmc/create', [MMCController::class, 'create'])->middleware(['auth'])->name('mmc.create');
|
||||
Route::get('project/{project}/mmc/{mmc}', [MMCController::class, 'show'])->middleware(['auth'])->name('mmc.show');
|
||||
|
||||
Route::resource('/documents', DocumentController::class)->middleware(['auth']);
|
||||
Route::resource('/auk', AUKController::class)->middleware(['auth']);
|
||||
|
||||
Route::prefix('project/'.session('project_id'))->middleware(['auth'])->group(function () {
|
||||
Route::resource('/mmc', MMCController::class);
|
||||
Route::resource('/documents', DocumentController::class);
|
||||
Route::resource('/auk', DocumenAUKControllertController::class);
|
||||
});
|
||||
|
||||
require __DIR__ . '/auth.php';
|
||||
|
||||
Reference in New Issue
Block a user