user controller added
This commit is contained in:
parent
df5a77ae94
commit
d59affd0f7
@ -29,9 +29,10 @@ class UserController extends Controller
|
||||
return redirect()->route('users.index');
|
||||
}
|
||||
|
||||
public function index(UsersDataTable $dataTables)
|
||||
public function index()
|
||||
{
|
||||
return $dataTables->render('users.index');
|
||||
$users = User::latest()->get();
|
||||
return view('users.index', compact('users'));
|
||||
}
|
||||
|
||||
public function destroy(string $id)
|
||||
|
@ -1,26 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\View\Component;
|
||||
|
||||
class application-logo extends Component
|
||||
{
|
||||
/**
|
||||
* Create a new component instance.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*/
|
||||
public function render(): View|Closure|string
|
||||
{
|
||||
return view('components.application-logo');
|
||||
}
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\View\Component;
|
||||
|
||||
class auth-session-status extends Component
|
||||
{
|
||||
/**
|
||||
* Create a new component instance.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*/
|
||||
public function render(): View|Closure|string
|
||||
{
|
||||
return view('components.auth-session-status');
|
||||
}
|
||||
}
|
67
resources/views/users/create.blade.php
Normal file
67
resources/views/users/create.blade.php
Normal file
@ -0,0 +1,67 @@
|
||||
@extends('layouts.app')
|
||||
@section('content')
|
||||
<section class="section">
|
||||
<div class="section-header">
|
||||
<h1>Create User</h1>
|
||||
</div>
|
||||
<div class="card">
|
||||
<div class="card-header d-flex justify-content-between">
|
||||
<h5>Add New User</h5>
|
||||
<a href="{{ route('users.index') }}" class="btn btn-primary btn-sm">Back</a>
|
||||
</div>
|
||||
|
||||
<div class="card-body">
|
||||
<div class="card-body">
|
||||
<form action="{{ route('users.store') }}" method="post" enctype="multipart/form-data">
|
||||
@csrf
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="form-group">
|
||||
<label for="name">Name <span class="text-danger">*</span></label>
|
||||
<input id="name" class="form-control rounded-md" type="text" name="name" required />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="form-group">
|
||||
<label for="email">Email <span class="text-danger">*</span></label>
|
||||
<input id="email" class="form-control rounded-md" type="text" name="email" required />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="form-group">
|
||||
<label for="password">Password <span class="text-danger">*</span></label>
|
||||
<input id="password" class="form-control rounded-md" type="password" name="password" required />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="form-group">
|
||||
<label for="role_id">Role<span class="text-danger">*</span></label>
|
||||
<select class="form-control rounded-md" name="role">
|
||||
@foreach ($roles as $role)
|
||||
<option value="{{ $role->id }}">{{ $role->name }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-12 d-flex justify-end">
|
||||
<button type="submit" class="btn btn-primary">Save Record</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
@endsection
|
55
resources/views/users/index.blade.php
Normal file
55
resources/views/users/index.blade.php
Normal file
@ -0,0 +1,55 @@
|
||||
@extends('layouts.app')
|
||||
@section('content')
|
||||
<section class="section">
|
||||
<div class="section-header">
|
||||
<h1>List users</h1>
|
||||
</div>
|
||||
<div class="card">
|
||||
<div class="card-header d-flex justify-end p-3">
|
||||
@can('create users')
|
||||
<a href="{{ route('users.create') }}" class="btn btn-primary btn-sm">New User</a>
|
||||
@endcan
|
||||
</div>
|
||||
|
||||
<div class="card-body">
|
||||
<div class="table-responsive">
|
||||
<table class="table-bordered table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="border-1 border">S.N</th>
|
||||
<th class="border-1 border">Name</th>
|
||||
<th class="border-1 border">Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@can('access users')
|
||||
@foreach ($users as $permission)
|
||||
<tr>
|
||||
<td>{{ $permission->id }}</td>
|
||||
<td>{{ $permission->name }}</td>
|
||||
<td>
|
||||
@can('edit users')
|
||||
<a href="{{ route('users.edit', $permission->id) }}"
|
||||
class="btn btn-primary btn-sm rounded-lg text-white"><i class="fas fa-edit"></i></a>
|
||||
@endcan
|
||||
@can('delete users')
|
||||
<form action="{{ route('users.destroy', $permission->id) }}" method="post">
|
||||
@csrf
|
||||
@method('delete')
|
||||
<a href="{{ route('users.destroy', $permission->id) }}"
|
||||
class="btn btn-danger btn-sm rounded-lg text-white"
|
||||
onclick="event.preventDefault();this.closest('form').submit();"><i
|
||||
class="fas fa-trash-alt"></i></a>
|
||||
</form>
|
||||
@endcan
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
@endcan
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
@endsection
|
@ -2,6 +2,7 @@
|
||||
|
||||
use App\Http\Controllers\PermissionController;
|
||||
use App\Http\Controllers\RoleController;
|
||||
use App\Http\Controllers\UserController;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
/*
|
||||
@ -25,3 +26,4 @@ Route::get('/dashboard', [App\Http\Controllers\HomeController::class, 'index'])-
|
||||
|
||||
Route::resource('roles', RoleController::class)->names('roles');
|
||||
Route::resource('permissions', PermissionController::class)->names('permissions');
|
||||
Route::resource('users', UserController::class)->names('users');
|
||||
|
Loading…
Reference in New Issue
Block a user