Document create continue

This commit is contained in:
Александр Бабкин
2022-07-01 21:45:15 +03:00
parent 17b364b1e3
commit 6bafca0eb6
6 changed files with 112 additions and 108 deletions

View File

@@ -18,7 +18,7 @@ class DocumentController extends Controller
{ {
$project_id = $request->session()->get('project_id'); $project_id = $request->session()->get('project_id');
$project = Project::find($project_id); $project = Project::find($project_id);
$documents = Document::find($project_id); $documents = Document::where('project_id',$project_id)->get();
return view('documents.list', ['project' => $project, 'documents' => $documents]); return view('documents.list', ['project' => $project, 'documents' => $documents]);
} }
@@ -32,7 +32,7 @@ class DocumentController extends Controller
{ {
$project_id = $request->session()->get('project_id'); $project_id = $request->session()->get('project_id');
$project = Project::find($project_id); $project = Project::find($project_id);
$documents = Document::find($project_id); $documents = Document::where('project_id',$project_id)->get();
return view('documents.create', ['project' => $project, 'documents' => $documents]); return view('documents.create', ['project' => $project, 'documents' => $documents]);
} }
@@ -44,7 +44,20 @@ class DocumentController extends Controller
*/ */
public function store(Request $request) public function store(Request $request)
{ {
// $project_id = $request->session()->get('project_id');
$request->validate([
'name' => ['required', 'string', 'max:255'],
'parent_id' => ['required', 'integer'],
]);
// $user =
Document::create([
'project_id' => $project_id,
'name' => $request->name,
'parent_id' => $request->parent_id,
]);
return redirect(route('documents.index'));
} }
/** /**

View File

@@ -697,6 +697,9 @@ select {
.z-50 { .z-50 {
z-index: 50; z-index: 50;
} }
.m-2 {
margin: 0.5rem;
}
.mx-auto { .mx-auto {
margin-left: auto; margin-left: auto;
margin-right: auto; margin-right: auto;
@@ -713,6 +716,9 @@ select {
.mt-4 { .mt-4 {
margin-top: 1rem; margin-top: 1rem;
} }
.ml-4 {
margin-left: 1rem;
}
.ml-1 { .ml-1 {
margin-left: 0.25rem; margin-left: 0.25rem;
} }
@@ -725,9 +731,6 @@ select {
.ml-2 { .ml-2 {
margin-left: 0.5rem; margin-left: 0.5rem;
} }
.ml-4 {
margin-left: 1rem;
}
.mt-8 { .mt-8 {
margin-top: 2rem; margin-top: 2rem;
} }
@@ -743,12 +746,12 @@ select {
.mt-3 { .mt-3 {
margin-top: 0.75rem; margin-top: 0.75rem;
} }
.mb-4 {
margin-bottom: 1rem;
}
.mt-6 { .mt-6 {
margin-top: 1.5rem; margin-top: 1.5rem;
} }
.mb-4 {
margin-bottom: 1rem;
}
.block { .block {
display: block; display: block;
} }
@@ -797,9 +800,6 @@ select {
.w-5 { .w-5 {
width: 1.25rem; width: 1.25rem;
} }
.w-96 {
width: 24rem;
}
.w-full { .w-full {
width: 100%; width: 100%;
} }
@@ -821,15 +821,15 @@ select {
.w-20 { .w-20 {
width: 5rem; width: 5rem;
} }
.w-96 {
width: 24rem;
}
.max-w-7xl { .max-w-7xl {
max-width: 80rem; max-width: 80rem;
} }
.max-w-6xl { .max-w-6xl {
max-width: 72rem; max-width: 72rem;
} }
.max-w-xl {
max-width: 36rem;
}
.flex-1 { .flex-1 {
flex: 1 1 0%; flex: 1 1 0%;
} }
@@ -907,15 +907,15 @@ select {
.rounded-md { .rounded-md {
border-radius: 0.375rem; border-radius: 0.375rem;
} }
.rounded-full {
border-radius: 9999px;
}
.rounded-lg { .rounded-lg {
border-radius: 0.5rem; border-radius: 0.5rem;
} }
.rounded { .rounded {
border-radius: 0.25rem; border-radius: 0.25rem;
} }
.rounded-full {
border-radius: 9999px;
}
.rounded-l-md { .rounded-l-md {
border-top-left-radius: 0.375rem; border-top-left-radius: 0.375rem;
border-bottom-left-radius: 0.375rem; border-bottom-left-radius: 0.375rem;
@@ -939,9 +939,6 @@ select {
.border-l-4 { .border-l-4 {
border-left-width: 4px; border-left-width: 4px;
} }
.border-r {
border-right-width: 1px;
}
.border-gray-300 { .border-gray-300 {
--tw-border-opacity: 1; --tw-border-opacity: 1;
border-color: rgb(209 213 219 / var(--tw-border-opacity)); border-color: rgb(209 213 219 / var(--tw-border-opacity));
@@ -961,10 +958,6 @@ select {
--tw-border-opacity: 1; --tw-border-opacity: 1;
border-color: rgb(129 140 248 / var(--tw-border-opacity)); 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 { .bg-white {
--tw-bg-opacity: 1; --tw-bg-opacity: 1;
background-color: rgb(255 255 255 / var(--tw-bg-opacity)); background-color: rgb(255 255 255 / var(--tw-bg-opacity));
@@ -973,14 +966,6 @@ select {
--tw-bg-opacity: 1; --tw-bg-opacity: 1;
background-color: rgb(243 244 246 / var(--tw-bg-opacity)); background-color: rgb(243 244 246 / var(--tw-bg-opacity));
} }
.bg-blue-500 {
--tw-bg-opacity: 1;
background-color: rgb(59 130 246 / var(--tw-bg-opacity));
}
.bg-gray-500 {
--tw-bg-opacity: 1;
background-color: rgb(107 114 128 / var(--tw-bg-opacity));
}
.bg-gray-800 { .bg-gray-800 {
--tw-bg-opacity: 1; --tw-bg-opacity: 1;
background-color: rgb(31 41 55 / var(--tw-bg-opacity)); background-color: rgb(31 41 55 / var(--tw-bg-opacity));
@@ -989,6 +974,14 @@ select {
--tw-bg-opacity: 1; --tw-bg-opacity: 1;
background-color: rgb(238 242 255 / var(--tw-bg-opacity)); 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));
}
.bg-gray-500 {
--tw-bg-opacity: 1;
background-color: rgb(107 114 128 / var(--tw-bg-opacity));
}
.fill-current { .fill-current {
fill: currentColor; fill: currentColor;
} }
@@ -1034,24 +1027,18 @@ select {
padding-left: 0.25rem; padding-left: 0.25rem;
padding-right: 0.25rem; padding-right: 0.25rem;
} }
.pr-2 {
padding-right: 0.5rem;
}
.pl-2 {
padding-left: 0.5rem;
}
.pt-8 { .pt-8 {
padding-top: 2rem; padding-top: 2rem;
} }
.pt-4 {
padding-top: 1rem;
}
.pt-2 { .pt-2 {
padding-top: 0.5rem; padding-top: 0.5rem;
} }
.pb-3 { .pb-3 {
padding-bottom: 0.75rem; padding-bottom: 0.75rem;
} }
.pt-4 {
padding-top: 1rem;
}
.pb-1 { .pb-1 {
padding-bottom: 0.25rem; padding-bottom: 0.25rem;
} }
@@ -1067,6 +1054,12 @@ select {
.pr-4 { .pr-4 {
padding-right: 1rem; padding-right: 1rem;
} }
.pr-2 {
padding-right: 0.5rem;
}
.pl-2 {
padding-left: 0.5rem;
}
.text-center { .text-center {
text-align: center; text-align: center;
} }
@@ -1117,9 +1110,6 @@ select {
.tracking-widest { .tracking-widest {
letter-spacing: 0.1em; letter-spacing: 0.1em;
} }
.tracking-wider {
letter-spacing: 0.05em;
}
.text-gray-500 { .text-gray-500 {
--tw-text-opacity: 1; --tw-text-opacity: 1;
color: rgb(107 114 128 / var(--tw-text-opacity)); color: rgb(107 114 128 / var(--tw-text-opacity));
@@ -1132,14 +1122,6 @@ select {
--tw-text-opacity: 1; --tw-text-opacity: 1;
color: rgb(31 41 55 / var(--tw-text-opacity)); color: rgb(31 41 55 / var(--tw-text-opacity));
} }
.text-red-500 {
--tw-text-opacity: 1;
color: rgb(239 68 68 / var(--tw-text-opacity));
}
.text-white {
--tw-text-opacity: 1;
color: rgb(255 255 255 / var(--tw-text-opacity));
}
.text-gray-200 { .text-gray-200 {
--tw-text-opacity: 1; --tw-text-opacity: 1;
color: rgb(229 231 235 / var(--tw-text-opacity)); color: rgb(229 231 235 / var(--tw-text-opacity));
@@ -1160,6 +1142,10 @@ select {
--tw-text-opacity: 1; --tw-text-opacity: 1;
color: rgb(17 24 39 / var(--tw-text-opacity)); 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 { .text-green-500 {
--tw-text-opacity: 1; --tw-text-opacity: 1;
color: rgb(34 197 94 / var(--tw-text-opacity)); color: rgb(34 197 94 / var(--tw-text-opacity));
@@ -1172,6 +1158,10 @@ select {
--tw-text-opacity: 1; --tw-text-opacity: 1;
color: rgb(22 163 74 / var(--tw-text-opacity)); 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 { .text-red-600 {
--tw-text-opacity: 1; --tw-text-opacity: 1;
color: rgb(220 38 38 / var(--tw-text-opacity)); color: rgb(220 38 38 / var(--tw-text-opacity));
@@ -9072,22 +9062,22 @@ readers do not read off random characters that represent icons */
--tw-border-opacity: 1; --tw-border-opacity: 1;
border-color: rgb(209 213 219 / var(--tw-border-opacity)); border-color: rgb(209 213 219 / var(--tw-border-opacity));
} }
.hover\:bg-blue-700:hover { .hover\:bg-gray-100:hover {
--tw-bg-opacity: 1; --tw-bg-opacity: 1;
background-color: rgb(29 78 216 / var(--tw-bg-opacity)); background-color: rgb(243 244 246 / var(--tw-bg-opacity));
} }
.hover\:bg-gray-700:hover { .hover\:bg-gray-700:hover {
--tw-bg-opacity: 1; --tw-bg-opacity: 1;
background-color: rgb(55 65 81 / var(--tw-bg-opacity)); 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 { .hover\:bg-gray-50:hover {
--tw-bg-opacity: 1; --tw-bg-opacity: 1;
background-color: rgb(249 250 251 / var(--tw-bg-opacity)); 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 { .hover\:text-gray-500:hover {
--tw-text-opacity: 1; --tw-text-opacity: 1;
color: rgb(107 114 128 / var(--tw-text-opacity)); color: rgb(107 114 128 / var(--tw-text-opacity));
@@ -9096,6 +9086,18 @@ readers do not read off random characters that represent icons */
--tw-text-opacity: 1; --tw-text-opacity: 1;
color: rgb(156 163 175 / var(--tw-text-opacity)); 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 { .hover\:text-green-700:hover {
--tw-text-opacity: 1; --tw-text-opacity: 1;
color: rgb(21 128 61 / var(--tw-text-opacity)); color: rgb(21 128 61 / var(--tw-text-opacity));
@@ -9108,18 +9110,6 @@ readers do not read off random characters that represent icons */
--tw-text-opacity: 1; --tw-text-opacity: 1;
color: rgb(185 28 28 / var(--tw-text-opacity)); 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 { .focus\:z-10:focus {
z-index: 10; z-index: 10;
} }

View File

@@ -27,29 +27,34 @@
<div> <div>
<x-label for="username" :value="__('User name')" /> <x-label for="username" :value="__('User name')" />
<x-input id="username" class="block mt-1 w-full" type="text" name="username" value="{{ $user->username }}" required autofocus /> <x-input id="username" class="block mt-1 w-full" type="text" name="username"
value="{{ $user->username }}" required autofocus />
</div> </div>
<!-- Name --> <!-- Name -->
<div> <div>
<x-label for="name" :value="__('Name')" /> <x-label for="name" :value="__('Name')" />
<x-input id="name" class="block mt-1 w-full" type="text" name="name" value="{{ $user->name }}" required /> <x-input id="name" class="block mt-1 w-full" type="text" name="name"
value="{{ $user->name }}" required />
</div> </div>
<!-- Email Address --> <!-- Email Address -->
<div class="mt-4"> <div class="mt-4">
<x-label for="email" :value="__('Email')" /> <x-label for="email" :value="__('Email')" />
<x-input id="email" class="block mt-1 w-full" type="email" name="email" value="{{ $user->email }}" required /> <x-input id="email" class="block mt-1 w-full" type="email" name="email"
value="{{ $user->email }}" required />
</div> </div>
<div class="flex items-center justify-end mt-4"> <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"> <button
class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded-full">
<i class="fa fa-save pr-2"></i>{{ __('Save') }} <i class="fa fa-save pr-2"></i>{{ __('Save') }}
</button> </button>
<div class="pl-2"> <div class="pl-2">
<a href="{{ route('users.index') }}" class="btn bg-gray-500 hover:bg-gray-700 text-white font-bold py-2 px-4 rounded-full"> <a href="{{ route('users.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') }} <i class="fa fa-cancel pr-2"></i>{{ __('Cancel') }}
</a> </a>
</div> </div>

View File

@@ -0,0 +1,5 @@
@props(['disabled' => false])
<select {{ $disabled ? 'disabled' : '' }} {!! $attributes->merge(['class' => 'rounded-md shadow-sm border-gray-300 focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50']) !!}>
{{ $slot }}
</select>

View File

@@ -31,13 +31,12 @@
<div> <div>
<x-label for="parent_id" :value="__('Parent document')" /> <x-label for="parent_id" :value="__('Parent document')" />
{{-- <x-select> <x-select id="parent_id" class="block mt-1 w-full" name="parent_id" required>
<option>1</option> <option value="0">---</option>
</x-select> --}} @foreach($documents as $document)
<select id="parent_id" class="block mt-1 w-full" type="select" name="parent_id" :value="old('parent_id')" required> <option value="{{ $document->id }}">{{ $document->name}}</option>
<option>1</option> @endforeach
<option>1</option> </x-select>
</select>
</div> </div>

View File

@@ -15,30 +15,22 @@
</button> </button>
</a> </a>
{{-- <div align="center" class="pt-4"> <div align="center" class="pt-4">
<table class="table table-sm border-b border-gray-200"> <table class="table table-sm border-b border-gray-200">
<tr class="border border-gray-200"> <tr class="border border-gray-200">
<th class="p-2 border border-gray-200"> <th class="p-2 border border-gray-200">
{{ __('Title')}} {{ __('Title')}}
</th> </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"> <th class="p-2 border border-gray-200">
{{ __('Actions')}} {{ __('Actions')}}
</th> </th>
</tr> </tr>
@forelse ( $projects as $project) @forelse ( $documents as $document)
<tr class="border border-gray-200"> <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">{{ $document->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"> <td class="p-2 border border-gray-200">
<div class="text-center"> <div class="text-center">
<a href="{{ route('projects.show',$project->id) }}"> {{-- <a href="{{ route('projects.show',$project->id) }}">
<i class="fa fa-eye text-green-500 hover:text-green-700 px-2 text-lg"></i> <i class="fa fa-eye text-green-500 hover:text-green-700 px-2 text-lg"></i>
</a> </a>
<a href="{{ route('projects.edit',$project->id) }}"> <a href="{{ route('projects.edit',$project->id) }}">
@@ -50,17 +42,17 @@
<button type="submit"> <button type="submit">
<i class="fa fa-trash text-red-500 hover:text-red-700 px-2 text-lg"></i> <i class="fa fa-trash text-red-500 hover:text-red-700 px-2 text-lg"></i>
</button> </button>
</form> </form> --}}
</div> </div>
</td> </td>
</tr> </tr>
@empty @empty
<tr> <tr>
<td colspan="4" class="p-2 border border-gray-200 text-center">No Projects!</td> <td colspan="2" class="p-2 border border-gray-200 text-center">No Documents!</td>
</tr> </tr>
@endforelse @endforelse
</table> </table>
</div> --}} </div>
</div> </div>
</div> </div>
</div> </div>