Project Set up Step

1= create project composer create-project --prefer-dist laravel/laravel create-blog 2=go to project directory cd create-blog 3= install ui composer require laravel/ui 4=install boostrap php artisan ui bootstrap --auth 5=npm install npm install 6=npm run dev npm run dev 7= for bootswatch install optional npm install bootswatch 8= copy =sass code = from https://bootswatch.com/help/ paste in resources app.scss @import 3 times liness 9=npm run dev 10= start server php artisan serve 11= database migrate php artisan migrate 12=create table ( via migration ) php artisan make:migration create_contacts_table 13=create table stucture inn database migrate table name file 14 = apply to db file into php my admin => do migrate php artisan migrate 15=make resourse controller php artisan make:controller contactController --resource 16= new model php artisan make:model Contact 17=display query with =where order by pagination $id = auth()->user()->id; $contacts = Contact::where('userid', $id)->orderBy("id", "desc")->paginate(5); return view('show', ['contacts' => $contacts]); 18= insert query with session validation $user = auth()->user(); $user_id = $user->id; $request->validate([ 'name' => 'required', 'email' => 'required', 'phone' => 'required' ]); $contact = Contact::create([ 'name' => $request->name, 'email' => $request->email, 'phone' => $request->phone, 'userid' => $user_id ]); 19=update form
@csrf @method("PATCH")
20=update ontroller function public function update(Request $request, $id) { $contact = Contact::find($id); $contact->name = $request->name; $contact->email = $request->email; $contact->phone = $request->phone; if ($contact->save()) { return redirect("contacts")->with("contactEdited", "Contact Updated"); } } 21=validation with old value retuen @error('name') {{$message}} @enderror 22=delete $contact = Contact::find($id); if ($contact->delete()) { return redirect("contacts")->with("contactDeleted", "Contact Deleted"); } 23=

Comments

Popular posts from this blog

routes->web.php

HomeController.php log reg