diff --git a/app/Http/Controllers/DocumentController.php b/app/Http/Controllers/DocumentController.php index 6e5f012..246b336 100644 --- a/app/Http/Controllers/DocumentController.php +++ b/app/Http/Controllers/DocumentController.php @@ -18,8 +18,8 @@ class DocumentController extends Controller { $project_id = $request->session()->get('project_id'); $project = Project::find($project_id); - $documents = Document::where('project_id',$project_id)->get(); - return view('documents.list', ['project' => $project, 'documents' => $documents]); + $top_documents = $project->documents()->where('parent_id',0)->get(); + return view('documents.list', ['project' => $project, 'top_documents' => $top_documents]); } /** @@ -32,8 +32,8 @@ class DocumentController extends Controller { $project_id = $request->session()->get('project_id'); $project = Project::find($project_id); - $documents = Document::where('project_id',$project_id)->get(); - return view('documents.create', ['project' => $project, 'documents' => $documents]); + $top_documents = $project->documents()->where('parent_id',0)->get(); + return view('documents.create', ['project' => $project, 'top_documents' => $top_documents]); } /** @@ -74,12 +74,17 @@ class DocumentController 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) { - // + $project_id = $request->session()->get('project_id'); + $project = Project::find($project_id); + $top_documents = $project->documents()->where('parent_id',0)->get(); + $document = Document::find($id); + return view('documents.edit', ['project' => $project, 'top_documents' => $top_documents, 'document' => $document]); } /** @@ -91,7 +96,20 @@ class DocumentController extends Controller */ public function update(Request $request, $id) { - // + $project_id = $request->session()->get('project_id'); + $request->validate([ + 'name' => ['required', 'string', 'max:255'], + 'parent_id' => 'required|integer|different:id', + // 'parent_id' => ['required', 'integer','lt:'.$id,'gt:'.$id], + ]); + + $document = Document::find($id); + $document->name = $request->name; + $document->project_id = $project_id; + $document->parent_id = $request->parent_id; + $document->save(); + + return redirect(route('documents.index')); } /** @@ -102,6 +120,7 @@ class DocumentController extends Controller */ public function destroy($id) { - // + Document::findOrFail($id)->delete(); + return redirect()->route('documents.index'); } } diff --git a/app/Models/Document.php b/app/Models/Document.php index 1ed1d2e..508c252 100644 --- a/app/Models/Document.php +++ b/app/Models/Document.php @@ -16,9 +16,8 @@ class Document extends Model 'parent_id', ]; - public function childs() { - - return $this->hasMany('App\Category','parent_id','id') ; - + public function childs() + { + return $this->hasMany('App\Models\Document','parent_id','id'); } } diff --git a/app/Models/Project.php b/app/Models/Project.php index ae0bfc1..05dce2d 100644 --- a/app/Models/Project.php +++ b/app/Models/Project.php @@ -13,4 +13,9 @@ class Project extends Model 'description', 'mmc_path', ]; + + public function documents() + { + return $this->hasMany(Document::class); + } } diff --git a/public/css/app.css b/public/css/app.css index 5402dae..2fbee43 100644 --- a/public/css/app.css +++ b/public/css/app.css @@ -697,9 +697,6 @@ select { .z-50 { z-index: 50; } -.m-2 { - margin: 0.5rem; -} .mx-auto { margin-left: auto; margin-right: auto; @@ -716,9 +713,6 @@ select { .mt-4 { margin-top: 1rem; } -.ml-4 { - margin-left: 1rem; -} .ml-1 { margin-left: 0.25rem; } @@ -731,6 +725,9 @@ select { .ml-2 { margin-left: 0.5rem; } +.ml-4 { + margin-left: 1rem; +} .mt-8 { margin-top: 2rem; } @@ -746,12 +743,12 @@ select { .mt-3 { margin-top: 0.75rem; } -.mt-6 { - margin-top: 1.5rem; -} .mb-4 { margin-bottom: 1rem; } +.mt-6 { + margin-top: 1.5rem; +} .block { display: block; } @@ -800,6 +797,9 @@ select { .w-5 { width: 1.25rem; } +.w-96 { + width: 24rem; +} .w-full { width: 100%; } @@ -821,15 +821,15 @@ select { .w-20 { width: 5rem; } -.w-96 { - width: 24rem; -} .max-w-7xl { max-width: 80rem; } .max-w-6xl { max-width: 72rem; } +.max-w-xl { + max-width: 36rem; +} .flex-1 { flex: 1 1 0%; } @@ -907,15 +907,15 @@ select { .rounded-md { border-radius: 0.375rem; } +.rounded-full { + border-radius: 9999px; +} .rounded-lg { border-radius: 0.5rem; } .rounded { border-radius: 0.25rem; } -.rounded-full { - border-radius: 9999px; -} .rounded-l-md { border-top-left-radius: 0.375rem; border-bottom-left-radius: 0.375rem; @@ -939,6 +939,9 @@ select { .border-l-4 { border-left-width: 4px; } +.border-r { + border-right-width: 1px; +} .border-gray-300 { --tw-border-opacity: 1; border-color: rgb(209 213 219 / var(--tw-border-opacity)); @@ -958,6 +961,10 @@ select { --tw-border-opacity: 1; border-color: rgb(129 140 248 / var(--tw-border-opacity)); } +.border-gray-400 { + --tw-border-opacity: 1; + border-color: rgb(156 163 175 / var(--tw-border-opacity)); +} .bg-white { --tw-bg-opacity: 1; background-color: rgb(255 255 255 / var(--tw-bg-opacity)); @@ -966,14 +973,6 @@ select { --tw-bg-opacity: 1; background-color: rgb(243 244 246 / var(--tw-bg-opacity)); } -.bg-gray-800 { - --tw-bg-opacity: 1; - background-color: rgb(31 41 55 / var(--tw-bg-opacity)); -} -.bg-indigo-50 { - --tw-bg-opacity: 1; - background-color: rgb(238 242 255 / var(--tw-bg-opacity)); -} .bg-blue-500 { --tw-bg-opacity: 1; background-color: rgb(59 130 246 / var(--tw-bg-opacity)); @@ -982,6 +981,14 @@ select { --tw-bg-opacity: 1; background-color: rgb(107 114 128 / var(--tw-bg-opacity)); } +.bg-gray-800 { + --tw-bg-opacity: 1; + background-color: rgb(31 41 55 / var(--tw-bg-opacity)); +} +.bg-indigo-50 { + --tw-bg-opacity: 1; + background-color: rgb(238 242 255 / var(--tw-bg-opacity)); +} .fill-current { fill: currentColor; } @@ -1027,6 +1034,15 @@ select { padding-left: 0.25rem; padding-right: 0.25rem; } +.pr-2 { + padding-right: 0.5rem; +} +.pt-4 { + padding-top: 1rem; +} +.pl-2 { + padding-left: 0.5rem; +} .pt-8 { padding-top: 2rem; } @@ -1036,9 +1052,6 @@ select { .pb-3 { padding-bottom: 0.75rem; } -.pt-4 { - padding-top: 1rem; -} .pb-1 { padding-bottom: 0.25rem; } @@ -1054,12 +1067,6 @@ select { .pr-4 { padding-right: 1rem; } -.pr-2 { - padding-right: 0.5rem; -} -.pl-2 { - padding-left: 0.5rem; -} .text-center { text-align: center; } @@ -1110,6 +1117,9 @@ select { .tracking-widest { letter-spacing: 0.1em; } +.tracking-wider { + letter-spacing: 0.05em; +} .text-gray-500 { --tw-text-opacity: 1; color: rgb(107 114 128 / var(--tw-text-opacity)); @@ -1122,6 +1132,14 @@ select { --tw-text-opacity: 1; color: rgb(31 41 55 / var(--tw-text-opacity)); } +.text-white { + --tw-text-opacity: 1; + color: rgb(255 255 255 / var(--tw-text-opacity)); +} +.text-red-500 { + --tw-text-opacity: 1; + color: rgb(239 68 68 / var(--tw-text-opacity)); +} .text-gray-200 { --tw-text-opacity: 1; color: rgb(229 231 235 / var(--tw-text-opacity)); @@ -1142,10 +1160,6 @@ select { --tw-text-opacity: 1; color: rgb(17 24 39 / var(--tw-text-opacity)); } -.text-red-500 { - --tw-text-opacity: 1; - color: rgb(239 68 68 / var(--tw-text-opacity)); -} .text-green-500 { --tw-text-opacity: 1; color: rgb(34 197 94 / var(--tw-text-opacity)); @@ -1158,10 +1172,6 @@ select { --tw-text-opacity: 1; color: rgb(22 163 74 / var(--tw-text-opacity)); } -.text-white { - --tw-text-opacity: 1; - color: rgb(255 255 255 / var(--tw-text-opacity)); -} .text-red-600 { --tw-text-opacity: 1; color: rgb(220 38 38 / var(--tw-text-opacity)); @@ -9062,22 +9072,22 @@ readers do not read off random characters that represent icons */ --tw-border-opacity: 1; border-color: rgb(209 213 219 / var(--tw-border-opacity)); } -.hover\:bg-gray-100:hover { +.hover\:bg-blue-700:hover { --tw-bg-opacity: 1; - background-color: rgb(243 244 246 / var(--tw-bg-opacity)); + background-color: rgb(29 78 216 / var(--tw-bg-opacity)); } .hover\:bg-gray-700:hover { --tw-bg-opacity: 1; background-color: rgb(55 65 81 / var(--tw-bg-opacity)); } +.hover\:bg-gray-100:hover { + --tw-bg-opacity: 1; + background-color: rgb(243 244 246 / var(--tw-bg-opacity)); +} .hover\:bg-gray-50:hover { --tw-bg-opacity: 1; background-color: rgb(249 250 251 / var(--tw-bg-opacity)); } -.hover\:bg-blue-700:hover { - --tw-bg-opacity: 1; - background-color: rgb(29 78 216 / var(--tw-bg-opacity)); -} .hover\:text-gray-500:hover { --tw-text-opacity: 1; color: rgb(107 114 128 / var(--tw-text-opacity)); @@ -9086,18 +9096,6 @@ readers do not read off random characters that represent icons */ --tw-text-opacity: 1; color: rgb(156 163 175 / var(--tw-text-opacity)); } -.hover\:text-gray-700:hover { - --tw-text-opacity: 1; - color: rgb(55 65 81 / var(--tw-text-opacity)); -} -.hover\:text-gray-800:hover { - --tw-text-opacity: 1; - color: rgb(31 41 55 / var(--tw-text-opacity)); -} -.hover\:text-gray-900:hover { - --tw-text-opacity: 1; - color: rgb(17 24 39 / var(--tw-text-opacity)); -} .hover\:text-green-700:hover { --tw-text-opacity: 1; color: rgb(21 128 61 / var(--tw-text-opacity)); @@ -9110,6 +9108,18 @@ readers do not read off random characters that represent icons */ --tw-text-opacity: 1; color: rgb(185 28 28 / var(--tw-text-opacity)); } +.hover\:text-gray-700:hover { + --tw-text-opacity: 1; + color: rgb(55 65 81 / var(--tw-text-opacity)); +} +.hover\:text-gray-900:hover { + --tw-text-opacity: 1; + color: rgb(17 24 39 / var(--tw-text-opacity)); +} +.hover\:text-gray-800:hover { + --tw-text-opacity: 1; + color: rgb(31 41 55 / var(--tw-text-opacity)); +} .focus\:z-10:focus { z-index: 10; } diff --git a/resources/views/documents/actions.blade.php b/resources/views/documents/actions.blade.php new file mode 100644 index 0000000..3e68f9c --- /dev/null +++ b/resources/views/documents/actions.blade.php @@ -0,0 +1,16 @@ +{{-- + + --}} + + + +@if (!count($document->childs)) +
+@endif diff --git a/resources/views/documents/create.blade.php b/resources/views/documents/create.blade.php index a451c9b..6dcd2b6 100644 --- a/resources/views/documents/create.blade.php +++ b/resources/views/documents/create.blade.php @@ -11,13 +11,13 @@| - {{ __('Title')}} + {{ __('Title') }} | - {{ __('Actions')}} + {{ __('Actions') }} |
|---|---|
| {{ $document->name }} | -- - | -
| {{ $document->name }} | +
+
+ @include('documents.actions', ['document' => $document])
+
+ |
+
+
| No Documents! | -|
| No Documents! | +|