Posts

Showing posts from January, 2025

CRUD using Ajax(jQuery) in Laravel 11

Image
   <?php namespace App\Http\Controllers ; use App\Models\ Student ; use Illuminate\Http\ Request ; class StudentController extends Controller {     public function addStudent ( Request $request )     {         $file = $request -> file ( "file" );         $fileName = time () . "" . $file -> getClientOriginalName ();         $filePath = $file -> storeAs ( "images" , $fileName , "public" );         $student = new Student ;         $student -> name = $request -> name ;         $student -> email = $request -> email ;         $student -> image = $filePath ;         $student -> save ();         return response ()-> json ([ "result" => "Student data created Successfully." ]);     }     public function getStude...

CRUD Project (Create | Read | Update | Delete) | Image Upload in Laravel 11

Image
   <?php namespace App\Http\Controllers ; use App\Models\ Product ; use Illuminate\Http\ Request ; use Illuminate\Support\Facades\ File ; use Illuminate\Support\Facades\ Validator ; class ProductController extends Controller {     // This method will show products page     public function index ()     {         $products = Product :: orderBy ( "created_at" , "DESC" )-> get ();         return view ( "products.list" , [             "products" => $products         ]);     }     // This method will show create product page     public function create ()     {         return view ( "products.create" );     }     // This method will store a product in db     public function store ( Request $request )     {         $rules...