StocksNew/Modules/Admin/app/Http/Controllers/NationalityController.php.bak

84 lines
2.1 KiB
PHP
Raw Normal View History

2024-08-27 12:03:06 +00:00
<?php
namespace Modules\Admin\Http\Controllers;
use App\Http\Controllers\Controller;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Modules\Admin\Repositories\NationalityRepository;
class NationalityController extends Controller
{
private $nationalityRepository;
public function __construct(NationalityRepository $nationalityRepository)
{
$this->nationalityRepository = $nationalityRepository;
}
/**
* Display a listing of the resource.
*/
public function index()
{
$data['title'] = 'Nationality List';
$data['nationalityLists'] = $this->nationalityRepository->findAll();
return view('admin::nationalities.index', $data);
}
/**
* Show the form for creating a new resource.
*/
public function create()
{
$data['title'] = 'Create Nationality';
$data['editable'] = false;
return view('admin::nationalities.create', $data);
}
/**
* Store a newly created resource in storage.
*/
public function store(Request $request): RedirectResponse
{
$this->nationalityRepository->create($request->all());
return redirect()->route('nationality.index');
}
/**
* Show the specified resource.
*/
public function show($id)
{
return view('admin::nationalities.show');
}
/**
* Show the form for editing the specified resource.
*/
public function edit($id)
{
$data['title'] = 'Edit Nationality';
$data['editable'] = true;
$data['nationality'] = $this->nationalityRepository->getNationalityById($id);
return view('admin::nationalities.edit', $data);
}
/**
* Update the specified resource in storage.
*/
public function update(Request $request, $id): RedirectResponse
{
$this->nationalityRepository->update($id, $request->all());
return redirect()->route('nationality.index');
}
/**
* Remove the specified resource from storage.
*/
public function destroy($id)
{
//
}
}