Posts

Showing posts from November, 2024

Eloquent ORM Create Data Tutorial in Laravel 11

Image
  <?php namespace App\Http\Controllers ; use App\Models\ User ; use Illuminate\Http\ Request ; class UserController extends Controller {     /**      * Display a listing of the resource.      */     public function index ()     {         $users = User :: all ();         // return $users;  //Here returns json data         // $users = User::find(2); //Here find() method doesn't return JSON, find() method returns Array         // $users = User::find(2,["name","email"]);         // $users = User::find([2,4],["name","email"]);         // $users = User::count();         // $users = User::min("age");  //min() and max() methods works with integer data Type Columns         // $users = User::max("age");         // $users = User::sum("...

Eloquent ORM Read Data Tutorial in Laravel 11

Image
  <?php namespace App\Http\Controllers ; use App\Models\ User ; use Illuminate\Http\ Request ; class UserController extends Controller {     /**      * Display a listing of the resource.      */     public function index ()     {         // $users = User::all();         // return $users;  //Here returns json data         // $users = User::find(2); //Here find() method doesn't return JSON, find() method returns Array         // $users = User::find(2,["name","email"]);         // $users = User::find([2,4],["name","email"]);         // $users = User::count();         // $users = User::min("age");  //min() and max() methods works with integer data Type Columns         // $users = User::max("age");         // $users = User::sum("a...