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

View File

@ -1,139 +1,182 @@
<?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 function __construct()
{ {
$this->middleware(function ($request, $next) { public $user;
//$this->user = Auth::guard('web')->user();
return $next($request);
});
}
/** public function __construct()
* Display a listing of the resource. {
*/ $this->middleware(function ($request, $next) {
public function index(JobDataTable $dataTable, Request $request) $this->user = Auth::guard('web')->user();
{ return $next($request);
/*if (is_null($this->user) || !$this->user->can('masters.read')) { });
abort(403, 'Sorry !! You are Unauthorized to view any master data !');
}*/
// Add Vendor
addVendor('chained-select');
if(isset($request->sub_directorat_id) && !empty($request->sub_directorat_id)) {
$this->show($request);
return;
} }
$directorat = Directorat::all(); /**
return $dataTable->render('pages.masters.job.index', compact('directorat')); * Display a listing of the Jobs.
} *
* @param \App\DataTables\JobDataTable $dataTable
/** * @param \Illuminate\Http\Request $request
* Show the form for creating a new resource. *
*/ * @return mixed|void
public function create(){} */
public function index(JobDataTable $dataTable, Request $request)
/** {
* Store a newly created resource in storage. if (is_null($this->user) || !$this->user->can('masters.read')) {
*/ abort(403, 'Sorry !! You are Unauthorized to view any master data !');
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; // Add Vendor
} addVendor('chained-select');
/** if (isset($request->sub_directorat_id) && !empty($request->sub_directorat_id)) {
* Display the specified resource. $this->show($request);
*/ return;
public function show(Request $request)
{
$jobs = Job::where('sub_directorat_id', $request->sub_directorat_id)->get();
$data = [];
foreach ($jobs as $row) {
$result = [
$row->id => $row->name,
];
$data[] = $result;
}
echo json_encode($data);
}
/**
* Show the form for editing the specified resource.
*/
public function edit($id){
$job = Job::find($id);
echo json_encode($job);
}
/**
* Update the specified resource in storage.
*/
public function update(UpdateJobRequest $request, Job $job)
{
/*if (is_null($this->user) || !$this->user->can('masters.update')) {
abort(403, 'Sorry !! You are Unauthorized to update any master data !');
}*/
// Validate the request...
$validated = $request->validated();
// Update the Job...
if($validated){
try{
$job->update($validated);
//return redirect()->route('job.index')->with('success', 'Job updated successfully.');
echo json_encode(['status' => 'success', 'message' => 'Job updated successfully.']);
}catch(\Exception $e){
//return redirect()->route('job.index')->with('error', 'Job updated failed.');
echo json_encode(['status' => 'error', 'message' => 'Job updated failed.']);
} }
$directorat = Directorat::all();
return $dataTable->render('pages.masters.job.index', compact('directorat'));
} }
return false; /**
} * Lists the specified Job by Sub Directorat ID.
*
* @param \Illuminate\Http\Request $request
*
* @return void
*/
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();
* Remove the specified resource from storage.
*/ $data = [];
public function destroy(Job $job){ foreach ($jobs as $row) {
$job->delete(); $result = [
echo json_encode(['status' => 'success', 'message' => 'Job deleted successfully.']); $row->id => $row->name,
//return redirect()->route('job.index')->with('success', 'Job deleted successfully.'); ];
$data[] = $result;
}
echo json_encode($data);
}
/**
* Store a newly created Job in storage.
*
* @param \App\Http\Requests\StoreJobRequest $request
*
* @return void
*/
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);
echo json_encode($job);
}
/**
* 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)
{
if (is_null($this->user) || !$this->user->can('masters.update')) {
abort(403, 'Sorry !! You are Unauthorized to update any master data !');
}
// Validate the request...
$validated = $request->validated();
// Update the Job...
if ($validated) {
try {
$job->update($validated);
echo json_encode(['status' => 'success', 'message' => 'Job updated successfully.']);
} catch (Exception $e) {
echo json_encode(['status' => 'error', 'message' => 'Job updated failed.']);
}
}
echo json_encode(['status' => 'error', 'message' => 'Job updated failed.']);
}
/**
* Remove the specified Job from storage.
*
* @param \App\Models\Job $job
*
* @return void
*/
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();
echo json_encode(['status' => 'success', 'message' => 'Job deleted successfully.']);
}
} }
}

View File

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

View File

@ -1,139 +1,179 @@
<?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 function __construct()
{ {
$this->middleware(function ($request, $next) { public $user;
//$this->user = Auth::guard('web')->user();
return $next($request);
});
}
/** public function __construct()
* Display a listing of the resource. {
*/ $this->middleware(function ($request, $next) {
public function index(SubJobDataTable $dataTable, Request $request) $this->user = Auth::guard('web')->user();
{ return $next($request);
/*if (is_null($this->user) || !$this->user->can('masters.read')) { });
abort(403, 'Sorry !! You are Unauthorized to view any master data !');
}*/
addVendor('chained-select');
if(isset($request->job_id) && !empty($request->job_id)) {
$this->show($request);
return;
} }
$directorat = Directorat::all(); /**
return $dataTable->render('pages.masters.sub-job.index', compact('directorat')); * Display a listing of the Sub Jobs.
} *
* @param \App\DataTables\SubJobDataTable $dataTable
/** * @param \Illuminate\Http\Request $request
* Show the form for creating a new resource. *
*/ * @return mixed|void
public function create(){} */
public function index(SubJobDataTable $dataTable, Request $request)
/** {
* Store a newly created resource in storage. if (is_null($this->user) || !$this->user->can('masters.read')) {
*/ abort(403, 'Sorry !! You are Unauthorized to view any master data !');
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; addVendor('chained-select');
}
/** if (isset($request->job_id) && !empty($request->job_id)) {
* Display the specified resource. $this->show($request);
*/ return;
public function show(Request $request)
{
$subJob = SubJob::where('job_id', $request->job_id)->get();
$data = [];
foreach ($subJob as $row) {
$result = [
$row->id => $row->name,
];
$data[] = $result;
}
echo json_encode($data);
}
/**
* Show the form for editing the specified resource.
*/
public function edit($id){
$subJob = SubJob::find($id);
echo json_encode($subJob);
}
/**
* Update the specified resource in storage.
*/
public function update(UpdateSubJobRequest $request, SubJob $subJob)
{
/*if (is_null($this->user) || !$this->user->can('masters.update')) {
abort(403, 'Sorry !! You are Unauthorized to update any master data !');
}*/
// Validate the request...
$validated = $request->validated();
// Update the SubJob...
if($validated){
try{
$subJob->update($validated);
//return redirect()->route('job.index')->with('success', 'SubJob updated successfully.');
echo json_encode(['status' => 'success', 'message' => 'Sub Job updated successfully.']);
}catch(\Exception $e){
//return redirect()->route('job.index')->with('error', 'SubJob updated failed.');
echo json_encode(['status' => 'error', 'message' => 'Sub Job updated failed.']);
} }
$directorat = Directorat::all();
return $dataTable->render('pages.masters.sub-job.index', compact('directorat'));
} }
return false; /**
} * Lists the specified Sub Job by Job ID.
*
* @param \Illuminate\Http\Request $request
*
* @return void
*/
public function show(Request $request)
{
$subJob = SubJob::where('job_id', $request->job_id)->get();
/** $data = [];
* Remove the specified resource from storage. foreach ($subJob as $row) {
*/ $result = [
public function destroy(SubJob $subJob){ $row->id => $row->name,
$subJob->delete(); ];
echo json_encode(['status' => 'success', 'message' => 'Sub Job deleted successfully.']);
//return redirect()->route('sub-job.index')->with('success', 'Sub Job deleted successfully.'); $data[] = $result;
}
echo json_encode($data);
}
/**
* Store a newly created Sub Job in storage.
*
* @param \App\Http\Requests\StoreSubJobRequest $request
*
* @return void
*/
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);
echo json_encode($subJob);
}
/**
* 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)
{
if (is_null($this->user) || !$this->user->can('masters.update')) {
abort(403, 'Sorry !! You are Unauthorized to update any master data !');
}
// Validate the request...
$validated = $request->validated();
// Update the SubJob...
if ($validated) {
try {
$subJob->update($validated);
echo json_encode(['status' => 'success', 'message' => 'Sub Job updated successfully.']);
} catch (Exception $e) {
echo json_encode(['status' => 'error', 'message' => 'Sub Job updated failed.']);
}
}
echo json_encode(['status' => 'error', 'message' => 'Sub Job updated failed.']);
}
/**
* Remove the specified Sub Job from storage.
*
* @param \App\Models\SubJob $subJob
*
* @return void
*/
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();
echo json_encode(['status' => 'success', 'message' => 'Sub Job deleted successfully.']);
}
} }
}

View File

@ -1,139 +1,154 @@
<?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 function __construct()
{ {
$this->middleware(function ($request, $next) { public $user;
//$this->user = Auth::guard('web')->user();
return $next($request);
});
}
/** public function __construct()
* Display a listing of the resource. {
*/ $this->middleware(function ($request, $next) {
public function index(SubSubJobDataTable $dataTable, Request $request) $this->user = Auth::guard('web')->user();
{ return $next($request);
/*if (is_null($this->user) || !$this->user->can('masters.read')) { });
abort(403, 'Sorry !! You are Unauthorized to view any master data !');
}*/
if(isset($request->sub_job_id) && !empty($request->sub_job_id)) {
$this->show($request);
return;
} }
addVendor('chained-select'); /**
* Display a listing of the Sub Sub Jobs.
$directorat = Directorat::all(); *
return $dataTable->render('pages.masters.sub-sub-job.index', compact('directorat')); * @param \App\DataTables\SubSubJobDataTable $dataTable
} * @param \Illuminate\Http\Request $request
*
/** * @return mixed|void
* Show the form for creating a new resource. */
*/ public function index(SubSubJobDataTable $dataTable, Request $request)
public function create(){} {
if (is_null($this->user) || !$this->user->can('masters.read')) {
/** abort(403, 'Sorry !! You are Unauthorized to view any master data !');
* 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; if (isset($request->sub_job_id) && !empty($request->sub_job_id)) {
} $this->show($request);
return;
/**
* Display the specified resource.
*/
public function show(Request $request)
{
$subSubJob = SubSubJob::where('sub_job_id', $request->sub_job_id)->get();
$data = [];
foreach ($subSubJob as $row) {
$result = [
$row->id => $row->name,
];
$data[] = $result;
}
echo json_encode($data);
}
/**
* Show the form for editing the specified resource.
*/
public function edit($id){
$subJob = SubSubJob::find($id);
echo json_encode($subJob);
}
/**
* Update the specified resource in storage.
*/
public function update(UpdateSubSubJobRequest $request, SubSubJob $subSubJob)
{
/*if (is_null($this->user) || !$this->user->can('masters.update')) {
abort(403, 'Sorry !! You are Unauthorized to update any master data !');
}*/
// Validate the request...
$validated = $request->validated();
// Update the SubSubJob...
if($validated){
try{
$subSubJob->update($validated);
//return redirect()->route('job.index')->with('success', 'SubSubJob updated successfully.');
echo json_encode(['status' => 'success', 'message' => 'Sub Sub Job updated successfully.']);
}catch(\Exception $e){
//return redirect()->route('job.index')->with('error', 'SubSubJob updated failed.');
echo json_encode(['status' => 'error', 'message' => 'Sub Sub Job updated failed.']);
} }
addVendor('chained-select');
$directorat = Directorat::all();
return $dataTable->render('pages.masters.sub-sub-job.index', compact('directorat'));
} }
return false; /**
} * Lists the specified Sub Sub Job by Sub Job ID.
*
* @param \Illuminate\Http\Request $request
*
* @return void
*/
public function show(Request $request)
{
$subSubJob = SubSubJob::where('sub_job_id', $request->sub_job_id)->get();
/** $data = [];
* Remove the specified resource from storage. foreach ($subSubJob as $row) {
*/ $result = [
public function destroy(SubSubJob $subSubJob){ $row->id => $row->name,
$subSubJob->delete(); ];
echo json_encode(['status' => 'success', 'message' => 'Sub Sub Job deleted successfully.']);
//return redirect()->route('sub-job.index')->with('success', 'Sub Sub Job deleted successfully.'); $data[] = $result;
}
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.
*/
public function edit($id)
{
$subJob = SubSubJob::find($id);
echo json_encode($subJob);
}
/**
* Update the specified resource in storage.
*/
public function update(UpdateSubSubJobRequest $request, SubSubJob $subSubJob)
{
/*if (is_null($this->user) || !$this->user->can('masters.update')) {
abort(403, 'Sorry !! You are Unauthorized to update any master data !');
}*/
// Validate the request...
$validated = $request->validated();
// Update the SubSubJob...
if ($validated) {
try {
$subSubJob->update($validated);
//return redirect()->route('job.index')->with('success', 'SubSubJob updated successfully.');
echo json_encode(['status' => 'success', 'message' => 'Sub Sub Job updated successfully.']);
} catch (Exception $e) {
//return redirect()->route('job.index')->with('error', 'SubSubJob updated failed.');
echo json_encode(['status' => 'error', 'message' => 'Sub Sub Job updated failed.']);
}
}
return false;
}
/**
* Remove the specified resource from storage.
*/
public function destroy(SubSubJob $subSubJob)
{
$subSubJob->delete();
echo json_encode(['status' => 'success', 'message' => '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']);