update doc block

This commit is contained in:
daeng.deni@dharma.or.id 2023-05-05 07:54:31 +07:00
parent 548b345111
commit eea0e3d304
7 changed files with 807 additions and 634 deletions

View File

@ -1,123 +1,157 @@
<?php
namespace App\Http\Controllers;
namespace App\Http\Controllers;
use App\DataTables\DirectoratDataTable;
use App\Http\Requests\StoreDirectoratRequest;
use App\Http\Requests\UpdateDirectoratRequest;
use App\Models\Directorat;
use Illuminate\Http\Request;
use Spatie\Activitylog\Facades\CauserResolver;
use App\DataTables\DirectoratDataTable;
use App\Http\Requests\StoreDirectoratRequest;
use App\Http\Requests\UpdateDirectoratRequest;
use App\Models\Directorat;
use Exception;
use Illuminate\Http\Request;
use Spatie\Activitylog\Facades\CauserResolver;
class DirectoratController extends Controller
{
public $user;
public function __construct()
class DirectoratController extends Controller
{
$this->middleware(function ($request, $next) {
//$this->user = Auth::guard('web')->user();
return $next($request);
});
public $user;
//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.
*/
public function index(DirectoratDataTable $dataTable)
{
/*if (is_null($this->user) || !$this->user->can('masters.read')) {
abort(403, 'Sorry !! You are Unauthorized to view any master data !');
}*/
/**
* Display a listing of the Directorats.
*
* @param \App\DataTables\DirectoratDataTable $dataTable
*
* @return mixed
*/
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.
*/
public function create(){}
/**
* Store a newly created Directorat in storage.
*
* @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 !');
}
/**
* Store a newly created resource in storage.
*/
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...
$validated = $request->validated();
// 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...
$validated = $request->validated();
echo json_encode(['status' => 'error', 'message' => 'Directorat created failed.']);
}
// Store the Directorat...
if($validated){
try{
Directorat::create($validated);
//return redirect()->route('directorat.index')->with('success', 'Directorat created successfully.');
echo json_encode(['status' => 'success', 'message' => 'Directorat created successfully.']);
}catch(\Exception $e){
//return redirect()->route('directorat.index')->with('error', 'Directorat created failed.');
echo json_encode(['status' => 'error', 'message' => 'Directorat created failed.']);
/**
* 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)
{
if (is_null($this->user) || !$this->user->can('masters.read')) {
abort(403, 'Sorry !! You are Unauthorized to view any master data !');
}
}
return false;
}
/**
* Display the specified resource.
*/
public function show(Directorat $directorat)
{
}
/**
* 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.']);
/**
* Show the form for editing the specified Directorat.
*
* @param $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);
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 !');
}
/**
* Remove the specified resource from storage.
*/
public function destroy(Directorat $directorat){
$directorat->delete();
echo json_encode(['status' => 'success', 'message' => 'Directorat deleted successfully.']);
// Validate the request...
$validated = $request->validated();
// Update the Directorat...
if ($validated) {
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
namespace App\Http\Controllers;
namespace App\Http\Controllers;
use App\DataTables\JobDataTable;
use App\Http\Requests\StoreJobRequest;
use App\Http\Requests\UpdateJobRequest;
use App\Models\Directorat;
use App\Models\Job;
use Illuminate\Http\Request;
use App\DataTables\JobDataTable;
use App\Http\Requests\StoreJobRequest;
use App\Http\Requests\UpdateJobRequest;
use App\Models\Directorat;
use App\Models\Job;
use Exception;
use Illuminate\Http\Request;
class JobController extends Controller
{
public $user;
public function __construct()
class JobController extends Controller
{
$this->middleware(function ($request, $next) {
//$this->user = Auth::guard('web')->user();
return $next($request);
});
}
public $user;
/**
* Display a listing of the resource.
*/
public function index(JobDataTable $dataTable, Request $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;
public function __construct()
{
$this->middleware(function ($request, $next) {
$this->user = Auth::guard('web')->user();
return $next($request);
});
}
$directorat = Directorat::all();
return $dataTable->render('pages.masters.job.index', compact('directorat'));
}
/**
* Show the form for creating a new resource.
*/
public function create(){}
/**
* 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.']);
/**
* 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)
{
if (is_null($this->user) || !$this->user->can('masters.read')) {
abort(403, 'Sorry !! You are Unauthorized to view any master data !');
}
}
return false;
}
// Add Vendor
addVendor('chained-select');
/**
* Display the specified resource.
*/
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.']);
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'));
}
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 !');
}
/**
* Remove the specified resource from storage.
*/
public function destroy(Job $job){
$job->delete();
echo json_encode(['status' => 'success', 'message' => 'Job deleted successfully.']);
//return redirect()->route('job.index')->with('success', 'Job deleted successfully.');
$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);
}
/**
* 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
namespace App\Http\Controllers;
namespace App\Http\Controllers;
use App\DataTables\SubDirectoratDataTable;
use App\Http\Requests\StoreSubDirectoratRequest;
use App\Http\Requests\UpdateSubDirectoratRequest;
use App\Models\Directorat;
use App\Models\SubDirectorat;
use Illuminate\Http\Request;
use App\DataTables\SubDirectoratDataTable;
use App\Http\Requests\StoreSubDirectoratRequest;
use App\Http\Requests\UpdateSubDirectoratRequest;
use App\Models\Directorat;
use App\Models\SubDirectorat;
use Exception;
use Illuminate\Http\Request;
class SubDirectoratController extends Controller
{
public $user;
public function __construct()
class SubDirectoratController extends Controller
{
$this->middleware(function ($request, $next) {
//$this->user = Auth::guard('web')->user();
return $next($request);
});
}
public $user;
/**
* Display a listing of the resource.
*/
public function index(SubDirectoratDataTable $dataTable, Request $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;
public function __construct()
{
$this->middleware(function ($request, $next) {
$this->user = Auth::guard('web')->user();
return $next($request);
});
}
$directorat = Directorat::all();
return $dataTable->render('pages.masters.sub-directorat.index', compact('directorat'));
}
/**
* Show the form for creating a new resource.
*/
public function create(){}
/**
* 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.']);
/**
* 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)
{
if (is_null($this->user) || !$this->user->can('masters.read')) {
abort(403, 'Sorry !! You are Unauthorized to view any master data !');
}
}
return false;
}
/**
* 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.']);
if (isset($request->directorat_id) && !empty($request->directorat_id)) {
$this->show($request);
return;
}
$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();
/**
* Remove the specified resource from storage.
*/
public function destroy(SubDirectorat $subDirectorat){
$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 = [];
foreach ($subdirectorats as $row) {
$result = [
$row->id => $row->name,
];
$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
namespace App\Http\Controllers;
namespace App\Http\Controllers;
use App\DataTables\SubJobDataTable;
use App\Http\Requests\StoreSubJobRequest;
use App\Http\Requests\UpdateSubJobRequest;
use App\Models\Directorat;
use App\Models\Job;
use App\Models\SubJob;
use Illuminate\Http\Request;
use App\DataTables\SubJobDataTable;
use App\Http\Requests\StoreSubJobRequest;
use App\Http\Requests\UpdateSubJobRequest;
use App\Models\Directorat;
use App\Models\SubJob;
use Exception;
use Illuminate\Http\Request;
class SubJobController extends Controller
{
public $user;
public function __construct()
class SubJobController extends Controller
{
$this->middleware(function ($request, $next) {
//$this->user = Auth::guard('web')->user();
return $next($request);
});
}
public $user;
/**
* Display a listing of the resource.
*/
public function index(SubJobDataTable $dataTable, Request $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;
public function __construct()
{
$this->middleware(function ($request, $next) {
$this->user = Auth::guard('web')->user();
return $next($request);
});
}
$directorat = Directorat::all();
return $dataTable->render('pages.masters.sub-job.index', compact('directorat'));
}
/**
* Show the form for creating a new resource.
*/
public function create(){}
/**
* 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.']);
/**
* 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)
{
if (is_null($this->user) || !$this->user->can('masters.read')) {
abort(403, 'Sorry !! You are Unauthorized to view any master data !');
}
}
return false;
}
addVendor('chained-select');
/**
* Display the specified resource.
*/
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.']);
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'));
}
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();
/**
* Remove the specified resource from storage.
*/
public function destroy(SubJob $subJob){
$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 = [];
foreach ($subJob as $row) {
$result = [
$row->id => $row->name,
];
$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
namespace App\Http\Controllers;
namespace App\Http\Controllers;
use App\DataTables\SubSubJobDataTable;
use App\Http\Requests\StoreSubSubJobRequest;
use App\Http\Requests\UpdateSubSubJobRequest;
use App\Models\Directorat;
use App\Models\Job;
use App\Models\SubSubJob;
use Illuminate\Http\Request;
use App\DataTables\SubSubJobDataTable;
use App\Http\Requests\StoreSubSubJobRequest;
use App\Http\Requests\UpdateSubSubJobRequest;
use App\Models\Directorat;
use App\Models\SubSubJob;
use Exception;
use Illuminate\Http\Request;
class SubSubJobController extends Controller
{
public $user;
public function __construct()
class SubSubJobController extends Controller
{
$this->middleware(function ($request, $next) {
//$this->user = Auth::guard('web')->user();
return $next($request);
});
}
public $user;
/**
* Display a listing of the resource.
*/
public function index(SubSubJobDataTable $dataTable, Request $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;
public function __construct()
{
$this->middleware(function ($request, $next) {
$this->user = Auth::guard('web')->user();
return $next($request);
});
}
addVendor('chained-select');
$directorat = Directorat::all();
return $dataTable->render('pages.masters.sub-sub-job.index', compact('directorat'));
}
/**
* Show the form for creating a new resource.
*/
public function create(){}
/**
* 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.']);
/**
* 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)
{
if (is_null($this->user) || !$this->user->can('masters.read')) {
abort(403, 'Sorry !! You are Unauthorized to view any master data !');
}
}
return false;
}
/**
* 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.']);
if (isset($request->sub_job_id) && !empty($request->sub_job_id)) {
$this->show($request);
return;
}
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();
/**
* 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.');
$data = [];
foreach ($subSubJob as $row) {
$result = [
$row->id => $row->name,
];
$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",
"version": "v10.7.1",
"version": "v10.8.0",
"source": {
"type": "git",
"url": "https://github.com/laravel/framework.git",
"reference": "ddbbb2b50388721fe63312bb4469cae13163fd36"
"reference": "317d7ccaeb1bbf4ac3035efe225ef2746c45f3a8"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/laravel/framework/zipball/ddbbb2b50388721fe63312bb4469cae13163fd36",
"reference": "ddbbb2b50388721fe63312bb4469cae13163fd36",
"url": "https://api.github.com/repos/laravel/framework/zipball/317d7ccaeb1bbf4ac3035efe225ef2746c45f3a8",
"reference": "317d7ccaeb1bbf4ac3035efe225ef2746c45f3a8",
"shasum": ""
},
"require": {
@ -1469,7 +1469,7 @@
"issues": "https://github.com/laravel/framework/issues",
"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",
@ -1666,16 +1666,16 @@
},
{
"name": "laravelcollective/html",
"version": "v6.4.0",
"version": "v6.4.1",
"source": {
"type": "git",
"url": "https://github.com/LaravelCollective/html.git",
"reference": "ac74f580459a5120079b8def0404e5d312a09504"
"reference": "64ddfdcaeeb8d332bd98bef442bef81e39c3910b"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/LaravelCollective/html/zipball/ac74f580459a5120079b8def0404e5d312a09504",
"reference": "ac74f580459a5120079b8def0404e5d312a09504",
"url": "https://api.github.com/repos/LaravelCollective/html/zipball/64ddfdcaeeb8d332bd98bef442bef81e39c3910b",
"reference": "64ddfdcaeeb8d332bd98bef442bef81e39c3910b",
"shasum": ""
},
"require": {
@ -1734,7 +1734,8 @@
"issues": "https://github.com/LaravelCollective/html/issues",
"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",
@ -7347,16 +7348,16 @@
},
{
"name": "laravel/breeze",
"version": "v1.20.1",
"version": "v1.20.2",
"source": {
"type": "git",
"url": "https://github.com/laravel/breeze.git",
"reference": "bb2935f40d8396c6d0c77e4099a6e072c9095b33"
"reference": "b010ff3f8cd8e9ae2a2023ca323fba9987157f60"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/laravel/breeze/zipball/bb2935f40d8396c6d0c77e4099a6e072c9095b33",
"reference": "bb2935f40d8396c6d0c77e4099a6e072c9095b33",
"url": "https://api.github.com/repos/laravel/breeze/zipball/b010ff3f8cd8e9ae2a2023ca323fba9987157f60",
"reference": "b010ff3f8cd8e9ae2a2023ca323fba9987157f60",
"shasum": ""
},
"require": {
@ -7405,20 +7406,20 @@
"issues": "https://github.com/laravel/breeze/issues",
"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",
"version": "v1.8.0",
"version": "v1.9.0",
"source": {
"type": "git",
"url": "https://github.com/laravel/pint.git",
"reference": "4b8f2ef22bfcddd1d163cfd282e3f42ee1a5cce2"
"reference": "eac5ec3d6b5c96543c682e309a10fdddc9f61d80"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/laravel/pint/zipball/4b8f2ef22bfcddd1d163cfd282e3f42ee1a5cce2",
"reference": "4b8f2ef22bfcddd1d163cfd282e3f42ee1a5cce2",
"url": "https://api.github.com/repos/laravel/pint/zipball/eac5ec3d6b5c96543c682e309a10fdddc9f61d80",
"reference": "eac5ec3d6b5c96543c682e309a10fdddc9f61d80",
"shasum": ""
},
"require": {
@ -7471,7 +7472,7 @@
"issues": "https://github.com/laravel/pint/issues",
"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",
@ -7671,16 +7672,16 @@
},
{
"name": "nunomaduro/collision",
"version": "v7.5.0",
"version": "v7.5.2",
"source": {
"type": "git",
"url": "https://github.com/nunomaduro/collision.git",
"reference": "bbbc6fb9c1ee88f8aa38e47abd15c465f946f85e"
"reference": "76b3cabda0aabda455fc3b9db6c3615f5a87c7ff"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/nunomaduro/collision/zipball/bbbc6fb9c1ee88f8aa38e47abd15c465f946f85e",
"reference": "bbbc6fb9c1ee88f8aa38e47abd15c465f946f85e",
"url": "https://api.github.com/repos/nunomaduro/collision/zipball/76b3cabda0aabda455fc3b9db6c3615f5a87c7ff",
"reference": "76b3cabda0aabda455fc3b9db6c3615f5a87c7ff",
"shasum": ""
},
"require": {
@ -7690,19 +7691,19 @@
"symfony/console": "^6.2.8"
},
"conflict": {
"phpunit/phpunit": "<10.1.0"
"phpunit/phpunit": "<10.1.2"
},
"require-dev": {
"brianium/paratest": "^7.1.3",
"laravel/framework": "^10.7.1",
"laravel/pint": "^1.8.0",
"laravel/framework": "^10.8.0",
"laravel/pint": "^1.9.0",
"laravel/sail": "^1.21.4",
"laravel/sanctum": "^3.2.1",
"laravel/tinker": "^2.8.1",
"nunomaduro/larastan": "^2.5.1",
"orchestra/testbench-core": "^8.4.2",
"pestphp/pest": "^2.5.0",
"phpunit/phpunit": "^10.1.0",
"nunomaduro/larastan": "^2.6.0",
"orchestra/testbench-core": "^8.5.0",
"pestphp/pest": "^2.5.2",
"phpunit/phpunit": "^10.1.1",
"sebastian/environment": "^6.0.1",
"spatie/laravel-ignition": "^2.1.0"
},
@ -7763,7 +7764,7 @@
"type": "patreon"
}
],
"time": "2023-04-14T10:39:16+00:00"
"time": "2023-04-22T22:12:40+00:00"
},
{
"name": "phar-io/manifest",
@ -8197,16 +8198,16 @@
},
{
"name": "phpunit/phpunit",
"version": "10.1.1",
"version": "10.1.2",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/phpunit.git",
"reference": "0d9401b7e8245d71079e249e3cb868e9d2337887"
"reference": "6f0cd95be71add539f8fd2be25b2a4a29789000b"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/0d9401b7e8245d71079e249e3cb868e9d2337887",
"reference": "0d9401b7e8245d71079e249e3cb868e9d2337887",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/6f0cd95be71add539f8fd2be25b2a4a29789000b",
"reference": "6f0cd95be71add539f8fd2be25b2a4a29789000b",
"shasum": ""
},
"require": {
@ -8278,7 +8279,7 @@
"support": {
"issues": "https://github.com/sebastianbergmann/phpunit/issues",
"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": [
{
@ -8294,7 +8295,7 @@
"type": "tidelift"
}
],
"time": "2023-04-17T12:17:05+00:00"
"time": "2023-04-22T07:38:19+00:00"
},
{
"name": "sebastian/cli-parser",

View File

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