setup module
This commit is contained in:
parent
e0fe321cb7
commit
1dbc6cabf8
@ -3,13 +3,13 @@
|
||||
namespace Modules\Employee\Http\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Role;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Modules\Employee\Repositories\EmployeeInterface;
|
||||
use Modules\User\Repositories\UserInterface;
|
||||
use Spatie\Permission\Models\Role;
|
||||
|
||||
class EmployeeController extends Controller
|
||||
{
|
||||
@ -53,6 +53,7 @@ class EmployeeController extends Controller
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
dd($request->all());
|
||||
$inputData = $request->all();
|
||||
try {
|
||||
|
||||
@ -63,8 +64,11 @@ class EmployeeController extends Controller
|
||||
}
|
||||
|
||||
$this->employeeRepository->create($inputData);
|
||||
|
||||
toastr()->success('Employee Created Succesfully');
|
||||
|
||||
} catch (\Throwable $th) {
|
||||
echo $th->getMessage();
|
||||
toastr()->error($th->getMessage());
|
||||
}
|
||||
return redirect()->route('employee.index');
|
||||
@ -114,19 +118,25 @@ class EmployeeController extends Controller
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
public function destroy($id)
|
||||
public function destroy(Request $request)
|
||||
{
|
||||
try {
|
||||
$employeeModel = $this->employeeRepository->getEmployeeById($id);
|
||||
$employeeModel->user->roles()->detach();
|
||||
$employeeModel->user->delete();
|
||||
$employeeModel->delete();
|
||||
|
||||
$employeeModel = $this->employeeRepository->getEmployeeById($request->id);
|
||||
|
||||
optional($employeeModel)->user?->roles()?->detach();
|
||||
|
||||
optional($employeeModel)->user?->delete();
|
||||
|
||||
optional($employeeModel)->delete();
|
||||
|
||||
toastr()->success('Employee Delete Succesfully');
|
||||
|
||||
} catch (\Throwable $th) {
|
||||
toastr()->error($th->getMessage());
|
||||
}
|
||||
return redirect()->route('employee.index');
|
||||
|
||||
return response()->json(['status' => true, 'message' => 'Employee Delete Succesfully']);
|
||||
|
||||
}
|
||||
|
||||
@ -153,4 +163,14 @@ class EmployeeController extends Controller
|
||||
return redirect()->route('employee.index');
|
||||
}
|
||||
|
||||
public function changePassword(Request $request)
|
||||
{
|
||||
dd($request->all());
|
||||
try {
|
||||
|
||||
} catch (\Throwable $th) {
|
||||
toastr()->error($th->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -42,7 +42,8 @@
|
||||
@forelse ($employees as $employee)
|
||||
<div class="col">
|
||||
<div class="card team-box ribbon-box mb-lg-0 material-shadow border shadow-none">
|
||||
<div class="team-cover"> <img src="assets/images/small/img-9.jpg" alt="" class="img-fluid">
|
||||
<div class="team-cover">
|
||||
<img src="{{ asset('assets/images/small/img-9.jpg') }}" alt="" class="img-fluid">
|
||||
</div>
|
||||
<div class="card-body p-4">
|
||||
@if ($employee->user)
|
||||
@ -69,9 +70,11 @@
|
||||
|
||||
<div class="col-lg-4 col">
|
||||
<div class="team-profile-img">
|
||||
<div class="avatar-lg img-thumbnail rounded-circle flex-shrink-0"><img
|
||||
src="{{ asset('app/public/uploads/' . $employee->profile_picture) }}" alt=""
|
||||
class="member-img img-fluid d-block rounded-circle"></div>
|
||||
<div class="img-thumbnail rounded-circle flex-shrink-0">
|
||||
<img style="height: 90px; width:90px; object-fit:cover"
|
||||
src="{{ asset($employee->profile_picture) }}" alt=""
|
||||
class="img-fluid rounded-circle">
|
||||
</div>
|
||||
<div class="team-content"> <a class="member-name"
|
||||
href="{{ route('employee.show', $employee->id) }}">
|
||||
<h5 class="fs-16 mb-1">{{ $employee->first_name }}</h5>
|
||||
|
@ -14,10 +14,16 @@ use Modules\Employee\Http\Controllers\EmployeeController;
|
||||
|
|
||||
*/
|
||||
|
||||
Route::group(['middleware' => 'auth'], function () {
|
||||
Route::post('assignRole', [EmployeeController::class, 'assignRole'])->name('employee.assignRole');
|
||||
Route::resource('employee', EmployeeController::class)->names('employee');
|
||||
Route::group(['prefix' => 'employee'], function () {
|
||||
Route::middleware('auth')->group(
|
||||
function () {
|
||||
|
||||
Route::prefix('employee')->as('employee.')->group(function () {
|
||||
|
||||
Route::post('assignRole', [EmployeeController::class, 'assignRole'])->name('assignRole');
|
||||
Route::post('changePassword', [EmployeeController::class, 'changePassword'])->name('assignRole');
|
||||
});
|
||||
|
||||
});
|
||||
Route::resource('employee', EmployeeController::class)->names('employee');
|
||||
|
||||
}
|
||||
);
|
||||
|
16
app/Models/Branches.php
Normal file
16
app/Models/Branches.php
Normal file
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Branches extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $table = "tbl_branches";
|
||||
protected $primaryKey = "branch_id";
|
||||
|
||||
protected $guarded = [];
|
||||
}
|
@ -9,7 +9,7 @@ class Cities extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $table = 'tbl_citites';
|
||||
protected $table = 'tbl_cities';
|
||||
protected $primaryKey = 'city_id';
|
||||
|
||||
protected $guarded = [];
|
||||
|
@ -15,19 +15,21 @@ class DatabaseSeeder extends Seeder
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
\App\Models\User::factory(10)->create();
|
||||
// \App\Models\User::factory(10)->create();
|
||||
|
||||
$admin = \App\Models\User::factory()->create([
|
||||
'name' => 'Admin User',
|
||||
'email' => 'admin@gmail.com',
|
||||
'password' => Hash::make('password'),
|
||||
'employee_id' => 1,
|
||||
'password' => bcrypt('password'),
|
||||
|
||||
]);
|
||||
|
||||
$member = \App\Models\User::factory()->create([
|
||||
'name' => 'Member User',
|
||||
'email' => 'member@gmail.com',
|
||||
'password' => Hash::make('password'),
|
||||
'employee_id' => 2,
|
||||
'password' => bcrypt('password'),
|
||||
|
||||
]);
|
||||
|
||||
|
@ -24,7 +24,9 @@ $('body').on('click', '.remove-item-btn', function (e) {
|
||||
id: id
|
||||
},
|
||||
success: function (response) {
|
||||
if(response.status == true){
|
||||
location.reload();
|
||||
}
|
||||
},
|
||||
error: function (xhr, status, error) {
|
||||
console.error(xhr.responseText);
|
||||
|
@ -1,30 +1,47 @@
|
||||
@extends('layouts.app')
|
||||
@section('content')
|
||||
<div class='card'>
|
||||
<div class='card-header d-flex justify-content-between align-items-center'>
|
||||
<h2 class="">{{ label('Add Cities') }}</h2>
|
||||
<?php createButton('btn-primary btn-cancel', '', 'Cancel', route('cities.index')); ?>
|
||||
<div class="page-content">
|
||||
<div class="container-fluid">
|
||||
|
||||
</div>
|
||||
<!-- start page title -->
|
||||
@include('layouts.partials.breadcrumb', ['title' => 'City'])
|
||||
|
||||
<!-- end page title -->
|
||||
<div class='card'>
|
||||
<div class='card-body'>
|
||||
<form action="{{ $editable ? route('cities.update', [$data->city_id]) : route('cities.store') }}" id="updateCustomForm"
|
||||
method="POST">
|
||||
@csrf <input type=hidden name='city_id' value='{{ $editable ? $data->city_id : '' }}' />
|
||||
<form action="{{ $editable ? route('cities.update', [$data->city_id]) : route('cities.store') }}"
|
||||
id="updateCustomForm" method="POST">
|
||||
|
||||
@csrf
|
||||
<input type=hidden name='city_id' value='{{ $editable ? $data->city_id : '' }}' />
|
||||
|
||||
<div class="row">
|
||||
|
||||
<div class="col-lg-6">
|
||||
{{ createCustomSelect('tbl_districts', 'title', 'district_id', $editable ? $data->districts_id : '', 'Districts Id', 'districts_id', 'form-control select2', 'status<>-1') }}
|
||||
{{ createText('title', 'title', 'Title', '', $editable ? $data->title : '') }}
|
||||
</div>
|
||||
<div class="col-lg-6">{{ createText('title', 'title', 'Title', '', $editable ? $data->title : '') }}
|
||||
|
||||
<div class="col-lg-6">
|
||||
{{ createCustomSelect('tbl_districts', 'title', 'district_id', $editable ? $data->districts_id : '', 'District', 'districts_id', 'form-control select2', 'status<>-1') }}
|
||||
</div>
|
||||
<div class="col-lg-12 pb-2">
|
||||
|
||||
|
||||
{{-- <div class="col-lg-12 pb-2">
|
||||
{{ createTextarea('description', 'description ckeditor-classic', 'Description', $editable ? $data->description : '') }}
|
||||
</div> --}}
|
||||
|
||||
<div class="col-lg-12 pb-2">
|
||||
{{ createPlainTextArea('remarks', '', 'Remarks', $editable ? $data->remarks : '') }}
|
||||
</div>
|
||||
<div class="col-lg-12 pb-2">{{ createPlainTextArea('remarks', '', 'Remarks', $editable ? $data->remarks : '') }}
|
||||
</div>
|
||||
<div class="col-md-12"><?php createButton('btn-primary btn-update', '', 'Submit'); ?>
|
||||
<?php createButton('btn-primary btn-cancel', '', 'Cancel', route('cities.index')); ?>
|
||||
|
||||
<div class="col-md-12 mt-2">
|
||||
<?php createButton('btn-primary btn-update', '', 'Submit'); ?>
|
||||
<?php createButton('btn-danger btn-cancel', '', 'Cancel', route('cities.index')); ?>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
@ -1,30 +1,39 @@
|
||||
@extends('layouts.app')
|
||||
@section('content')
|
||||
<div class="page-content">
|
||||
<div class="container-fluid">
|
||||
|
||||
<!-- start page title -->
|
||||
@include('layouts.partials.breadcrumb', ['title' => 'City'])
|
||||
<!-- end page title -->
|
||||
|
||||
<div class="card">
|
||||
<div class="card-header d-flex justify-content-between align-items-center">
|
||||
<h2>{{ label('Cities List') }}</h2>
|
||||
<a href="{{ route('cities.create') }}" class="btn btn-primary"><span>{{ label('Create New') }}</span></a>
|
||||
<div class="card-header align-items-center d-flex">
|
||||
<h5 class="card-title flex-grow-1 mb-0">City Lists</h5>
|
||||
<div class="flex-shrink-0">
|
||||
<a href="{{ route('cities.create') }}" class="btn btn-success waves-effect waves-light"><i
|
||||
class="ri-add-fill me-1 align-bottom"></i> Create City</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card-body">
|
||||
<table class="dataTable table" id="tbl_cities" data-url="{{ route('cities.sort') }}">
|
||||
<thead class="table-light">
|
||||
<tr>
|
||||
<th class="tb-col"><span class="overline-title">{{ label('Sn.') }}</span></th>
|
||||
<th class="tb-col"><span class="overline-title">{{ label('districts') }}</span></th>
|
||||
<th class="tb-col"><span class="overline-title">{{ label('District') }}</span></th>
|
||||
<th class="tb-col"><span class="overline-title">{{ label('title') }}</span></th>
|
||||
<th class="tb-col"><span class="overline-title">{{ label('alias') }}</span></th>
|
||||
<th class="tb-col" data-sortable="false"><span class="overline-title">{{ label('Action') }}</span>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
@php
|
||||
$i = 1;
|
||||
@endphp
|
||||
@foreach ($data as $item)
|
||||
<tr data-id="{{ $item->city_id }}" data-display_order="{{ $item->display_order }}"
|
||||
class="draggable-row <?php echo $item->status == 0 ? 'bg-light bg-danger' : ''; ?>">
|
||||
<td class="tb-col">{{ $i++ }}</td>
|
||||
<td class="tb-col">{{ $index + 1 }}</td>
|
||||
<td class="tb-col">
|
||||
{!! getFieldData('tbl_districts', 'title', 'district_id', $item->districts_id) !!}
|
||||
</td>
|
||||
@ -54,7 +63,6 @@
|
||||
<i class="ri-article-fill text-muted me-2 align-bottom"></i>
|
||||
{{ $item->status == 1 ? label('Unpublish') : label('Publish') }}
|
||||
</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="{{ route('cities.clone', [$item->city_id]) }}" class="dropdown-item toggle-item-btn"
|
||||
@ -68,38 +76,22 @@
|
||||
onclick="confirmDelete(this.href)">
|
||||
<i class="ri-delete-bin-fill text-muted me-2 align-bottom"></i> {{ label('Delete') }}
|
||||
</a>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@push('css')
|
||||
<link rel="stylesheet" href="https://cdn.datatables.net/1.13.5/css/dataTables.bootstrap4.min.css">
|
||||
<link rel="stylesheet" href="https://cdn.datatables.net/rowreorder/1.4.0/css/rowReorder.dataTables.min.css">
|
||||
@endpush
|
||||
|
||||
@push('js')
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.68/pdfmake.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.68/vfs_fonts.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
|
||||
<script src="https://cdn.datatables.net/1.13.5/js/jquery.dataTables.min.js"></script>
|
||||
<script src="https://cdn.datatables.net/buttons/2.4.1/js/buttons.html5.min.js"></script>
|
||||
<script src="https://cdn.datatables.net/rowreorder/1.4.0/js/dataTables.rowReorder.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
|
||||
|
||||
|
||||
<script>
|
||||
$(document).ready(function(e) {
|
||||
$('.change-alias-badge').on('click', function() {
|
||||
|
@ -1,17 +1,17 @@
|
||||
<?php
|
||||
use App\Http\Controllers\DistrictsController;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
Route::prefix("districts")->group(function () {
|
||||
Route::get('/', [DistrictsController::class, 'index'])->name('districts.index');
|
||||
Route::get('/create', [DistrictsController::class, 'create'])->name('districts.create');
|
||||
Route::post('/store', [DistrictsController::class, 'store'])->name('districts.store');
|
||||
Route::post('/sort', [DistrictsController::class, 'sort'])->name('districts.sort');
|
||||
Route::post('/updatealias', [DistrictsController::class, 'updatealias'])->name('districts.updatealias');
|
||||
Route::get('/show/{id}', [DistrictsController::class, 'show'])->name('districts.show');
|
||||
Route::get('/edit/{id}', [DistrictsController::class, 'edit'])->name('districts.edit') ;
|
||||
Route::post('/update/{id}', [DistrictsController::class, 'update'])->name('districts.update');
|
||||
Route::delete('/destroy/{id}', [DistrictsController::class, 'destroy'])->name('districts.destroy');
|
||||
Route::get('/toggle/{id}', [DistrictsController::class, 'toggle'])->name('districts.toggle');
|
||||
Route::get('/clone/{id}', [DistrictsController::class, 'clone'])->name('districts.clone');
|
||||
Route::prefix("district")->as('districts.')->group(function () {
|
||||
Route::get('/', [DistrictsController::class, 'index'])->name('index');
|
||||
Route::get('/create', [DistrictsController::class, 'create'])->name('create');
|
||||
Route::post('/store', [DistrictsController::class, 'store'])->name('store');
|
||||
Route::post('/sort', [DistrictsController::class, 'sort'])->name('sort');
|
||||
Route::post('/updatealias', [DistrictsController::class, 'updatealias'])->name('updatealias');
|
||||
Route::get('/show/{id}', [DistrictsController::class, 'show'])->name('show');
|
||||
Route::get('/edit/{id}', [DistrictsController::class, 'edit'])->name('edit') ;
|
||||
Route::post('/update/{id}', [DistrictsController::class, 'update'])->name('update');
|
||||
Route::delete('/destroy/{id}', [DistrictsController::class, 'destroy'])->name('destroy');
|
||||
Route::get('/toggle/{id}', [DistrictsController::class, 'toggle'])->name('toggle');
|
||||
Route::get('/clone/{id}', [DistrictsController::class, 'clone'])->name('clone');
|
||||
|
||||
});
|
@ -1,9 +1,8 @@
|
||||
<?php
|
||||
|
||||
use App\Http\Controllers\PermissionController;
|
||||
use App\Http\Controllers\RoleController;
|
||||
use App\Http\Controllers\UserController;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Modules\User\Http\Controllers\RoleController;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
@ -50,14 +49,14 @@ Route::middleware('auth')->group(function () {
|
||||
require __DIR__ . '/CRUDgenerated/route.districts.php';
|
||||
require __DIR__ . '/CRUDgenerated/route.cities.php';
|
||||
|
||||
require __DIR__ . '/CRUDgenerated/route.vendortypes.php';
|
||||
require __DIR__ . '/CRUDgenerated/route.vendors.php';
|
||||
// require __DIR__ . '/CRUDgenerated/route.vendortypes.php';
|
||||
// require __DIR__ . '/CRUDgenerated/route.vendors.php';
|
||||
|
||||
require __DIR__ . '/CRUDgenerated/route.genders.php';
|
||||
require __DIR__ . '/CRUDgenerated/route.castes.php';
|
||||
require __DIR__ . '/CRUDgenerated/route.nationalities.php';
|
||||
require __DIR__ . '/CRUDgenerated/route.ethnicities.php';
|
||||
require __DIR__ . '/CRUDgenerated/route.dags.php';
|
||||
// require __DIR__ . '/CRUDgenerated/route.genders.php';
|
||||
// require __DIR__ . '/CRUDgenerated/route.castes.php';
|
||||
// require __DIR__ . '/CRUDgenerated/route.nationalities.php';
|
||||
// require __DIR__ . '/CRUDgenerated/route.ethnicities.php';
|
||||
// require __DIR__ . '/CRUDgenerated/route.dags.php';
|
||||
|
||||
// require __DIR__ . '/CRUDgenerated/route.employees.php';
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user