IMMREX7
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class CompanyController extends Controller {
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index() {
$companies = \App\Company::get();
return view('master.companies', compact('companies'));
}
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public function create() {
//
}
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request) {
$company = new \App\Company();
$company->fill($request->all());
$company->save();
flash('Data Saved Successfully !!')->success();
return redirect('companies');
}
/**
* Display the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function show($id) {
//
}
/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function edit($id) {
$companies = \App\Company::get();
$company = \App\Company::findOrFail($id);
return view('master.companies', compact('companies', 'company'));
}
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @return \Illuminate\Http\Response
*/
public function update(Request $request, $id) {
$company = \App\Company::findOrFail($id);
$company->fill($request->all());
$company->update();
flash('Data Saved Successfully !!')->success();
return redirect('companies');
}
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function destroy($id) {
//
}
public function getBranches($id) {
$branches = \App\Branch::where('idCompany', '=', $id)->get()->pluck('branchName', 'idBranch');
return json_encode($branches);
}
public function deleteMahReport() {
$maha = \App\MaharastraReport::get();
foreach ($maha as $var) {
$mh = \App\MaharastraReport::where('idMParivahan', '=', $var->idMParivahan)->first();
$mh->delete();
}
return response()->json(['success' => "SUCCESS"], 200, ['app-status' => 'success']);
}
public function deleteParivahanReport() {
$parivahan = \App\ParivahanReport::get();
foreach ($parivahan as $var) {
$pv = \App\ParivahanReport::where('idParivahan', '=', $var->idParivahan)->first();
$pv->delete();
}
return response()->json(['success' => "SUCCESS"], 200, ['app-status' => 'success']);
}
}
Copyright © 2021 -