Skip to content

Instantly share code, notes, and snippets.

@Vigowebs
Created January 2, 2023 14:51
Show Gist options
  • Save Vigowebs/ddebe03272cd2d0492513b33f36cdc33 to your computer and use it in GitHub Desktop.
Save Vigowebs/ddebe03272cd2d0492513b33f36cdc33 to your computer and use it in GitHub Desktop.
This route will match a GET request to the /users URL and will call the index method of the UserController class. The index method retrieves a list of all users from the database using the User model and then returns a view file located at resources/views/users/index.blade.php, passing the $users variable to the view.
Route::get('/users', 'UserController@index');
class UserController extends Controller
{
public function index()
{
$users = User::all();
return view('users.index', compact('users'));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment