Compare commits

...

2 Commits

Author SHA1 Message Date
AslanAV 1383cad8b9 Merge remote-tracking branch 'origin/main'
# Conflicts:
#	routes/web.php
2024-01-11 15:11:05 +03:00
AslanAV 6dcf2c390f add User resource route, Controller 2024-01-11 15:10:01 +03:00
4 changed files with 125 additions and 2 deletions

View File

@ -0,0 +1,38 @@
<?php
namespace App\Http\Controllers;
use App\Models\User;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
class UserController extends Controller
{
public function index()
{
$users = User::all();
return view('users.index', compact('users'));
}
public function store($request)
{
if (Auth::guest()) {
return redirect()->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');
}
}

View File

@ -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

View File

@ -0,0 +1,75 @@
<h2>список пользователей</h2>
<a href="{{ route('users.create') }}"> создать пользователя</a>
<br>
<br>
<table class="mt-4">
<thead class="border-b-2 border-solid border-black text-left" style="text-align: left">
<tr>
<th>id</th>
<td>name</td>
<td>email</td>
</tr>
</thead>
<tbody>
@foreach($users as $user)
<tr>
<td>{{ $user->id }}</td>
<td>{{ $user->name }}</td>
<td>{{ $user->email }}</td>
</tr>
@endforeach
</tbody>
</table>
{{--<table class="mt-4">--}}
{{-- <thead class="border-b-2 border-solid border-black text-left" style="text-align: left">--}}
{{-- <tr>--}}
{{-- <th>{{ __('layout.table_id') }}</th>--}}
{{-- <th>{{ __('layout.table_task_status') }}</th>--}}
{{-- <th>{{ __('layout.table_name') }}</th>--}}
{{-- <th>{{ __('layout.table_creater') }}</th>--}}
{{-- <th>{{ __('layout.table_assigned') }}</th>--}}
{{-- <th>{{ __('layout.table_date_of_creation') }}</th>--}}
{{-- @auth()--}}
{{-- <th>{{ __('layout.table_actions') }}</th>--}}
{{-- @endauth--}}
{{-- </tr>--}}
{{-- </thead>--}}
{{-- <tbody>--}}
{{-- @foreach($tasks as $task)--}}
{{-- <tr class="border-b border-dashed text-left">--}}
{{-- <td>{{ $task->id }}</td>--}}
{{-- <td>{{ $taskStatuses[$task->status_id] }}</td>--}}
{{-- <td><a href="{{ route('tasks.show', $task) }}">{{ $task->name }}</a></td>--}}
{{-- <td>{{ $users[$task->created_by_id] }}</td>--}}
{{-- <td>{{ $users[$task->assigned_to_id] }}</td>--}}
{{-- <td>{{ date_format($task->created_at, 'd.m.Y') }}</td>--}}
{{-- @auth()--}}
{{-- <td>--}}
{{-- @can('delete', $task)--}}
{{-- <a--}}
{{-- class="text-red-600 hover:text-red-900"--}}
{{-- rel="nofollow"--}}
{{-- data-method="delete"--}}
{{-- data-confirm="{{ __('layout.table_delete_question') }}"--}}
{{-- href="{{ route('tasks.destroy', $task) }}"--}}
{{-- >--}}
{{-- {{ __('layout.table_delete') }}--}}
{{-- </a>--}}
{{-- @endcan--}}
{{-- @can('update', $task)--}}
{{-- <a class="text-blue-600 hover:text-blue-900"--}}
{{-- href="{{ route("tasks.edit", $task) }}"--}}
{{-- >--}}
{{-- {{ __('layout.table_edit') }}--}}
{{-- </a>--}}
{{-- @endcan--}}
{{-- </td>--}}
{{-- @endauth--}}
{{-- </tr>--}}
{{-- @endforeach--}}
{{-- </tbody>--}}
{{--</table>--}}

View File

@ -1,6 +1,7 @@
<?php
use App\Http\Controllers\ProfileController;
use App\Http\Controllers\UserController;
use Illuminate\Support\Facades\Route;
/*
@ -16,11 +17,19 @@ use Illuminate\Support\Facades\Route;
Route::get('/', function () {
return view('welcome');
});
Route::get('test', function () {
})->name('home');
Route::resource('/users', UserController::class);
Route::get('/test', function () {
return view('test');
});
Route::get('/dashboard', function () {
return view('dashboard');
})->middleware(['auth', 'verified'])->name('dashboard');
Route::get('/dashboard', function () {
return view('dashboard');
})->middleware(['auth', 'verified'])->name('dashboard');