Update Metronic Version to 8.2.1 #1

Merged
putrakuningan merged 77 commits from dev into master 2024-05-04 09:46:45 +00:00
7 changed files with 807 additions and 634 deletions
Showing only changes of commit eea0e3d304 - Show all commits

View File

@ -1,123 +1,157 @@
<?php <?php
namespace App\Http\Controllers; namespace App\Http\Controllers;
use App\DataTables\DirectoratDataTable; use App\DataTables\DirectoratDataTable;
use App\Http\Requests\StoreDirectoratRequest; use App\Http\Requests\StoreDirectoratRequest;
use App\Http\Requests\UpdateDirectoratRequest; use App\Http\Requests\UpdateDirectoratRequest;
use App\Models\Directorat; use App\Models\Directorat;
use Illuminate\Http\Request; use Exception;
use Spatie\Activitylog\Facades\CauserResolver; use Illuminate\Http\Request;
use Spatie\Activitylog\Facades\CauserResolver;
class DirectoratController extends Controller class DirectoratController extends Controller
{ {
public $user; public $user;
public function __construct() public function __construct()
{ {
$this->middleware(function ($request, $next) { $this->middleware(function ($request, $next) {
//$this->user = Auth::guard('web')->user(); $this->user = Auth::guard('web')->user();
return $next($request); return $next($request);
}); });
//CauserResolver::setCauser($this->user);
} }
/** /**
* Display a listing of the resource. * Display a listing of the Directorats.
*
* @param \App\DataTables\DirectoratDataTable $dataTable
*
* @return mixed
*/ */
public function index(DirectoratDataTable $dataTable) public function index(DirectoratDataTable $dataTable, Request $request)
{ {
/*if (is_null($this->user) || !$this->user->can('masters.read')) { if (is_null($this->user) || !$this->user->can('masters.read')) {
abort(403, 'Sorry !! You are Unauthorized to view any master data !'); abort(403, 'Sorry !! You are Unauthorized to view any master data !');
}*/ }
return $dataTable->render('pages.masters.directorat.index'); return $dataTable->render('pages.masters.directorat.index');
} }
/** /**
* Show the form for creating a new resource. * Store a newly created Directorat in storage.
*/ *
public function create(){} * @param \App\Http\Requests\StoreDirectoratRequest $request
*
/** * @return mixed
* Store a newly created resource in storage.
*/ */
public function store(StoreDirectoratRequest $request) public function store(StoreDirectoratRequest $request)
{ {
/*if (is_null($this->user) || !$this->user->can('masters.create')) { if (is_null($this->user) || !$this->user->can('masters.create')) {
abort(403, 'Sorry !! You are Unauthorized to create any master data !'); abort(403, 'Sorry !! You are Unauthorized to create any master data !');
}*/ }
// Validate the request... // Validate the request...
$validated = $request->validated(); $validated = $request->validated();
// Store the Directorat... // Store the Directorat...
if($validated){ if ($validated) {
try{ try {
Directorat::create($validated); Directorat::create($validated);
//return redirect()->route('directorat.index')->with('success', 'Directorat created successfully.');
echo json_encode(['status' => 'success', 'message' => 'Directorat created successfully.']); echo json_encode(['status' => 'success', 'message' => 'Directorat created successfully.']);
}catch(\Exception $e){ } catch (Exception $e) {
//return redirect()->route('directorat.index')->with('error', 'Directorat created failed.');
echo json_encode(['status' => 'error', 'message' => 'Directorat created failed.']); echo json_encode(['status' => 'error', 'message' => 'Directorat created failed.']);
} }
} }
return false; echo json_encode(['status' => 'error', 'message' => 'Directorat created failed.']);
} }
/** /**
* Display the specified resource. * Show the form for creating a new Directorat.
*/
public function create()
{
if (is_null($this->user) || !$this->user->can('masters.create')) {
abort(403, 'Sorry !! You are Unauthorized to create any master data !');
}
show_404();
}
/**
* Display the specified Directorat.
*
* @param \App\Models\Directorat $directorat
*/ */
public function show(Directorat $directorat) public function show(Directorat $directorat)
{ {
if (is_null($this->user) || !$this->user->can('masters.read')) {
abort(403, 'Sorry !! You are Unauthorized to view any master data !');
}
} }
/** /**
* Show the form for editing the specified resource. * Show the form for editing the specified Directorat.
*
* @param $id
*/ */
public function edit($id){ public function edit($id)
{
if (is_null($this->user) || !$this->user->can('masters.update')) {
abort(403, 'Sorry !! You are Unauthorized to update any master data !');
}
$directorat = Directorat::find($id); $directorat = Directorat::find($id);
echo json_encode($directorat); echo json_encode($directorat);
} }
/** /**
* Update the specified resource in storage. * Update the specified Directorat in storage.
*
* @param \App\Http\Requests\UpdateDirectoratRequest $request
* @param \App\Models\Directorat $directorat
*
* @return mixed
*/ */
public function update(UpdateDirectoratRequest $request, Directorat $directorat) public function update(UpdateDirectoratRequest $request, Directorat $directorat)
{ {
/*if (is_null($this->user) || !$this->user->can('masters.update')) { if (is_null($this->user) || !$this->user->can('masters.update')) {
abort(403, 'Sorry !! You are Unauthorized to update any master data !'); abort(403, 'Sorry !! You are Unauthorized to update any master data !');
}*/ }
// Validate the request... // Validate the request...
$validated = $request->validated(); $validated = $request->validated();
// Update the Directorat... // Update the Directorat...
if($validated){ if ($validated) {
try{ try {
CauserResolver::setCauser($this->user); CauserResolver::setCauser($this->user);
$directorat->update($validated); $directorat->update($validated);
//return redirect()->route('directorat.index')->with('success', 'Directorat updated successfully.');
echo json_encode(['status' => 'success', 'message' => 'Directorat updated successfully.']); echo json_encode(['status' => 'success', 'message' => 'Directorat updated successfully.']);
}catch(\Exception $e){ } catch (Exception $e) {
//return redirect()->route('directorat.index')->with('error', 'Directorat updated failed.');
echo json_encode(['status' => 'error', 'message' => 'Directorat updated failed.']); echo json_encode(['status' => 'error', 'message' => 'Directorat updated failed.']);
} }
} }
return false; echo json_encode(['status' => 'error', 'message' => 'Directorat updated failed.']);
} }
/** /**
* Remove the specified resource from storage. * Remove the specified Directorat from storage.
*
* @param \App\Models\Directorat $directorat
*
* @return void
*/ */
public function destroy(Directorat $directorat){ public function destroy(Directorat $directorat)
{
if (is_null($this->user) || !$this->user->can('masters.delete')) {
abort(403, 'Sorry !! You are Unauthorized to delete any master data !');
}
$directorat->delete(); $directorat->delete();
echo json_encode(['status' => 'success', 'message' => 'Directorat deleted successfully.']); echo json_encode(['status' => 'success', 'message' => 'Directorat deleted successfully.']);
} }
} }

View File

@ -1,38 +1,45 @@
<?php <?php
namespace App\Http\Controllers; namespace App\Http\Controllers;
use App\DataTables\JobDataTable; use App\DataTables\JobDataTable;
use App\Http\Requests\StoreJobRequest; use App\Http\Requests\StoreJobRequest;
use App\Http\Requests\UpdateJobRequest; use App\Http\Requests\UpdateJobRequest;
use App\Models\Directorat; use App\Models\Directorat;
use App\Models\Job; use App\Models\Job;
use Illuminate\Http\Request; use Exception;
use Illuminate\Http\Request;
class JobController extends Controller class JobController extends Controller
{ {
public $user; public $user;
public function __construct() public function __construct()
{ {
$this->middleware(function ($request, $next) { $this->middleware(function ($request, $next) {
//$this->user = Auth::guard('web')->user(); $this->user = Auth::guard('web')->user();
return $next($request); return $next($request);
}); });
} }
/** /**
* Display a listing of the resource. * Display a listing of the Jobs.
*
* @param \App\DataTables\JobDataTable $dataTable
* @param \Illuminate\Http\Request $request
*
* @return mixed|void
*/ */
public function index(JobDataTable $dataTable, Request $request) public function index(JobDataTable $dataTable, Request $request)
{ {
/*if (is_null($this->user) || !$this->user->can('masters.read')) { if (is_null($this->user) || !$this->user->can('masters.read')) {
abort(403, 'Sorry !! You are Unauthorized to view any master data !'); abort(403, 'Sorry !! You are Unauthorized to view any master data !');
}*/ }
// Add Vendor // Add Vendor
addVendor('chained-select'); addVendor('chained-select');
if(isset($request->sub_directorat_id) && !empty($request->sub_directorat_id)) { if (isset($request->sub_directorat_id) && !empty($request->sub_directorat_id)) {
$this->show($request); $this->show($request);
return; return;
} }
@ -42,43 +49,18 @@ class JobController extends Controller
} }
/** /**
* Show the form for creating a new resource. * Lists the specified Job by Sub Directorat ID.
*/ *
public function create(){} * @param \Illuminate\Http\Request $request
*
/** * @return void
* Store a newly created resource in storage.
*/
public function store(StoreJobRequest $request)
{
/*if (is_null($this->user) || !$this->user->can('masters.create')) {
abort(403, 'Sorry !! You are Unauthorized to create any master data !');
}*/
// Validate the request...
$validated = $request->validated();
// Store the Job...
if($validated){
try{
Job::create($validated);
//return redirect()->route('job.index')->with('success', 'Job created successfully.');
echo json_encode(['status' => 'success', 'message' => 'Job created successfully.']);
}catch(\Exception $e){
//return redirect()->route('job.index')->with('error', 'Job created failed.');
echo json_encode(['status' => 'error', 'message' => 'Job created failed.']);
}
}
return false;
}
/**
* Display the specified resource.
*/ */
public function show(Request $request) public function show(Request $request)
{ {
if (is_null($this->user) || !$this->user->can('masters.read')) {
abort(403, 'Sorry !! You are Unauthorized to view any master data !');
}
$jobs = Job::where('sub_directorat_id', $request->sub_directorat_id)->get(); $jobs = Job::where('sub_directorat_id', $request->sub_directorat_id)->get();
$data = []; $data = [];
@ -94,46 +76,107 @@ class JobController extends Controller
} }
/** /**
* Show the form for editing the specified resource. * Store a newly created Job in storage.
*
* @param \App\Http\Requests\StoreJobRequest $request
*
* @return void
*/ */
public function edit($id){ public function store(StoreJobRequest $request)
{
if (is_null($this->user) || !$this->user->can('masters.create')) {
abort(403, 'Sorry !! You are Unauthorized to create any master data !');
}
// Validate the request...
$validated = $request->validated();
// Store the Job...
if ($validated) {
try {
Job::create($validated);
echo json_encode(['status' => 'success', 'message' => 'Job created successfully.']);
} catch (Exception $e) {
echo json_encode(['status' => 'error', 'message' => 'Job created failed.']);
}
}
echo json_encode(['status' => 'error', 'message' => 'Job created failed.']);
}
/**
* Show the form for creating a new Job.
*/
public function create()
{
if (is_null($this->user) || !$this->user->can('masters.create')) {
abort(403, 'Sorry !! You are Unauthorized to create any master data !');
}
show_404();
}
/**
* Show the form for editing the specified Job.
*
* @param $id
*
* @return void
*/
public function edit($id)
{
if (is_null($this->user) || !$this->user->can('masters.update')) {
abort(403, 'Sorry !! You are Unauthorized to update any master data !');
}
$job = Job::find($id); $job = Job::find($id);
echo json_encode($job); echo json_encode($job);
} }
/** /**
* Update the specified resource in storage. * Update the specified Job in storage.
*
* @param \App\Http\Requests\UpdateJobRequest $request
* @param \App\Models\Job $job
*
* @return void
*/ */
public function update(UpdateJobRequest $request, Job $job) public function update(UpdateJobRequest $request, Job $job)
{ {
/*if (is_null($this->user) || !$this->user->can('masters.update')) { if (is_null($this->user) || !$this->user->can('masters.update')) {
abort(403, 'Sorry !! You are Unauthorized to update any master data !'); abort(403, 'Sorry !! You are Unauthorized to update any master data !');
}*/ }
// Validate the request... // Validate the request...
$validated = $request->validated(); $validated = $request->validated();
// Update the Job... // Update the Job...
if($validated){ if ($validated) {
try{ try {
$job->update($validated); $job->update($validated);
//return redirect()->route('job.index')->with('success', 'Job updated successfully.');
echo json_encode(['status' => 'success', 'message' => 'Job updated successfully.']); echo json_encode(['status' => 'success', 'message' => 'Job updated successfully.']);
}catch(\Exception $e){ } catch (Exception $e) {
//return redirect()->route('job.index')->with('error', 'Job updated failed.');
echo json_encode(['status' => 'error', 'message' => 'Job updated failed.']); echo json_encode(['status' => 'error', 'message' => 'Job updated failed.']);
} }
} }
return false; echo json_encode(['status' => 'error', 'message' => 'Job updated failed.']);
} }
/** /**
* Remove the specified resource from storage. * Remove the specified Job from storage.
*
* @param \App\Models\Job $job
*
* @return void
*/ */
public function destroy(Job $job){ public function destroy(Job $job)
{
if (is_null($this->user) || !$this->user->can('masters.delete')) {
abort(403, 'Sorry !! You are Unauthorized to delete any master data !');
}
$job->delete(); $job->delete();
echo json_encode(['status' => 'success', 'message' => 'Job deleted successfully.']); echo json_encode(['status' => 'success', 'message' => 'Job deleted successfully.']);
//return redirect()->route('job.index')->with('success', 'Job deleted successfully.');
} }
} }

View File

@ -1,80 +1,56 @@
<?php <?php
namespace App\Http\Controllers; namespace App\Http\Controllers;
use App\DataTables\SubDirectoratDataTable; use App\DataTables\SubDirectoratDataTable;
use App\Http\Requests\StoreSubDirectoratRequest; use App\Http\Requests\StoreSubDirectoratRequest;
use App\Http\Requests\UpdateSubDirectoratRequest; use App\Http\Requests\UpdateSubDirectoratRequest;
use App\Models\Directorat; use App\Models\Directorat;
use App\Models\SubDirectorat; use App\Models\SubDirectorat;
use Illuminate\Http\Request; use Exception;
use Illuminate\Http\Request;
class SubDirectoratController extends Controller class SubDirectoratController extends Controller
{ {
public $user; public $user;
public function __construct() public function __construct()
{ {
$this->middleware(function ($request, $next) { $this->middleware(function ($request, $next) {
//$this->user = Auth::guard('web')->user(); $this->user = Auth::guard('web')->user();
return $next($request); return $next($request);
}); });
} }
/** /**
* Display a listing of the resource. * Display a listing of the Sub Directorats.
*
* @param \App\DataTables\SubDirectoratDataTable $dataTable
* @param \Illuminate\Http\Request $request
*
* @return mixed|void
*/ */
public function index(SubDirectoratDataTable $dataTable, Request $request) public function index(SubDirectoratDataTable $dataTable, Request $request)
{ {
/*if (is_null($this->user) || !$this->user->can('masters.read')) { if (is_null($this->user) || !$this->user->can('masters.read')) {
abort(403, 'Sorry !! You are Unauthorized to view any master data !'); abort(403, 'Sorry !! You are Unauthorized to view any master data !');
}*/ }
if(isset($request->directorat_id) && !empty($request->directorat_id)) { if (isset($request->directorat_id) && !empty($request->directorat_id)) {
$this->show($request); $this->show($request);
return; return;
} }
$directorat = Directorat::all(); $directorat = Directorat::all();
return $dataTable->render('pages.masters.sub-directorat.index', compact('directorat')); return $dataTable->render('pages.masters.sub-directorat.index', compact('directorat'));
} }
/** /**
* Show the form for creating a new resource. * Lists the specified Sub Directorat by Directorat ID.
*/ *
public function create(){} * @param \Illuminate\Http\Request $request
*
/** * @return void
* Store a newly created resource in storage.
*/
public function store(StoreSubDirectoratRequest $request)
{
/*if (is_null($this->user) || !$this->user->can('masters.create')) {
abort(403, 'Sorry !! You are Unauthorized to create any master data !');
}*/
// Validate the request...
$validated = $request->validated();
// Store the SubDirectorat...
if($validated){
try{
SubDirectorat::create($validated);
//return redirect()->route('directorat.index')->with('success', 'SubDirectorat created successfully.');
echo json_encode(['status' => 'success', 'message' => 'Sub Directorat created successfully.']);
}catch(\Exception $e){
//return redirect()->route('directorat.index')->with('error', 'SubDirectorat created failed.');
echo json_encode(['status' => 'error', 'message' => 'Sub Directorat created failed.']);
}
}
return false;
}
/**
* Display the specified resource.
*/ */
public function show(Request $request) public function show(Request $request)
{ {
@ -93,46 +69,107 @@ class SubDirectoratController extends Controller
} }
/** /**
* Show the form for editing the specified resource. * Store a newly created Sub Directorat in storage.
*
* @param \App\Http\Requests\StoreSubDirectoratRequest $request
*
* @return void
*/ */
public function edit($id){ public function store(StoreSubDirectoratRequest $request)
{
if (is_null($this->user) || !$this->user->can('masters.create')) {
abort(403, 'Sorry !! You are Unauthorized to create any master data !');
}
// Validate the request...
$validated = $request->validated();
// Store the SubDirectorat...
if ($validated) {
try {
SubDirectorat::create($validated);
echo json_encode(['status' => 'success', 'message' => 'Sub Directorat created successfully.']);
} catch (Exception $e) {
echo json_encode(['status' => 'error', 'message' => 'Sub Directorat created failed.']);
}
}
echo json_encode(['status' => 'error', 'message' => 'Sub Directorat created failed.']);
}
/**
* Show the form for creating a new Sub Directorat.
*/
public function create()
{
if (is_null($this->user) || !$this->user->can('masters.create')) {
abort(403, 'Sorry !! You are Unauthorized to create any master data !');
}
show_404();
}
/**
* Show the form for editing the specified Sub Directorat.
*
* @param $id
*
* @return void
*/
public function edit($id)
{
if (is_null($this->user) || !$this->user->can('masters.update')) {
abort(403, 'Sorry !! You are Unauthorized to update any master data !');
}
$subDirectorat = SubDirectorat::find($id); $subDirectorat = SubDirectorat::find($id);
echo json_encode($subDirectorat); echo json_encode($subDirectorat);
} }
/** /**
* Update the specified resource in storage. * Update the specified Sub Directorat in storage.
*
* @param \App\Http\Requests\UpdateSubDirectoratRequest $request
* @param \App\Models\SubDirectorat $subDirectorat
*
* @return void
*/ */
public function update(UpdateSubDirectoratRequest $request, SubDirectorat $subDirectorat) public function update(UpdateSubDirectoratRequest $request, SubDirectorat $subDirectorat)
{ {
/*if (is_null($this->user) || !$this->user->can('masters.update')) { if (is_null($this->user) || !$this->user->can('masters.update')) {
abort(403, 'Sorry !! You are Unauthorized to update any master data !'); abort(403, 'Sorry !! You are Unauthorized to update any master data !');
}*/ }
// Validate the request... // Validate the request...
$validated = $request->validated(); $validated = $request->validated();
// Update the SubDirectorat... // Update the SubDirectorat...
if($validated){ if ($validated) {
try{ try {
$subDirectorat->update($validated); $subDirectorat->update($validated);
//return redirect()->route('directorat.index')->with('success', 'SubDirectorat updated successfully.');
echo json_encode(['status' => 'success', 'message' => 'Sub Directorat updated successfully.']); echo json_encode(['status' => 'success', 'message' => 'Sub Directorat updated successfully.']);
}catch(\Exception $e){ } catch (Exception $e) {
//return redirect()->route('directorat.index')->with('error', 'SubDirectorat updated failed.');
echo json_encode(['status' => 'error', 'message' => 'Sub Directorat updated failed.']); echo json_encode(['status' => 'error', 'message' => 'Sub Directorat updated failed.']);
} }
} }
return false; echo json_encode(['status' => 'error', 'message' => 'Sub Directorat updated failed.']);
} }
/** /**
* Remove the specified resource from storage. * Remove the specified Sub Directorat from storage.
*
* @param \App\Models\SubDirectorat $subDirectorat
*
* @return void
*/ */
public function destroy(SubDirectorat $subDirectorat){ public function destroy(SubDirectorat $subDirectorat)
{
if (is_null($this->user) || !$this->user->can('masters.delete')) {
abort(403, 'Sorry !! You are Unauthorized to delete any master data !');
}
$subDirectorat->delete(); $subDirectorat->delete();
echo json_encode(['status' => 'success', 'message' => 'Sub Directorat deleted successfully.']); echo json_encode(['status' => 'success', 'message' => 'Sub Directorat deleted successfully.']);
//return redirect()->route('sub-directorat.index')->with('success', 'Sub Directorat deleted successfully.');
} }
} }

View File

@ -1,38 +1,44 @@
<?php <?php
namespace App\Http\Controllers; namespace App\Http\Controllers;
use App\DataTables\SubJobDataTable; use App\DataTables\SubJobDataTable;
use App\Http\Requests\StoreSubJobRequest; use App\Http\Requests\StoreSubJobRequest;
use App\Http\Requests\UpdateSubJobRequest; use App\Http\Requests\UpdateSubJobRequest;
use App\Models\Directorat; use App\Models\Directorat;
use App\Models\Job; use App\Models\SubJob;
use App\Models\SubJob; use Exception;
use Illuminate\Http\Request; use Illuminate\Http\Request;
class SubJobController extends Controller class SubJobController extends Controller
{ {
public $user; public $user;
public function __construct() public function __construct()
{ {
$this->middleware(function ($request, $next) { $this->middleware(function ($request, $next) {
//$this->user = Auth::guard('web')->user(); $this->user = Auth::guard('web')->user();
return $next($request); return $next($request);
}); });
} }
/** /**
* Display a listing of the resource. * Display a listing of the Sub Jobs.
*
* @param \App\DataTables\SubJobDataTable $dataTable
* @param \Illuminate\Http\Request $request
*
* @return mixed|void
*/ */
public function index(SubJobDataTable $dataTable, Request $request) public function index(SubJobDataTable $dataTable, Request $request)
{ {
/*if (is_null($this->user) || !$this->user->can('masters.read')) { if (is_null($this->user) || !$this->user->can('masters.read')) {
abort(403, 'Sorry !! You are Unauthorized to view any master data !'); abort(403, 'Sorry !! You are Unauthorized to view any master data !');
}*/ }
addVendor('chained-select'); addVendor('chained-select');
if(isset($request->job_id) && !empty($request->job_id)) { if (isset($request->job_id) && !empty($request->job_id)) {
$this->show($request); $this->show($request);
return; return;
} }
@ -42,40 +48,11 @@ class SubJobController extends Controller
} }
/** /**
* Show the form for creating a new resource. * Lists the specified Sub Job by Job ID.
*/ *
public function create(){} * @param \Illuminate\Http\Request $request
*
/** * @return void
* Store a newly created resource in storage.
*/
public function store(StoreSubJobRequest $request)
{
/*if (is_null($this->user) || !$this->user->can('masters.create')) {
abort(403, 'Sorry !! You are Unauthorized to create any master data !');
}*/
// Validate the request...
$validated = $request->validated();
// Store the SubJob...
if($validated){
try{
SubJob::create($validated);
//return redirect()->route('job.index')->with('success', 'SubJob created successfully.');
echo json_encode(['status' => 'success', 'message' => 'Sub Job created successfully.']);
}catch(\Exception $e){
//return redirect()->route('job.index')->with('error', 'SubJob created failed.');
echo json_encode(['status' => 'error', 'message' => 'Sub Job created failed.']);
}
}
return false;
}
/**
* Display the specified resource.
*/ */
public function show(Request $request) public function show(Request $request)
{ {
@ -94,46 +71,109 @@ class SubJobController extends Controller
} }
/** /**
* Show the form for editing the specified resource. * Store a newly created Sub Job in storage.
*
* @param \App\Http\Requests\StoreSubJobRequest $request
*
* @return void
*/ */
public function edit($id){ public function store(StoreSubJobRequest $request)
{
if (is_null($this->user) || !$this->user->can('masters.create')) {
abort(403, 'Sorry !! You are Unauthorized to create any master data !');
}
// Validate the request...
$validated = $request->validated();
// Store the SubJob...
if ($validated) {
try {
SubJob::create($validated);
echo json_encode(['status' => 'success', 'message' => 'Sub Job created successfully.']);
} catch (Exception $e) {
echo json_encode(['status' => 'error', 'message' => 'Sub Job created failed.']);
}
}
echo json_encode(['status' => 'error', 'message' => 'Sub Job created failed.']);
}
/**
* Show the form for creating a new Sub Job.
*
* @return void
*/
public function create()
{
if (is_null($this->user) || !$this->user->can('masters.create')) {
abort(403, 'Sorry !! You are Unauthorized to create any master data !');
}
show_404();
}
/**
* Show the form for editing the specified Sub Job.
*
* @param $id
*
* @return void
*/
public function edit($id)
{
if (is_null($this->user) || !$this->user->can('masters.update')) {
abort(403, 'Sorry !! You are Unauthorized to update any master data !');
}
$subJob = SubJob::find($id); $subJob = SubJob::find($id);
echo json_encode($subJob); echo json_encode($subJob);
} }
/** /**
* Update the specified resource in storage. * Update the specified Sub Job in storage.
*
* @param \App\Http\Requests\UpdateSubJobRequest $request
* @param \App\Models\SubJob $subJob
*
* @return false
*/ */
public function update(UpdateSubJobRequest $request, SubJob $subJob) public function update(UpdateSubJobRequest $request, SubJob $subJob)
{ {
/*if (is_null($this->user) || !$this->user->can('masters.update')) { if (is_null($this->user) || !$this->user->can('masters.update')) {
abort(403, 'Sorry !! You are Unauthorized to update any master data !'); abort(403, 'Sorry !! You are Unauthorized to update any master data !');
}*/ }
// Validate the request... // Validate the request...
$validated = $request->validated(); $validated = $request->validated();
// Update the SubJob... // Update the SubJob...
if($validated){ if ($validated) {
try{ try {
$subJob->update($validated); $subJob->update($validated);
//return redirect()->route('job.index')->with('success', 'SubJob updated successfully.');
echo json_encode(['status' => 'success', 'message' => 'Sub Job updated successfully.']); echo json_encode(['status' => 'success', 'message' => 'Sub Job updated successfully.']);
}catch(\Exception $e){ } catch (Exception $e) {
//return redirect()->route('job.index')->with('error', 'SubJob updated failed.');
echo json_encode(['status' => 'error', 'message' => 'Sub Job updated failed.']); echo json_encode(['status' => 'error', 'message' => 'Sub Job updated failed.']);
} }
} }
return false; echo json_encode(['status' => 'error', 'message' => 'Sub Job updated failed.']);
} }
/** /**
* Remove the specified resource from storage. * Remove the specified Sub Job from storage.
*
* @param \App\Models\SubJob $subJob
*
* @return void
*/ */
public function destroy(SubJob $subJob){ public function destroy(SubJob $subJob)
{
if (is_null($this->user) || !$this->user->can('masters.delete')) {
abort(403, 'Sorry !! You are Unauthorized to delete any master data !');
}
$subJob->delete(); $subJob->delete();
echo json_encode(['status' => 'success', 'message' => 'Sub Job deleted successfully.']); echo json_encode(['status' => 'success', 'message' => 'Sub Job deleted successfully.']);
//return redirect()->route('sub-job.index')->with('success', 'Sub Job deleted successfully.');
} }
} }

View File

@ -1,37 +1,42 @@
<?php <?php
namespace App\Http\Controllers; namespace App\Http\Controllers;
use App\DataTables\SubSubJobDataTable; use App\DataTables\SubSubJobDataTable;
use App\Http\Requests\StoreSubSubJobRequest; use App\Http\Requests\StoreSubSubJobRequest;
use App\Http\Requests\UpdateSubSubJobRequest; use App\Http\Requests\UpdateSubSubJobRequest;
use App\Models\Directorat; use App\Models\Directorat;
use App\Models\Job; use App\Models\SubSubJob;
use App\Models\SubSubJob; use Exception;
use Illuminate\Http\Request; use Illuminate\Http\Request;
class SubSubJobController extends Controller class SubSubJobController extends Controller
{ {
public $user; public $user;
public function __construct() public function __construct()
{ {
$this->middleware(function ($request, $next) { $this->middleware(function ($request, $next) {
//$this->user = Auth::guard('web')->user(); $this->user = Auth::guard('web')->user();
return $next($request); return $next($request);
}); });
} }
/** /**
* Display a listing of the resource. * Display a listing of the Sub Sub Jobs.
*
* @param \App\DataTables\SubSubJobDataTable $dataTable
* @param \Illuminate\Http\Request $request
*
* @return mixed|void
*/ */
public function index(SubSubJobDataTable $dataTable, Request $request) public function index(SubSubJobDataTable $dataTable, Request $request)
{ {
/*if (is_null($this->user) || !$this->user->can('masters.read')) { if (is_null($this->user) || !$this->user->can('masters.read')) {
abort(403, 'Sorry !! You are Unauthorized to view any master data !'); abort(403, 'Sorry !! You are Unauthorized to view any master data !');
}*/ }
if(isset($request->sub_job_id) && !empty($request->sub_job_id)) { if (isset($request->sub_job_id) && !empty($request->sub_job_id)) {
$this->show($request); $this->show($request);
return; return;
} }
@ -43,40 +48,11 @@ class SubSubJobController extends Controller
} }
/** /**
* Show the form for creating a new resource. * Lists the specified Sub Sub Job by Sub Job ID.
*/ *
public function create(){} * @param \Illuminate\Http\Request $request
*
/** * @return void
* Store a newly created resource in storage.
*/
public function store(StoreSubSubJobRequest $request)
{
/*if (is_null($this->user) || !$this->user->can('masters.create')) {
abort(403, 'Sorry !! You are Unauthorized to create any master data !');
}*/
// Validate the request...
$validated = $request->validated();
// Store the SubSubJob...
if($validated){
try{
SubSubJob::create($validated);
//return redirect()->route('job.index')->with('success', 'SubSubJob created successfully.');
echo json_encode(['status' => 'success', 'message' => 'Sub Sub Job created successfully.']);
}catch(\Exception $e){
//return redirect()->route('job.index')->with('error', 'SubSubJob created failed.');
echo json_encode(['status' => 'error', 'message' => 'Sub Sub Job created failed.']);
}
}
return false;
}
/**
* Display the specified resource.
*/ */
public function show(Request $request) public function show(Request $request)
{ {
@ -94,10 +70,48 @@ class SubSubJobController extends Controller
echo json_encode($data); echo json_encode($data);
} }
/**
* Store a newly created Sub Sub Job in storage.
*
* @param \App\Http\Requests\StoreSubSubJobRequest $request
*
* @return false
*/
public function store(StoreSubSubJobRequest $request)
{
/*if (is_null($this->user) || !$this->user->can('masters.create')) {
abort(403, 'Sorry !! You are Unauthorized to create any master data !');
}*/
// Validate the request...
$validated = $request->validated();
// Store the SubSubJob...
if ($validated) {
try {
SubSubJob::create($validated);
//return redirect()->route('job.index')->with('success', 'SubSubJob created successfully.');
echo json_encode(['status' => 'success', 'message' => 'Sub Sub Job created successfully.']);
} catch (Exception $e) {
//return redirect()->route('job.index')->with('error', 'SubSubJob created failed.');
echo json_encode(['status' => 'error', 'message' => 'Sub Sub Job created failed.']);
}
}
return false;
}
/**
* Show the form for creating a new resource.
*/
public function create() { }
/** /**
* Show the form for editing the specified resource. * Show the form for editing the specified resource.
*/ */
public function edit($id){ public function edit($id)
{
$subJob = SubSubJob::find($id); $subJob = SubSubJob::find($id);
echo json_encode($subJob); echo json_encode($subJob);
} }
@ -114,12 +128,12 @@ class SubSubJobController extends Controller
// Validate the request... // Validate the request...
$validated = $request->validated(); $validated = $request->validated();
// Update the SubSubJob... // Update the SubSubJob...
if($validated){ if ($validated) {
try{ try {
$subSubJob->update($validated); $subSubJob->update($validated);
//return redirect()->route('job.index')->with('success', 'SubSubJob updated successfully.'); //return redirect()->route('job.index')->with('success', 'SubSubJob updated successfully.');
echo json_encode(['status' => 'success', 'message' => 'Sub Sub Job updated successfully.']); echo json_encode(['status' => 'success', 'message' => 'Sub Sub Job updated successfully.']);
}catch(\Exception $e){ } catch (Exception $e) {
//return redirect()->route('job.index')->with('error', 'SubSubJob updated failed.'); //return redirect()->route('job.index')->with('error', 'SubSubJob updated failed.');
echo json_encode(['status' => 'error', 'message' => 'Sub Sub Job updated failed.']); echo json_encode(['status' => 'error', 'message' => 'Sub Sub Job updated failed.']);
} }
@ -131,9 +145,10 @@ class SubSubJobController extends Controller
/** /**
* Remove the specified resource from storage. * Remove the specified resource from storage.
*/ */
public function destroy(SubSubJob $subSubJob){ public function destroy(SubSubJob $subSubJob)
{
$subSubJob->delete(); $subSubJob->delete();
echo json_encode(['status' => 'success', 'message' => 'Sub Sub Job deleted successfully.']); echo json_encode(['status' => 'success', 'message' => 'Sub Sub Job deleted successfully.']);
//return redirect()->route('sub-job.index')->with('success', 'Sub Sub Job deleted successfully.'); //return redirect()->route('sub-job.index')->with('success', 'Sub Sub Job deleted successfully.');
} }
} }

77
composer.lock generated
View File

@ -1273,16 +1273,16 @@
}, },
{ {
"name": "laravel/framework", "name": "laravel/framework",
"version": "v10.7.1", "version": "v10.8.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/laravel/framework.git", "url": "https://github.com/laravel/framework.git",
"reference": "ddbbb2b50388721fe63312bb4469cae13163fd36" "reference": "317d7ccaeb1bbf4ac3035efe225ef2746c45f3a8"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/laravel/framework/zipball/ddbbb2b50388721fe63312bb4469cae13163fd36", "url": "https://api.github.com/repos/laravel/framework/zipball/317d7ccaeb1bbf4ac3035efe225ef2746c45f3a8",
"reference": "ddbbb2b50388721fe63312bb4469cae13163fd36", "reference": "317d7ccaeb1bbf4ac3035efe225ef2746c45f3a8",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -1469,7 +1469,7 @@
"issues": "https://github.com/laravel/framework/issues", "issues": "https://github.com/laravel/framework/issues",
"source": "https://github.com/laravel/framework" "source": "https://github.com/laravel/framework"
}, },
"time": "2023-04-11T14:11:49+00:00" "time": "2023-04-18T13:45:33+00:00"
}, },
{ {
"name": "laravel/sanctum", "name": "laravel/sanctum",
@ -1666,16 +1666,16 @@
}, },
{ {
"name": "laravelcollective/html", "name": "laravelcollective/html",
"version": "v6.4.0", "version": "v6.4.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/LaravelCollective/html.git", "url": "https://github.com/LaravelCollective/html.git",
"reference": "ac74f580459a5120079b8def0404e5d312a09504" "reference": "64ddfdcaeeb8d332bd98bef442bef81e39c3910b"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/LaravelCollective/html/zipball/ac74f580459a5120079b8def0404e5d312a09504", "url": "https://api.github.com/repos/LaravelCollective/html/zipball/64ddfdcaeeb8d332bd98bef442bef81e39c3910b",
"reference": "ac74f580459a5120079b8def0404e5d312a09504", "reference": "64ddfdcaeeb8d332bd98bef442bef81e39c3910b",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -1734,7 +1734,8 @@
"issues": "https://github.com/LaravelCollective/html/issues", "issues": "https://github.com/LaravelCollective/html/issues",
"source": "https://github.com/LaravelCollective/html" "source": "https://github.com/LaravelCollective/html"
}, },
"time": "2023-02-13T18:15:35+00:00" "abandoned": "spatie/laravel-html",
"time": "2023-04-25T02:46:11+00:00"
}, },
{ {
"name": "league/commonmark", "name": "league/commonmark",
@ -7347,16 +7348,16 @@
}, },
{ {
"name": "laravel/breeze", "name": "laravel/breeze",
"version": "v1.20.1", "version": "v1.20.2",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/laravel/breeze.git", "url": "https://github.com/laravel/breeze.git",
"reference": "bb2935f40d8396c6d0c77e4099a6e072c9095b33" "reference": "b010ff3f8cd8e9ae2a2023ca323fba9987157f60"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/laravel/breeze/zipball/bb2935f40d8396c6d0c77e4099a6e072c9095b33", "url": "https://api.github.com/repos/laravel/breeze/zipball/b010ff3f8cd8e9ae2a2023ca323fba9987157f60",
"reference": "bb2935f40d8396c6d0c77e4099a6e072c9095b33", "reference": "b010ff3f8cd8e9ae2a2023ca323fba9987157f60",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -7405,20 +7406,20 @@
"issues": "https://github.com/laravel/breeze/issues", "issues": "https://github.com/laravel/breeze/issues",
"source": "https://github.com/laravel/breeze" "source": "https://github.com/laravel/breeze"
}, },
"time": "2023-03-28T14:37:27+00:00" "time": "2023-04-16T20:27:51+00:00"
}, },
{ {
"name": "laravel/pint", "name": "laravel/pint",
"version": "v1.8.0", "version": "v1.9.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/laravel/pint.git", "url": "https://github.com/laravel/pint.git",
"reference": "4b8f2ef22bfcddd1d163cfd282e3f42ee1a5cce2" "reference": "eac5ec3d6b5c96543c682e309a10fdddc9f61d80"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/laravel/pint/zipball/4b8f2ef22bfcddd1d163cfd282e3f42ee1a5cce2", "url": "https://api.github.com/repos/laravel/pint/zipball/eac5ec3d6b5c96543c682e309a10fdddc9f61d80",
"reference": "4b8f2ef22bfcddd1d163cfd282e3f42ee1a5cce2", "reference": "eac5ec3d6b5c96543c682e309a10fdddc9f61d80",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -7471,7 +7472,7 @@
"issues": "https://github.com/laravel/pint/issues", "issues": "https://github.com/laravel/pint/issues",
"source": "https://github.com/laravel/pint" "source": "https://github.com/laravel/pint"
}, },
"time": "2023-04-04T13:08:09+00:00" "time": "2023-04-18T14:50:44+00:00"
}, },
{ {
"name": "laravel/sail", "name": "laravel/sail",
@ -7671,16 +7672,16 @@
}, },
{ {
"name": "nunomaduro/collision", "name": "nunomaduro/collision",
"version": "v7.5.0", "version": "v7.5.2",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/nunomaduro/collision.git", "url": "https://github.com/nunomaduro/collision.git",
"reference": "bbbc6fb9c1ee88f8aa38e47abd15c465f946f85e" "reference": "76b3cabda0aabda455fc3b9db6c3615f5a87c7ff"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/nunomaduro/collision/zipball/bbbc6fb9c1ee88f8aa38e47abd15c465f946f85e", "url": "https://api.github.com/repos/nunomaduro/collision/zipball/76b3cabda0aabda455fc3b9db6c3615f5a87c7ff",
"reference": "bbbc6fb9c1ee88f8aa38e47abd15c465f946f85e", "reference": "76b3cabda0aabda455fc3b9db6c3615f5a87c7ff",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -7690,19 +7691,19 @@
"symfony/console": "^6.2.8" "symfony/console": "^6.2.8"
}, },
"conflict": { "conflict": {
"phpunit/phpunit": "<10.1.0" "phpunit/phpunit": "<10.1.2"
}, },
"require-dev": { "require-dev": {
"brianium/paratest": "^7.1.3", "brianium/paratest": "^7.1.3",
"laravel/framework": "^10.7.1", "laravel/framework": "^10.8.0",
"laravel/pint": "^1.8.0", "laravel/pint": "^1.9.0",
"laravel/sail": "^1.21.4", "laravel/sail": "^1.21.4",
"laravel/sanctum": "^3.2.1", "laravel/sanctum": "^3.2.1",
"laravel/tinker": "^2.8.1", "laravel/tinker": "^2.8.1",
"nunomaduro/larastan": "^2.5.1", "nunomaduro/larastan": "^2.6.0",
"orchestra/testbench-core": "^8.4.2", "orchestra/testbench-core": "^8.5.0",
"pestphp/pest": "^2.5.0", "pestphp/pest": "^2.5.2",
"phpunit/phpunit": "^10.1.0", "phpunit/phpunit": "^10.1.1",
"sebastian/environment": "^6.0.1", "sebastian/environment": "^6.0.1",
"spatie/laravel-ignition": "^2.1.0" "spatie/laravel-ignition": "^2.1.0"
}, },
@ -7763,7 +7764,7 @@
"type": "patreon" "type": "patreon"
} }
], ],
"time": "2023-04-14T10:39:16+00:00" "time": "2023-04-22T22:12:40+00:00"
}, },
{ {
"name": "phar-io/manifest", "name": "phar-io/manifest",
@ -8197,16 +8198,16 @@
}, },
{ {
"name": "phpunit/phpunit", "name": "phpunit/phpunit",
"version": "10.1.1", "version": "10.1.2",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/sebastianbergmann/phpunit.git", "url": "https://github.com/sebastianbergmann/phpunit.git",
"reference": "0d9401b7e8245d71079e249e3cb868e9d2337887" "reference": "6f0cd95be71add539f8fd2be25b2a4a29789000b"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/0d9401b7e8245d71079e249e3cb868e9d2337887", "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/6f0cd95be71add539f8fd2be25b2a4a29789000b",
"reference": "0d9401b7e8245d71079e249e3cb868e9d2337887", "reference": "6f0cd95be71add539f8fd2be25b2a4a29789000b",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -8278,7 +8279,7 @@
"support": { "support": {
"issues": "https://github.com/sebastianbergmann/phpunit/issues", "issues": "https://github.com/sebastianbergmann/phpunit/issues",
"security": "https://github.com/sebastianbergmann/phpunit/security/policy", "security": "https://github.com/sebastianbergmann/phpunit/security/policy",
"source": "https://github.com/sebastianbergmann/phpunit/tree/10.1.1" "source": "https://github.com/sebastianbergmann/phpunit/tree/10.1.2"
}, },
"funding": [ "funding": [
{ {
@ -8294,7 +8295,7 @@
"type": "tidelift" "type": "tidelift"
} }
], ],
"time": "2023-04-17T12:17:05+00:00" "time": "2023-04-22T07:38:19+00:00"
}, },
{ {
"name": "sebastian/cli-parser", "name": "sebastian/cli-parser",

View File

@ -1,6 +1,7 @@
<?php <?php
use Illuminate\Http\Request; use App\Http\Controllers\DirectoratController;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route; use Illuminate\Support\Facades\Route;
/* /*
@ -17,3 +18,5 @@ use Illuminate\Support\Facades\Route;
Route::middleware('auth:sanctum')->get('/user', function (Request $request) { Route::middleware('auth:sanctum')->get('/user', function (Request $request) {
return $request->user(); return $request->user();
}); });
Route::get('directorat',[DirectoratController::class, 'index']);