first commit
This commit is contained in:
59
app/Http/Controllers/Admin/RegionController.php
Executable file
59
app/Http/Controllers/Admin/RegionController.php
Executable file
@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Country;
|
||||
use App\Models\Region;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class RegionController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
$regions = Region::orderBy('id','desc')->get();
|
||||
|
||||
return view('admin.region.index', compact('regions'));
|
||||
}
|
||||
|
||||
public function create()
|
||||
{
|
||||
$countries = Country::all();
|
||||
|
||||
return view('admin.region.create', compact('countries'));
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
'country_id' => 'required',
|
||||
]);
|
||||
Region::create($request->post());
|
||||
|
||||
return redirect()->route('admin.regions.index')->with('success','region has been created successfully.');
|
||||
}
|
||||
|
||||
public function edit(Region $region)
|
||||
{
|
||||
$countries = Country::all();
|
||||
|
||||
return view('admin.region.edit',compact('region', 'countries'));
|
||||
}
|
||||
|
||||
public function update(Request $request, Region $region)
|
||||
{
|
||||
$request->validate([
|
||||
'country_id' => 'required',
|
||||
]);
|
||||
|
||||
$region->fill($request->post())->save();
|
||||
|
||||
return redirect()->route('admin.regions.index')->with('success','regions Has Been updated successfully');
|
||||
}
|
||||
|
||||
public function destroy(Region $region)
|
||||
{
|
||||
$region->delete();
|
||||
return redirect()->route('admin.regions.index')->with('success','regions has been deleted successfully');
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user