Laravel 8 tutorial - Controller | how to create controller in laravel | laravel controller example

 command

php artisan make:controller UserController

php artisan make:controller UserController –invokable


routes\web.php

//6 Controller
Route::get('users',[UserController::class,'index']);
Route::get('userpage',[UserController::class,'view']);
Route::get('users/{id}',[UserController::class,'peramiter']);


app\Http\Controllers\UserController.php


<?php

namespace App\Http\Controllers;

class UserController extends Controller
{

    public function index()
    {
        return "hello";
    }

    public function peramiter($id)
    {
        return $id;
    }
    public function view()
    {
        return view('user');
    }

}


Hi everyone welcome back to my dental my name is on it and in this letter we would have to go to be learned about the control let me see what is the control of how we can make a call we can define the function inside a public and political not altered and hope we can pause the. But I'm retired of the day you want to and and the last a last minute congressional so one more important thing in this video is that. 

Not I will it have the different syntax footballing the controller from that out in the 7 and 6 a lot I mean you can find the difference index into it you will find the difference index I will make a complete radio on it because this is all new feature of the laravel it but. There will be only specifically for the lot of L. calling from doctor 8 a note about the. Controller now the flesh less than just jump on the main topic what is the controller to controller is basically a central unit off any MVC framework I took a lot of L.

 like using like go why I am old right so in the MVC there is a C. directly meaning though I mean with the controller and what we do here so controlling basically fetch the data from the old Morton and send to them view that simply you can see that doesn't get the data from the database and chill below. Our view and the estimate part and the second thing is although you can Bakula programming actually done in the controller and second and the third thing is that old office under the direct link with the controller right and I will show you how that occurs automatically can the condolence or thank so now let's see how we can just.

 If a controller so let's open the,nd line and assembly right TF PHP artisan make. In Poland. And controller name select a controller name is users right and just hit the enter now you can find this controller inside the. App as TDP controllers and here so let's close the oral fallen an average we will be in STP then controllers and headaches. You can use the movie to make the controllers VH1 in the,nd line another you can just make it by creating the new file like this type so you can just get a new fight let's see what another controller name is about both PHP right and who just make it very quickly despite just copy and paste the cord and just change here last name I'd like this soap you can use the bottles bit vague but up I will just be coming to that you can use the,nd line because this is normal practice group type or these things and then create a new file and save it because it will just finding things it will just waste your time so because a lot of it is a very popular for rates come online we just knew that modeling that simple right so now the next thing is that how we can make the function inside controlled this is a very simple you're going to simply make a function like this function the function name and you can just write something here like hello. From control. Right and you can just define the exes modified heroes like public private or protected whatever you want right.

 Like this and a sportier semicolon so how we can call this controller the firm that I wanted and she showed this output here but I just want to see hello from the controller here on a browser so for that let's go to the of that book PHP. Of it is a placed inside the. Close that's open the web of peach pit and here you can just to find out about this plan that allow as a board in the previous would be doing so I'm just telling you again do you have to define the pool but I'm the best one is the pot what do you what is and second one is controller. 58. So well this is the vision or the controller so now first of all let me tell you that how we call the components in the lot of it 7 and it's previous versions like so you can decided like this here you can put the pot like you just want to. Make the potluck users. Then you can just use here to use as condoning same as the capitalization than just define a function name but now this index is a little bit different. If you plan to use it. And then believe me you will find the. Edit here. Like this right because the beast is now so now what do you need rules first before you have to import. The letter L. controller like this shows.

 App. S. T. T. P.. Then controller. And then the single date here. Home my bad the controller name to just use that site end of does Patel semicolon at the lot. Chipped semicolon at the last and commend the survey and decide if new with. Right Seoul just the. What had a get function. And are defined by you either love pot let's see who's this. Then in the second but I need to define and edit and in the end he just put your glass. And a lot like last. An ongoing class 8 and stuff just for the second but I'm adept at low functioning like this. Now this type of excessive. Okay okay so I have to put air controllers controllers. That's working fine now so now the next thinking how we can just send the data from here let's say you just want to boss the name or by somebody that will look into how you can blink so for a moment you will get an added here like this. Food is all baked or blasted I you can just simply use it like put Kevin name ID or user let's say you just want to use a but I would like users and Dan here to simply right here hello. User. And even you can just make can console like bola use that even you can use the bottle things in a single Edwards but I'm just going to define like this state.



  • laravel 8 route controller
  • laravel resource controller
  • laravel controller example
  • php artisan make:controller
  • how to create controller in laravel
  • route::resource laravel 8
  • route controller laravel
  • laravel documentation


Post a Comment

0 Comments
* Please Don't Spam Here. All the Comments are Reviewed by Admin.