Project Laravel 11
<?php
namespace App\Http\Controllers;
use App\Models\Country;
use App\Models\States;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
class CountryController extends Controller
{
public function index()
{
// $country = DB::table("country")->get();
$country = Country::all();
// dd($country);
return view("country", ["data" => $country]);
}
public function showCountry()
{
$country = Country::all();
return view("countryHome", ["data" => $country]);
}
public function validateCountry(Request $request)
{
if ($request->validate([
"countryName" => "required",
"countryCode" => "required|unique:country,country_code",
"countryDial" => "required|numeric|unique:country,country_dial"
])) {
$country = Country::insert([
"country_name" => $request->countryName,
"country_code" => $request->countryCode,
"country_dial" => $request->countryDial,
"created_at" => now(), //now() is a helper function in laravel
"updated_at" => now()
]);
if ($country) {
$country = DB::table("country")->get();
return view("countryHome", ["data" => $country]);
}
return redirect()->route("showCountry.country");
} else {
return redirect()->route("country");
}
}
}
Above File is app\Http\Controllers\CountryController.php FileBelow File is app\Http\Controllers\NotificationController.php File
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class NotificationController extends Controller
{
public function indexNotification()
{
return view("demo");
}
public function notification($type)
{
switch ($type) {
case "success":
return back()->with("success", "User created successfully.");
break;
case "info":
return back()->with("info", "User updated successfully.");
break;
case "warning":
return back()->with("warning", "User can not access page.");
break;
case "error":
return back()->with("error", "This is testing error.");
break;
default:
break;
}
}
public function index_notification()
{
return view("notifications.list");
}
public function notification_list($type)
{
switch ($type) {
case "success":
return back()->with("success", "User created successfully.");
break;
case "info":
return back()->with("info", "User updated successfully.");
break;
case "warning":
return back()->with("warning", "User can not access page.");
break;
case "error":
return back()->with("error", "This is testing error.");
break;
default:
break;
}
}
}
Below File is app\Http\Controllers\StatesController.php File
<?php
namespace App\Http\Controllers;
use App\Models\States;
use Illuminate\Contracts\Database\Eloquent\Builder;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Validator;
use Illuminate\Validation\Rule;
class StatesController extends Controller
{
public function index(Request $request)
{
$country = DB::table("country")->get();
return view("states", ["data" => $country]);
}
public function showStates()
{
// $states = DB::table("states")->get();
$states = States::where('status', 1)->get();
return view("statesHome", ["data" => $states]);
}
public function validateStates(Request $request)
{
if ($request->validate([
"country" => "required",
"state" => [
'required',
'string',
'max:255',
// Ensure the combination of state name and country_id is unique
Rule::unique('states', 'state_name')->where(function ($query) use ($request) {
return $query->where('country_ID', $request->country);
}),
],
"status" => "required"
], [
'state.unique' => 'The state name already exists for the selected country.',
])) {
$states = States::insert([
"country_ID" => $request->country,
"state_name" => $request->state,
"status" => $request->status,
"created_at" => now(),
"updated_at" => now()
]);
if ($states) {
$states = DB::table("states")->get();
return view("statesHome", ["data" => $states]);
}
return redirect()->route("showStates.states");
} else {
return redirect()->route("states");
}
}
}
Below File is app\Http\Controllers\TaskController.php File
<?php
namespace App\Http\Controllers;
use App\Models\Task;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
class TaskController extends Controller
{
public function showTask()
{
$tasks = DB::table("tasks")->get();
return view("home", ["data" => $tasks]);
}
public function validateUser(Request $request)
{
if ($request->validate([
"username" => "required",
"useremail" => "required|email|unique:tasks,email,except,id",
"userpassword" => "required|alpha_num|min:5",
"userage" => "required|numeric|between:18,100",
"usercity" => "required"
], [
"username.required" => "Username field is required!",
"useremail.required" => "Useremail field is required!",
"useremail.email" => "Please Enter the correct Email Address!",
"useremail.unique" => "Email Address is already registered, Please use Unique Email Address!",
"userpassword.required" => "Userpassword field is required!",
"userpassword.alpha_num" => "Userpassword must be Alpha Numeric!",
"userpassword.min" => "Userpassword length should not less than 5!",
"userage.required" => "Userage field is required!",
"userage.numeric" => "Userage must be Numeric!",
"userage.between" => "Userage must be between 18 to 100!",
"usercity.required" => "Usercity field is required!"
])) {
$tasks = Task::insert([
"name" => $request->username,
"email" => $request->useremail,
"password" => $request->userpassword,
"age" => $request->userage,
"city" => $request->usercity,
"created_at" => now(), //now() is a helper function in laravel
"updated_at" => now()
]);
if ($tasks) {
$tasks = DB::table("tasks")->orderBy("id", "desc")->get();
return view("home", ["data" => $tasks]);
}
return redirect()->route("home.task");
} else {
return redirect()->route("adduser");
}
}
public function singleTask(string $id)
{
$tasks = DB::table("tasks")->where("id", $id)->get();
return view("task", ["data" => $tasks]);
}
public function updatePage(string $id)
{
$tasks = DB::table("tasks")->where("id", $id)->first();
return view("updatetask", ["data" => $tasks]);
}
public function updateTask(Request $request, $id)
{
if ($request->validate([
"username" => "required",
"useremail" => "required|email|unique:tasks,email,except,id",
"userpassword" => "required|alpha_num|min:5",
"userage" => "required|numeric|between:18,100",
"usercity" => "required"
], [
"username.required" => "Username field is required!",
"useremail.required" => "Useremail field is required!",
"useremail.email" => "Please Enter the correct Email Address!",
"useremail.unique" => "Email Address is already registered, Please use Unique Email Address!",
"userpassword.required" => "Userpassword field is required!",
"userpassword.alpha_num" => "Userpassword must be Alpha Numeric!",
"userpassword.min" => "Userpassword length should not less than 5!",
"userage.required" => "Userage field is required!",
"userage.numeric" => "Userage must be Numeric!",
"userage.between" => "Userage must be between 18 to 100!",
"usercity.required" => "Usercity field is required!"
])) {
$tasks = DB::table("tasks")->where("id", $id)->update(
[
"name" => $request->username,
"email" => $request->useremail,
"password" => $request->userpassword,
"age" => $request->userage,
"city" => $request->usercity
]
);
if ($tasks) {
return redirect()->route("home.task");
}
} else {
return redirect()->route("update.task");
}
}
public function deleteTask(string $id)
{
$tasks = DB::table("tasks")->where("id", $id)->delete();
if ($tasks) {
return response()->json([
"status" => "success",
"message" => "Record deleted successfully!"
], 200);
} else {
$msg = "<h1>Data Not Deleted.</h1>";
return response()->json([
"status" => "error",
"message" => "Failed to delete the record!"
], 404);
// echo json_encode([
// "error" => "Record Not deleted."
// ], 404);
}
}
}
Below File is app\Http\Controllers\TestController.php File
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class TestController extends Controller
{
public function index()
{
$valueNine = session("name");
return view("welcomeTwo", compact("valueNine"));
// session() is a Global Helper Function
// "Request" Class is used to access Form Data
$value = session()->all();
echo "<pre>";
print_r($value);
echo "</pre>";
$valueTwo = session()->get("name"); //Get(Read) Session Value
// we can use default value(Here, "HELLO" is default value of name "name") of given session in case of not present given session as shown below :
$valueTwo = session("name", "HELLO"); //Get(Read) Session Value
echo $valueTwo . "<br><br>";
// except() method returns Array
// $valueThree = session()->except(["class"]);
// echo "<pre>";
// print_r($valueThree);
// echo "</pre>";
// $valueFour = session()->only(["name","_previous"]);
// echo "<pre>";
// print_r($valueFour);
// echo "</pre>";
// To Check whether any particular session exists OR Not, we can use has() method of session
if (session()->has("name")) {
$valueFive = session()->get("name");
echo $valueFive . "<br><br>";
} else {
echo "has() : Name Key does not exist<br><br>";
}
// We can also use exists() method to check whether any particular session exists OR Not
if (session()->exists("name")) {
$valueSix = session()->get("name");
echo $valueSix . "<br><br>";
} else {
echo "exists() : Name key does not exist<br><br>";
}
if (session()->exists("fruit")) {
$valueSeven = session()->get("fruit");
echo $valueSeven . "<br><br>";
} else {
echo "exists() : Fruit key does not exist<br><br>";
}
// exists() method returns true if session key exists OR session has NULL value and returns false(OR will go in else part) only if session key doesn't exists
// exists() will check only whether session key is present OR Not, Not value
// If any session key has NULL value then exists() method will print it.
// has() method returns true only if session key exists and returns false(OR will go in else part) if session key doesn't exists OR session key has NULL value
if (session()->has("fruit")) {
$valueEight = session()->get("fruit");
echo $valueEight . "<br><br>";
} else {
echo "has() : Fruit key does not exist<br><br>";
}
}
public function storeSession(Request $request)
{
// When we use "Request Class" with session at that time, we must use "put()" method
session(["name" => "HelloWorld", "class" => "BTech", "fruit" => NULL]);
// $request->session()->put("class","BTech");
session()->increment("count", $incrementBy = 2);
session()->decrement("countTwo", $decrementBy = 2);
// regenerate() method will generate different different Tokens every time
// regenerate() method is used for security purpose because every time different Tokens are generated so hackers will confuse and it will trouble for hackers
session()->regenerate();
// session()->flash("status","Session Saved Successfully.");
// return redirect("/welcomeTwoPage");
return redirect("/index");
}
public function deleteSession()
{
// session()->forget(["name", "class"]);
// We can use flush() method to remove All Sessions simultaneously
session()->flush();
// invalidate() method is used for security purpose because every time different Tokens are generated so hackers will confuse and it will trouble for hackers
// and invalidate() method removes all sessions. invalidate() method works same as regenerate() method.
session()->invalidate();
return redirect("/index");
}
}
Below File is app\Http\Controllers\UserController.php File
<?php
namespace App\Http\Controllers;
use App\Http\Requests\UserRequest;
use Illuminate\Http\Request;
use App\Rules\Uppercase;
use Illuminate\Support\Facades\Validator;
use Closure;
class UserController extends Controller
{
// There are two ways for applying Custom Validation Rule : Using Rule Object and Using Closure
// Applying Custom Validation Rule using "Rule Object" way in Laravel as shown below :
// public function addUser(Request $request)
// {
// $validate = $request->validate([
// "username" => ["required", new Uppercase],
// "useremail" => "required|email",
// "userpassword" => "required|alpha_num|min:5",
// "userage" => "required|numeric|between:18,100",
// "usercity" => "required"
// ]);
// return $request->all();
// }
// Applying Custom Validation Rule using "Closure" Method in Laravel as shown below :
// public function addUser(Request $request)
// {
// $validate = $request->validate([
// "username" => [
// "required",
// // Here below Field name(Here "username") will be store in "$attribute"
// function (string $attribute, mixed $value, Closure $fail) {
// if (strtoupper($value) !== $value) {
// $fail("The :attribute must be uppercase.");
// }
// }
// ],
// "useremail" => "required|email",
// "userpassword" => "required|alpha_num|min:5",
// "userage" => "required|numeric|between:18,100",
// "usercity" => "required"
// ]);
// // return $request->all();
// // dd($validate);
// echo $validate["username"];
// }
// public function addUser(UserRequest $request)
// {
// // return $request->all();
// // return $request->only(["username","usercity"]);
// return $request->except(["userpassword","usercity"]);
// }
public function addUser(Request $request)
{
// dd($request->all());
$request->validate([
"username" => "required",
"useremail" => "required|email",
"userpassword" => "required|alpha_num|min:5",
"userage" => "required|numeric|between:18,100",
"usercity" => "required"
], [
"username.required" => "Username field is required!",
"useremail.required" => "Useremail field is required!",
"useremail.email" => "Please Enter the correct Email Address!",
"userpassword.required" => "User Password field is required!",
"userpassword.alpha_num" => "User Password must be Alpha Numeric!",
"userpassword.min" => "User Password length should not less than 5",
"userage.required" => "User Age field is required!",
"userage.numeric" => "User Age must be Numeric!",
"userage.between" => "User Age must be between 18 to 100!",
"usercity.required" => "User City field is required!"
]);
return $request->all();
}
}
Below File is app\Models\Country.php File
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Country extends Model
{
use HasFactory;
protected $table = "country";
protected $primarykey = "id";
protected $fillable = [
"country_name",
"country_code",
"country_dial_code"
];
public function states()
{
return $this->hasMany(States::class, 'country_ID');
}
}
Below File is app\Models\States.php File
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class States extends Model
{
use HasFactory;
protected $table = "states";
protected $primarykey = "id";
protected $foreignkey = "country_ID";
protected $fillable = [
"country_ID",
"state_name",
"status"
];
public function country()
{
return $this->belongsTo(Country::class);
}
}
Below File is app\Models\Task.php File
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Task extends Model
{
use HasFactory;
public $timestamps = true;
protected $table = "tasks";
protected $primarykey = "id";
protected $fillable = [
"name",
"email",
"password",
"age",
"city"
];
}
Below File is app\Models\User.php File
<?php
namespace App\Models;
// use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
class User extends Authenticatable
{
/** @use HasFactory<\Database\Factories\UserFactory> */
use HasFactory, Notifiable;
/**
* The attributes that are mass assignable.
*
* @var array<int, string>
*/
protected $fillable = [
'name',
'email',
'password',
];
/**
* The attributes that should be hidden for serialization.
*
* @var array<int, string>
*/
protected $hidden = [
'password',
'remember_token',
];
/**
* Get the attributes that should be cast.
*
* @return array<string, string>
*/
protected function casts(): array
{
return [
'email_verified_at' => 'datetime',
'password' => 'hashed',
];
}
}
Below File is database\migrations\2024_11_20_043921_create_tasks_table.php File
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('tasks', function (Blueprint $table) {
$table->id();
$table->string("name", 30);
$table->string("email", 191)->unique();
$table->string("password");
$table->integer("age");
$table->string("city", 30);
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('tasks');
}
};
Below File is database\migrations\2024_11_25_050822_create_country_table.php File
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('country', function (Blueprint $table) {
$table->id();
$table->string("country_name", 50);
$table->string("country_code");
$table->string("country_dial");
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('country');
}
};
Below File is database\migrations\2024_11_25_053636_create_states_table.php
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
// Here below, we have used "cascade" that means if we change anything in primary key table then it will automatically update in Foreign key table
Schema::create('states', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger("country_ID");
$table->foreign("country_ID")->references("id")->on("country")->onUpdate("cascade")->onDelete("cascade")->onDelete("set null");
$table->string("state_name", 50);
$table->boolean("status");
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('states');
}
};
Below File is database\migrations\2024_11_28_115321_add_totalstates_to_country_table.php
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('country', function (Blueprint $table) {
$table->integer("Total_States")->after("country_dial");
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
//
}
};
Below File is database\seeders\TaskSeeder.php File
<?php
namespace Database\Seeders;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
class TaskSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
//
}
}
Below File is database\seeders\DatabaseSeeder.php File
<?php
namespace Database\Seeders;
use App\Models\User;
// use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
class DatabaseSeeder extends Seeder
{
/**
* Seed the application's database.
*/
public function run(): void
{
// User::factory(10)->create();
// User::factory()->create([
// 'name' => 'Test User',
// 'email' => 'test@example.com',
// ]);
$this->call([
TaskSeeder::class
]);
}
}
Below File is resources\views\notifications\list.blade.php File
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=no">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Laravel 11 Toastr Notification</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.7.1.min.js" integrity="sha256-/JqT3SQfawRcv/BIHPThkBvs0OEvtFFmqPF/lYI/Cxo=" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/toastr.min.js" integrity="sha512-VEd+nq25CkR676O+pLBnDW09R7VQX9Mdiij052gVCp5yVH3jGtH70Ho/UUv4mJDsEdTvqRCFZg0NKGiojGnUCw==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/toastr.css" integrity="sha512-3pIirOrwegjM6erE5gPSwkUzO+3cTjpnV9lexlNZqvupR64iZBnOOTiiLPb9M36zpMScbmUNIcHUqKD47M719g==" crossorigin="anonymous" referrerpolicy="no-referrer" />
</head>
<body>
<div class="container">
<div class="card mt-5">
<div class="card-header">
<h4>Laravel 11 Toastr Notification</h4>
</div>
<div class="card-body">
<a href="{{ route("notification_list", "success") }}" class="btn btn-success">Success</a>
<a href="{{ route("notification_list", "info") }}" class="btn btn-info">Info</a>
<a href="{{ route("notification_list", "warning") }}" class="btn btn-warning">Warning</a>
</div>
</div>
</div>
@include("notifications.notifications")
</body>
</html>
Below File is resources\views\notifications\notifications.blade.php File
<script type="text/javascript">
@session("success")
toastr.success("{{ $value }}", "Success");
@endsession
@session("info")
toastr.info("{{ $value }}", "Info");
@endsession
@session("warning")
toastr.warning("{{ $value }}", "Warning");
@endsession
@session("error")
toastr.error("{{ $value }}", "Error");
@endsession
</script>
Below File is resources\views\adduser.blade.php File
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=no">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Add User Data</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
</head>
<body>
<div class="container">
<div class="row">
<div class="col-4">
<h1>Add New User</h1>
@if($errors->any())
<ul class="alert alert-danger">
@foreach($errors->all() as $error)
<li>{{ $error }}</li>
@endforeach
</ul>
@endif
<form action="{{ route('validate.user') }}" method="POST">
@csrf
<div class="mb-3">
<label class="form-label">Name</label>
<input type="text" value="{{ old('username') }}" class="form-control @error('username') is-invalid @enderror" name="username">
<span class="text-danger">
@error("username")
{{ $message }}
@enderror
</span>
</div>
<div class="mb-3">
<label class="form-label">Email</label>
<input type="email" value="{{ old('useremail') }}" class="form-control @error('useremail') is-invalid @enderror" name="useremail">
<span class="text-danger">
@error("useremail")
{{ $message }}
@enderror
</span>
</div>
<div class="mb-3">
<label class="form-label">Password</label>
<input type="password" value="{{ old('userpassword') }}" class="form-control @error('userpassword') is-invalid @enderror" name="userpassword">
<span class="text-danger">
@error("userpassword")
{{ $message }}
@enderror
</span>
</div>
<div class="mb-3">
<label class="form-label">Age</label>
<input type="text" value="{{ old('userage') }}" class="form-control @error('userage') is-invalid @enderror" name="userage">
<span class="text-danger">
@error("userage")
{{ $message }}
@enderror
</span>
</div>
<div class="mb-3">
<label class="form-label">City</label>
<select class="form-control" name="usercity">
<option value="Delhi">Delhi</option>
<option value="Mumbai">Mumbai</option>
<option value="Goa">Goa</option>
<option value="Pune">Pune</option>
<option value="Ahmedabad">Ahmedabad</option>
</select>
<span class="text-danger">
@error("usercity")
{{ $message }}
@enderror
</span>
</div>
<button type="submit" class="btn btn-primary">Submit</button>
<a href="{{ route('home.task') }}" class="btn btn-primary">Go to Home</a>
</form>
</div>
</div>
</div>
</body>
</html>
Below File is resources\views\country.blade.php File
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=no">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Country</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.11.8/dist/umd/popper.min.js" integrity="sha384-I7E8VVD/ismYTF4hNIPjVp/Zjvgyol6VFvRkX/vR+Vc4jQkC+hVqc2pM8ODewa9r" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.min.js" integrity="sha384-0pUGZvbkm6XF6gxjEnlmuGrJXVbNuzT9qBBavbLwCsOGabYfZo0T0to5eqruptLy" crossorigin="anonymous"></script>
</head>
<body>
<div class="container mt-5">
<div class="row justify-content-center">
<div class="col-4 card">
<div class="card-header">
<h1 class="mb-5 card-title">Add Country Details</h1>
</div>
<div class="card-body">
<form action="{{ route("validateCountry.country") }}" method="POST">
@csrf
<div class="mb-3">
<label for="exampleInputCountryName" class="form-label">Country Name</label>
<input type="text" class="form-control @error("countryName") is-invalid @enderror" id="exampleInputCountryName" aria-describedby="countryHelp" name="countryName">
@if($errors->has("countryName"))
<div class="error">{{ $errors->first("countryName") }}</div>
@endif
</div>
<div class="mb-3">
<label for="exampleInputCountryCode" class="form-label">Country ISO Code</label>
<input type="text" class="form-control @error("countryCode") is-invalid @enderror" id="exampleInputCountryCode" name="countryCode">
@if($errors->has("countryCode"))
<div class="error">{{ $errors->first("countryCode") }}</div>
@endif
</div>
<div class="mb-3">
<label for="exampleInputCountryDial" class="form-label">Country Dial</label>
<input type="text" class="form-control @error("countryDial") is-invalid @enderror" id="exampleInputCountryDial" name="countryDial">
@if($errors->has("countryDial"))
<div class="error">{{ $errors->first("countryDial") }}</div>
@endif
</div>
<button class="btn btn-primary mt-3">Submit</button>
<a href="{{ route("showCountry.country") }}" class="btn btn-primary mt-3">Go to Home</a>
</form>
</div>
</div>
</div>
</div>
</body>
</html>
Below File is resources\views\countryHome.blade.php File
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=no">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Home Screen</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.11.8/dist/umd/popper.min.js" integrity="sha384-I7E8VVD/ismYTF4hNIPjVp/Zjvgyol6VFvRkX/vR+Vc4jQkC+hVqc2pM8ODewa9r" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.min.js" integrity="sha384-0pUGZvbkm6XF6gxjEnlmuGrJXVbNuzT9qBBavbLwCsOGabYfZo0T0to5eqruptLy" crossorigin="anonymous"></script>
</head>
<body>
<div class="container">
<div class="row">
<div class="col-10">
<a href="{{ route("country") }}" class="btn btn-primary mt-5 mb-5">Add New Country</a>
<table class="table table-bordered table-striped table-hover">
<thead>
<tr>
<th>ID</th>
<th>Country Name</th>
<th>Country Code</th>
<th>Country Dial</th>
<th>Total States</th>
<th>Created At</th>
<th>Updated At</th>
</tr>
</thead>
<tbody>
@foreach($data as $key => $value)
<tr>
<td>{{ $value->id }}</td>
<td>{{ $value->country_name }}</td>
<td>{{ $value->country_code }}</td>
<td>{{ $value->country_dial }}</td>
<td>{{ $value->Total_States }}</td>
{{-- <td>{{ $value->states->count() }}</td> --}}
<td>{{ $value->created_at }}</td>
<td>{{ $value->updated_at }}</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
</div>
</body>
</html>
Below File is resources\views\demo.blade.php File
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=no">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Laravel 11 Toastr Notification</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.7.1.min.js" integrity="sha256-/JqT3SQfawRcv/BIHPThkBvs0OEvtFFmqPF/lYI/Cxo=" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/toastr.min.js" integrity="sha512-VEd+nq25CkR676O+pLBnDW09R7VQX9Mdiij052gVCp5yVH3jGtH70Ho/UUv4mJDsEdTvqRCFZg0NKGiojGnUCw==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/toastr.css" integrity="sha512-3pIirOrwegjM6erE5gPSwkUzO+3cTjpnV9lexlNZqvupR64iZBnOOTiiLPb9M36zpMScbmUNIcHUqKD47M719g==" crossorigin="anonymous" referrerpolicy="no-referrer" />
</head>
<body>
<div class="container">
<div class="card mt-3">
<div class="card-header"><h4>Laravel 11 Toastr Notification</h4></div>
<div class="card-body">
<a href="{{ route("notification","success") }}" class="btn btn-success">Success</a>
<a href="{{ route("notification","info") }}" class="btn btn-info">Info</a>
<a href="{{ route("notification","warning") }}" class="btn btn-warning">Warning</a>
<a href="{{ route("notification","error") }}" class="btn btn-danger">Error</a>
</div>
</div>
</div>
@include("notifications")
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" crossorigin="anonymous"></script>
</body>
</html>
Below File is resources\views\home.blade.php File
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=no">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Home Page</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js" integrity="sha512-v2CJ7UaYy4JwqLDIrZUI/4hqeoQieOmAZNXBeQyjo21dadnwR+8ZaIJVT8EE2iyI61OV8e6M8PP2/4hpQINQ/g==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.11.8/dist/umd/popper.min.js" integrity="sha384-I7E8VVD/ismYTF4hNIPjVp/Zjvgyol6VFvRkX/vR+Vc4jQkC+hVqc2pM8ODewa9r" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.min.js" integrity="sha384-0pUGZvbkm6XF6gxjEnlmuGrJXVbNuzT9qBBavbLwCsOGabYfZo0T0to5eqruptLy" crossorigin="anonymous"></script>
<script src="https://code.jquery.com/jquery-3.7.1.min.js" integrity="sha256-/JqT3SQfawRcv/BIHPThkBvs0OEvtFFmqPF/lYI/Cxo=" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/toastr.min.js" integrity="sha512-VEd+nq25CkR676O+pLBnDW09R7VQX9Mdiij052gVCp5yVH3jGtH70Ho/UUv4mJDsEdTvqRCFZg0NKGiojGnUCw==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/toastr.css" integrity="sha512-3pIirOrwegjM6erE5gPSwkUzO+3cTjpnV9lexlNZqvupR64iZBnOOTiiLPb9M36zpMScbmUNIcHUqKD47M719g==" crossorigin="anonymous" referrerpolicy="no-referrer" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/toastr.min.css" integrity="sha512-vKMx8UnXk60zUwyUnUPM3HbQo8QfmNx7+ltw8Pm5zLusl1XIfwcxo8DbWCqMGKaWeNxWA8yrx5v3SaVpMvR3CA==" crossorigin="anonymous" referrerpolicy="no-referrer" />
</head>
<body>
{{-- Modal --}}
<div class="modal fade" id="exampleModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content">
<div class="modal-header">
<h1 class="modal-title fs-5" id="exampleModalLabel">Delete Record</h1>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
Are you sure to delete record ?
<input type="text" name="task_delete_id" id="task_id">
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
{{-- <button type="button" class="btn btn-danger" data-bs-toggle="modal" data-bs-target="#exampleModal">Delete</button> --}}
<meta name="csrf-token" content="{{ csrf_token() }}">
<a href="javascript:void(0);" data-token="{{ csrf_token() }}" class="btn btn-danger mdl">Delete</a>
{{-- <a href="{{ route("notification", "success") }}" class="btn btn-success">Delete</a> --}}
</div>
</div>
</div>
</div>
<div class="container">
<div class="row">
<div class="col-10">
<a href="{{ route('addNew') }}" class="btn btn-primary btn-sm mt-5 mb-5">Add New User</a>
<table class="table table-bordered table-striped table-hover" id="bodyData">
<thead>
<tr>
<th>ID</th>
<th>Name</th>
<th>Email</th>
<th>Password</th>
<th>Age</th>
<th>City</th>
<th>View</th>
<th>Update</th>
<th>Delete</th>
</tr>
</thead>
<tbody>
@foreach($data as $key => $value)
<tr>
<td>{{ $value->id }}</td>
<td>{{ $value->name }}</td>
<td>{{ $value->email }}</td>
<td>{{ $value->password }}</td>
<td>{{ $value->age }}</td>
<td>{{ $value->city }}</td>
<td><a href="{{ route("single.task", $value->id) }}" class="btn btn-primary btn-sm">View</a></td>
<td><a href="{{ route("update.page", $value->id) }}" class="btn btn-warning btn-sm">Update</a></td>
{{-- <td><a href="{{ route("delete.task", $value->id) }}" data-tid="{{ $value->id }}" class="btn btn-danger btn-sm deleteBtn" data-bs-toggle="modal" data-bs-target="#exampleModal">Delete</a></td> --}}
<td><button data-tid="{{ $value->id }}" class="btn btn-danger btn-sm deleteBtn">Delete</button></td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
</div>
{{-- <script type="text/javascript">
$(".btn-delete").click(function(){
return confirm("Are you sure to delete ?");
});
</script> --}}
<script type="text/javascript">
$(document).ready(function(){
$(document).on("click", ".deleteBtn", function(e){
e.preventDefault();
var task_id = $(this).attr("data-tid");
$("#task_id").val(task_id);
$("#exampleModal").modal("show");
// var deleteUrl = "http://127.0.0.1:8000/delete/"+task_id;
// $(".mdl").attr("href",deleteUrl);
});
$(document).on("click", ".mdl", function(e){
var task_id = $("#task_id").val();
var token = $("meta[name='csrf-token']").attr("content");
$.ajax({
url: "http://127.0.0.1:8000/delete/"+task_id,
type: "GET",
data: { tid: task_id, "_token":token },
dataType: "json",
processData: false,
contentType: false,
success: function(data){
console.log(data.message);
toastr.success(data.message,"success");
$("#exampleModal").modal('hide');
setTimeout(() => {
location.reload();
}, 2000);
},
error: function(error){
toastr.error(error.message,"Error");
toastr.options = {
"closeButton": true,
"progressBar": true
};
}
});
});
});
</script>
@include("notifications")
</body>
</html>
Below File is resources\views\notifications.blade.php File
<script type="text/javascript">
@session("success")
toastr.success("Success","Success");
@endsession
@session("info")
toastr.info("Info","Info");
@endsession
@session("warning")
toastr.warning("Warning","Warning");
@endsession
@session("error")
toastr.error("error","Error");
@endsession
// toastr.success("hello","success");
// toastr.success("{{ session('message') }}");
</script>
Below File is resources\views\states.blade.php File
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=no">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>States</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.11.8/dist/umd/popper.min.js" integrity="sha384-I7E8VVD/ismYTF4hNIPjVp/Zjvgyol6VFvRkX/vR+Vc4jQkC+hVqc2pM8ODewa9r" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.min.js" integrity="sha384-0pUGZvbkm6XF6gxjEnlmuGrJXVbNuzT9qBBavbLwCsOGabYfZo0T0to5eqruptLy" crossorigin="anonymous"></script>
<script src="https://code.jquery.com/jquery-3.7.1.min.js" integrity="sha256-/JqT3SQfawRcv/BIHPThkBvs0OEvtFFmqPF/lYI/Cxo=" crossorigin="anonymous"></script>
</head>
<body>
<div class="container mt-5">
<div class="row justify-content-center">
<div class="col-4 card">
<div class="card-header">
<h1 class="mb-5 card-title">Add State Details</h1>
</div>
<div class="card-body">
<form action="{{ route("validateStates.states") }}" method="POST">
@csrf
<div class="mb-3">
<label for="exampleInputStateName" class="form-label">Enter State : </label>
<input type="text" class="form-control @error("state") is-invalid @enderror" id="exampleInputStateName" aria-describedby="countryHelp" name="state">
@if($errors->has("state"))
<div class="error">{{ $errors->first("state") }}</div>
@endif
</div><br>
<div class="mb-3">
<label for="state">Choose Country name : </label>
<select name="country" id="country" name="country">
@foreach($data as $key => $value)
<option value={{ $value->id }}>{{ $value->country_name }}</option>
@endforeach
</select>
@if($errors->has("country"))
<div class="error">{{ $errors->first("country") }}</div>
@endif
</div><br>
<p>Please select status : </p>
<input type="radio" id="active" name="status" value="1">
<label for="active">Active</label><br><br>
<input type="radio" id="inactive" name="status" value="0">
<label for="inactive">Inactive</label><br>
@if($errors->has("status"))
<div class="error">{{ $errors->first("status") }}</div>
@endif
<br><br>
<button type="submit" class="btn btn-primary">Submit</button>
<a href="{{ route("showStates.states") }}" class="btn btn-primary">Go to Home</a>
</form>
</div>
</div>
</div>
</div>
{{-- <script>
$(document).ready(function(){
$("#country").change(function(){
var id = this.value;
$("#exampleCountryID").val(id);
// alert(id);
// $.ajax({
// url: "http://127.0.0.1:8000/states",
// type: "POST",
// dataType: "json",
// data: {country_id: id},
// success: function(result){
// if(result) {
// alert("Correct");
// }
// },
// error: function(result){
// if(result) {
// alert("Incorrect");
// }
// }
// });
});
});
</script> --}}
</body>
</html>
Below File is resources\views\statesHome.blade.php File
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=no">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Home Screen</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.11.8/dist/umd/popper.min.js" integrity="sha384-I7E8VVD/ismYTF4hNIPjVp/Zjvgyol6VFvRkX/vR+Vc4jQkC+hVqc2pM8ODewa9r" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.min.js" integrity="sha384-0pUGZvbkm6XF6gxjEnlmuGrJXVbNuzT9qBBavbLwCsOGabYfZo0T0to5eqruptLy" crossorigin="anonymous"></script>
</head>
<body>
<div class="container">
<div class="row">
<div class="col-10">
<a href="{{ route("states") }}" class="btn btn-primary mt-5 mb-5">Add New State</a>
<table class="table table-bordered table-striped table-hover">
<thead>
<tr>
<td>ID</td>
<td>Country ID</td>
<td>State Name</td>
<td>Status</td>
<td>Created At</td>
<td>Updated At</td>
</tr>
</thead>
<tbody>
@foreach($data as $key => $value)
<tr>
<td>{{ $value->id }}</td>
<td>{{ $value->country_ID }}</td>
<td>{{ $value->state_name }}</td>
<td>{{ $value->status }}</td>
<td>{{ $value->created_at }}</td>
<td>{{ $value->updated_at }}</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
</div>
</body>
</html>
Below File is resources\views\task.blade.php File
<h1>User Details</h1>
@foreach($data as $key => $value)
<h2>Name : {{ $value->name }}</h2>
<h2>Email : {{ $value->email }}</h2>
<h2>Password : {{ $value->password }}</h2>
<h2>Age : {{ $value->age }}</h2>
<h2>City : {{ $value->city }}</h2>
@endforeach
Below File is resources\views\updatetask.blade.php File
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=no">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Update Task</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
</head>
<body>
<div class="container">
<div class="row">
<div class="col-10">
<h1>Update User Data</h1>
<form action="{{ route('update.task', $data->id) }}" method="POST">
{{-- here @csrf method will add token in Form. That token will store on server and
our Local System. After filling form when we press submit button then Laravel will
match this Token. If Token match then data will save, if token is not match then
data will not save --}}
@csrf
@method("PUT")
<div class="mb-3">
<label class="form-label">Name</label>
<input type="text" value="{{ $data->name }}" class="form-control @error("username") is-invalid @enderror" name="username">
<span class="text-danger">
@error("username")
{{ $message }}
@enderror
</span>
</div>
<div class="mb-3">
<label class="form-label">Email</label>
<input type="text" value="{{ $data->email }}" class="form-control @error("useremail") is-invalid @enderror" name="useremail">
<span class="text-danger">
@error("useremail")
{{ $message }}
@enderror
</span>
</div>
<div class="mb-3">
<label class="form-label">Password</label>
<input type="text" value="{{ $data->password }}" class="form-control @error("userpassword") is-invalid @enderror" name="userpassword">
<span class="text-danger">
@error("userpassword")
{{ $message }}
@enderror
</span>
</div>
<div class="mb-3">
<label class="form-label">Age</label>
<input type="text" value="{{ $data->age }}" class="form-control @error("userage") is-invalid @enderror" name="userage">
<span class="text-danger">
@error("userage")
{{ $message }}
@enderror
</span>
</div>
<div class="mb-3">
<label class="form-label">City</label>
<select class="form-control" value={{ $data->city }} name="usercity">
<option value="Delhi">Delhi</option>
<option value="Mumbai">Mumbai</option>
<option value="Goa">Goa</option>
<option value="Pune">Pune</option>
<option value="Ahmedabad">Ahmedabad</option>
</select>
<span class="text-danger">
@error("usercity")
{{ $message }}
@enderror
</span>
</div>
<button type="submit" class="btn btn-primary">Update</button>
<a href="{{ route("home.task") }}" class="btn btn-primary">Go to Home</a>
</form>
</div>
</div>
</div>
</body>
</html>
Below File is resources\views\welcomeTwo.blade.php File
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=no">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>WelcomeTwo</title>
</head>
<body>
<h1>{{ $valueNine }}</h1>
@if(session("status"))
<div class="alert alert-success">
{{ session("status") }}
</div>
@endif
</body>
</html>
Below File is routes\web.php File
<?php
use App\Http\Controllers\CountryController;
use App\Http\Controllers\NotificationController;
use App\Http\Controllers\StatesController;
use App\Http\Controllers\TaskController;
use App\Http\Controllers\TestController;
use App\Http\Controllers\UserController;
use Illuminate\Support\Facades\Route;
Route::get('/', function () {
return view('welcome');
});
Route::controller(NotificationController::class)->group(function () {
Route::get("notification", "indexNotification");
Route::get("notification/{type}", "notification")->name("notification");
Route::get("notification_list", "index_notification");
Route::get("notification_list/{type}", "notification_list")->name("notification_list");
});
Route::controller(TestController::class)->group(function () {
Route::get("/index", "index");
Route::get("/store-session", "storeSession");
Route::get("/delete-session", "deleteSession");
});
Route::get("/welcomeTwoPage", function () {
return view("welcomeTwo");
});
Route::get("/form", function () {
return view("adduser");
})->name("adduser");
Route::post("/add", [UserController::class, "addUser"])->name("addUser");
Route::get("/showAllTasks", [TaskController::class, "showTask"])->name("home.task");
Route::post("/checkValidate", [TaskController::class, "validateUser"])->name("validate.user");
Route::get("/singleTask/{id}", [TaskController::class, "singleTask"])->name("single.task");
Route::get("/updatePage/{id}", [TaskController::class, "updatePage"])->name("update.page");
Route::put("/updateTask/{id}", [TaskController::class, "updateTask"])->name("update.task");
Route::get("/delete/{id}", [TaskController::class, "deleteTask"])->name("delete.task");
Route::controller(CountryController::class)->group(function () {
Route::post("/validateCountry", "validateCountry")->name("validateCountry.country");
Route::get("/countryHome", "showCountry")->name("showCountry.country");
Route::get("/country","index")->name("country");
});
Route::controller(StatesController::class)->group(function () {
Route::post("/validateStates", "validateStates")->name("validateStates.states");
Route::get("/statesHome", "showStates")->name("showStates.states");
Route::get("/states", "index")->name("states");
});
Route::get("/addNew", function () {
return view("adduser");
})->name("addNew");
.png)
.png)
.png)
.png)
.png)
.png)
.png)
Comments
Post a Comment