Created
June 13, 2023 06:33
-
-
Save johnadan/bac26d68ffc10104b02776c2665dc427 to your computer and use it in GitHub Desktop.
create and use a function inside a model to controller
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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