diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php new file mode 100644 index 0000000..495fd26 --- /dev/null +++ b/app/Http/Controllers/UserController.php @@ -0,0 +1,38 @@ +route('tasks.index'); + } + + $validated = $request->validated(); + $createdById = Auth::id(); + $data = [...$validated, 'created_by_id' => $createdById]; + + $task = new User(); + $task->fill($data); + $task->save(); + + if (array_key_exists('labels', $validated)) { + $task->labels()->attach($validated['labels']); + } + + $message = __('controllers.tasks_create'); + return redirect()->route('tasks.index'); + } +} diff --git a/database/seeders/DatabaseSeeder.php b/database/seeders/DatabaseSeeder.php index a9f4519..e4705bd 100644 --- a/database/seeders/DatabaseSeeder.php +++ b/database/seeders/DatabaseSeeder.php @@ -3,6 +3,7 @@ namespace Database\Seeders; // use Illuminate\Database\Console\Seeds\WithoutModelEvents; +use App\Models\User; use Illuminate\Database\Seeder; class DatabaseSeeder extends Seeder diff --git a/resources/views/users/index.blade.php b/resources/views/users/index.blade.php new file mode 100644 index 0000000..3acc6e1 --- /dev/null +++ b/resources/views/users/index.blade.php @@ -0,0 +1,75 @@ +

список пользователей

+ + создать пользователя +
+
+ + + + + + + + + + @foreach($users as $user) + + + + + + @endforeach + +
idnameemail
{{ $user->id }}{{ $user->name }}{{ $user->email }}
+ + + +{{----}} +{{-- --}} +{{-- --}} +{{-- --}} +{{-- --}} +{{-- --}} +{{-- --}} +{{-- --}} +{{-- --}} +{{-- @auth()--}} +{{-- --}} +{{-- @endauth--}} +{{-- --}} +{{-- --}} +{{-- --}} +{{-- @foreach($tasks as $task)--}} +{{-- --}} +{{-- --}} +{{-- --}} +{{-- --}} +{{-- --}} +{{-- --}} +{{-- --}} +{{-- @auth()--}} +{{-- --}} +{{-- @endauth--}} +{{-- --}} +{{-- @endforeach--}} +{{-- --}} +{{--
{{ __('layout.table_id') }}{{ __('layout.table_task_status') }}{{ __('layout.table_name') }}{{ __('layout.table_creater') }}{{ __('layout.table_assigned') }}{{ __('layout.table_date_of_creation') }}{{ __('layout.table_actions') }}
{{ $task->id }}{{ $taskStatuses[$task->status_id] }}{{ $task->name }}{{ $users[$task->created_by_id] }}{{ $users[$task->assigned_to_id] }}{{ date_format($task->created_at, 'd.m.Y') }}--}} +{{-- @can('delete', $task)--}} +{{-- --}} +{{-- {{ __('layout.table_delete') }}--}} +{{-- --}} +{{-- @endcan--}} +{{-- @can('update', $task)--}} +{{-- --}} +{{-- {{ __('layout.table_edit') }}--}} +{{-- --}} +{{-- @endcan--}} +{{--
--}} diff --git a/routes/web.php b/routes/web.php index 67fd3d6..1273e62 100644 --- a/routes/web.php +++ b/routes/web.php @@ -1,6 +1,7 @@ name('home'); + +Route::resource('/users', UserController::class); + +Route::get('/dashboard', function () { + return view('dashboard'); +})->middleware(['auth', 'verified'])->name('dashboard'); Route::get('/dashboard', function () { return view('dashboard');