noble/app/Http/Controllers/CountryController.php

48 lines
1.1 KiB
PHP
Raw Normal View History

2023-05-16 15:54:23 +03:00
<?php
namespace App\Http\Controllers;
use App\Models\Country;
use Illuminate\Http\Request;
class CountryController extends Controller
{
public function index()
{
$countries = Country::orderBy('id','desc')->get();
return view('country.index', compact('countries'));
}
public function create()
{
return view('country.create');
}
public function store(Request $request)
{
Country::create();
return redirect()->route('countries.index')->with('success','country has been created successfully.');
}
public function edit(Country $country)
{
return view('country.edit',compact('country'));
}
public function update(Request $request, Country $country)
{
$country->updated_at = time();
$country->save();
return redirect()->route('countries.index')->with('success','country Has Been updated successfully');
}
public function destroy(Country $country)
{
$country->delete();
return redirect()->route('countries.index')->with('success','country has been deleted successfully');
}
}