Skip to content

Instantly share code, notes, and snippets.

@johnadan
Created June 13, 2023 06:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johnadan/bac26d68ffc10104b02776c2665dc427 to your computer and use it in GitHub Desktop.
Save johnadan/bac26d68ffc10104b02776c2665dc427 to your computer and use it in GitHub Desktop.
create and use a function inside a model to controller
<?php
class UserModel extends Model
{
public function totalUsers() {
$users = DB::table('users')->get();
return $users->count();
}
}
class UserController extends Model
{
public function index() {
$user = new User;
$total_users = $user->totalUsers();
return "Total registred users ".$total_users;
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment