49 lines
1.2 KiB
PHP
Executable File
49 lines
1.2 KiB
PHP
Executable File
<?php
|
|
|
|
namespace App\Http\Controllers\Admin;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Models\Country;
|
|
use Illuminate\Http\Request;
|
|
|
|
class CountryController extends Controller
|
|
{
|
|
public function index()
|
|
{
|
|
$countries = Country::orderBy('id','desc')->get();
|
|
|
|
return view('admin.country.index', compact('countries'));
|
|
}
|
|
|
|
public function create()
|
|
{
|
|
return view('admin.country.create');
|
|
}
|
|
|
|
public function store(Request $request)
|
|
{
|
|
Country::create();
|
|
|
|
return redirect()->route('admin.countries.index')->with('success','country has been created successfully.');
|
|
}
|
|
|
|
public function edit(Country $country)
|
|
{
|
|
return view('admin.country.edit',compact('country'));
|
|
}
|
|
|
|
public function update(Request $request, Country $country)
|
|
{
|
|
$country->updated_at = time();
|
|
$country->save();
|
|
|
|
return redirect()->route('admin.countries.index')->with('success','country Has Been updated successfully');
|
|
}
|
|
|
|
public function destroy(Country $country)
|
|
{
|
|
$country->delete();
|
|
return redirect()->route('admin.countries.index')->with('success','country has been deleted successfully');
|
|
}
|
|
}
|