changes
This commit is contained in:
@ -0,0 +1,84 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Stock\Http\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Modules\Stock\Models\StockLocation;
|
||||
use Modules\Stock\Repositories\StockLocationRepository;
|
||||
|
||||
class StockLocationController extends Controller
|
||||
{
|
||||
private $stockLocationRepository;
|
||||
|
||||
public function __construct(StockLocationRepository $stockLocationRepository)
|
||||
{
|
||||
$this->stockLocationRepository = $stockLocationRepository;
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
$data['title'] = 'Stocks List';
|
||||
$data['stockLocations'] = $this->stockLocationRepository->findAll();
|
||||
return view('stock::stockLocation.index', $data);
|
||||
}
|
||||
|
||||
public function create()
|
||||
{
|
||||
$data['title'] = 'Create StockLocation';
|
||||
$data['status'] = StockLocation::STATUS;
|
||||
|
||||
return view('stock::stockLocation.create', $data);
|
||||
}
|
||||
|
||||
public function store(Request $request): RedirectResponse
|
||||
{
|
||||
$request->request->add(['slug' => slugify($request->title)]);
|
||||
$inputData = $request->all();
|
||||
$this->stockLocationRepository->create($inputData);
|
||||
toastr()->success('StockLocation Created Successfully');
|
||||
|
||||
return redirect()->route('stockLocation.index');
|
||||
}
|
||||
|
||||
public function show($id)
|
||||
{
|
||||
$data['title'] = 'Show StockLocation';
|
||||
$data['status'] = StockLocation::STATUS;
|
||||
$data['stockLocation'] = $this->stockLocationRepository->getStockLocationById($id);
|
||||
|
||||
return view('stock::stockLocation.show', $data);
|
||||
}
|
||||
|
||||
public function edit($id)
|
||||
{
|
||||
$data['title'] = 'Edit StockLocation';
|
||||
$data['status'] = StockLocation::STATUS;
|
||||
$data['stockLocation'] = $this->stockLocationRepository->getStockLocationById($id);
|
||||
|
||||
return view('stock::stockLocation.edit', $data);
|
||||
}
|
||||
|
||||
public function update(Request $request, $id): RedirectResponse
|
||||
{
|
||||
$inputData = $request->except(['_method', '_token']);
|
||||
$this->stockLocationRepository->update($id, $inputData);
|
||||
|
||||
return redirect()->route('stockLocation.index');
|
||||
}
|
||||
|
||||
public function destroy($id)
|
||||
{
|
||||
try {
|
||||
$stock = $this->stockLocationRepository->getStockLocationById($id);
|
||||
$stock->delete();
|
||||
|
||||
toastr()->success('Stock Location Deleted Successfully');
|
||||
} catch (\Throwable $th) {
|
||||
toastr()->error($th->getMessage());
|
||||
}
|
||||
|
||||
return response()->json(['status' => true, 'message' => 'Stock Location Deleted Successfully']);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user