laravel 5.6 # create read update delete (crud) authentication pagination in laravel 5.6

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
in this screencast I will show you how can we make a create read update delete I mean crowd application using laravel 5.6 I have added authentication functionality with this application and physician things and this is actually the end result of this application anyone can see all forced and the single forced but in order to create a new forced or edit a forced or delete a first the people have to be registered user I mean authenticate a user suppose if I click on create first it takes me to the login page so if I log in here now I will to create a first suppose I create a first this is my first post and putting some dummy content here if I click on that first so this is the first post if I want to edit this thing if I click on edit and update this post it will update this post have been updated successfully if I go to home page again so this is the first and since I am logged in here I can logout from here as well if I click on it take me to the home page it's actually the oil campus of the laravel so I'm in my desktop I'm opening my terminal sit into desktop so here I will make a lateral project composer create happen project terrible slash horrible then what will be your laravel project name say i kept my letter will downloaded successfully it actually taking a lot of time in your case also it will take huge time since it is lot of dependency so if I sit inside my blog directory so currently I mean my blog directory by running PHP artisan common PHP artisan sorry it will actually run a development server so if I go to the localhost $8,000 I will so Laura will install successfully so now they make another tip then open the whole project into my sub lon there's the so we all know the our ability MVC framework so what actually MVC so this is the MVC framework we all know embassy means Model View and controller so whenever something suppose you go to single route this is a route right so it actually first you will go to route route will call a controller and controller actually dispatch ABY mean Shoaib you so high number you need data from database or anywhere else it actually talk to model so whenever you controller needed data it will getting data from model whenever something he want to store data into database he will excuse ending data to model so this is the basic model view controller but the first thing comes route route is essential so any request will come to route route will send it to the controller controller will show the views accordance the request but in between model will only communicate with controller whenever views needs some another timing some data it will actually fetching data from model or in some cases suppose in in case of creating it actually giving data to model in case of getting I mean reading some data it actually getting data from model so this is the basic structure of the Model View controller so wire actually I don't find this for thing so this is the routes it has four routes for laravel API Chris channel console and oil since we are going to make a website so all routes will be available here so this is the current route you may find out whenever someone go to the trout it will show the welcome page so this is the Welcome view I mean this page actually the Welcome page of the laravel and where I will find the controller so this is the place yep HTTP controller here actually all the controller will be researched and all models will be the the directly route up the app I mean here user is a model this is actually model so three things and another thing is be u s-- abuse will be found under the resources we use so so model will be have your model dot PHP this is will be your model location and route will be routes web dot PHP and controller will be have HTTP is actually uppercase but you will understand I think controller I think it's controllers controllers plural from this is because it has a lot of controllers okay then your controller dot PHP so then route controller model then view we will be resources views you would be dot PHP whatever be you have horrible comes with artisan common line tool you already seen some common here PHP artisans are using the sort command it actually make a development server so that we can access this server using localhost 8002 model command is PSP audition make : model then you model name so another thing is called controller so that will be your controller name so other than this for file we need another three things one is database things which actually you will get this inside this database folder database folder there is three folders factor this migration seats so factor is actually for the updating some dummy data I mean if you taste your website and you put some dummy data in your website so this is for factories those factory data will be seeded using this database cedar and migration actually the you table structure your the schema structure suppose the rebel comes with built-in authentication so it has a some user table so this is the structure of the user tables if you take a look this is the increments ID string name string email and it should be unique and string password then remember to contain stem for the created that and updated it so we said this I need we need we actually have to know about the three things database slash factories slash your factory dot PHP then database slash migration slash your migration file dot PSP and this is actually you will generate but the route I will write the route things database slash ceaseless database sitter dot PHP to create a migration command SP SP artisan make migration say your table name dot this is the command actually so to create a factory the command is PHP artisan make factory you factory then I have to send a flag M flag and flag will be app your modeling so there's all so we every time we want to craft something we actually need this for file so same all those for file we can get through the single command as well so this is a very handy if you want to make this thing individually you can make it or you if you want to the you know using the same simple command this is called PHP artisan make model just here you will tell a if or watch a all and this single common output and this for common output is same this is the basic model view controller flow and this is the how some essential audition common now if I go to the route now to type the PHP so currently we have all come down suppose I want to make another route route say gate say here write your hello so hi neighbor hello comes say I will return hello wall so if I go to the slash hello we'll find out we get this hello wall which I we are telling here so whenever someone go to the hello route the controller will set the hello wall so think is currently it's a single line of code but in function that there should be might be hundred of line so what will be happen in that case it will become clumsy right and think about if in this page there will be might be more than hundred route so in that case you can't maintain those things so this is the reason they have a solution you should make a controller file where you keep your all action so suppose we make another controller so people making a controller I just used git for tracking my file this is totally optional you don't need to use it but if you use it it's good actually good practice you I will make a controller call say PSP Hardison make controller say page controller we know that now currently controller will be available app HTTP controller and your controller app is TTP with the controller in my controller is based controller so here I make a function public function index return hello so instead of function I'll give the reference that my controller name is phase controller and method name is index that's all now if I go to go to my website again if I reload this page I am getting the same result I mean the hello result which actually I'm telling inside the page controller so this is the basic route and controller things and sometimes we keep the name of the route say name equal to say hello so if I go to the main terminal and make a common PSP partisan route list you'll find out excuse me so currently we have three routes for the route it is a closer middle Aires web and currently another one is hello which we just created and its name also hello so this is for the this using this name function we actually declare what is the name of this route and this is the reference I mean where the section resides action research inside the space controller the function name is index I mean method name is index their soul so this is basic route controller and another one is model so we make a model PHP artisan make model say model lim page so we make a model named Paige if I go to the page so Paige model that will be inside app folder so this is the model actually so now I am making a public static function only for returning some dummy data so I make a static function I make it static public static so this is my model the model name is Paige so suppose I want to show all the fruits in this index page what I need to do say fruits make well our model image space and function image fruits so that will actually give me the all force since we returned fruits here so currently our new species a pasty to be controllers but the pace thing we are using here is from the different namespace so suppose base is face namespaces app so whenever you want anything you want to use anything different then this namespace you have to actually use use the use statement so in this case that will be the under app page app page so we have fruits if we return excuse me fruits and go to our website feed alert this so this is the force we're getting from the model so currently in model we are sending data something hard coded data but in the future we will actually getting data from the database I mean in model through we will actually talk to the database so this is the basic about model so what actually we know about so far route controller model so the one thing is left is peevish so views will be inside the views will be inside resource be useful so any anything any PHP file would be Billy V which suppose I make a view say index dot PHP say here basic HTML tag and I'm writing something this is hello world view so this is the view if we go to face controller again so I'm telling we want to return that view so return view so what is the bunam so bunam is index dot PHP but we shouldn't use any extension only index and if it's stay inside a folder suppose some folder you have to put this thing or fold-up dot index it's up to you whether you use dot or slash so in your case it's directly inside this view show file image will be only POC so if we so this is this is the hello world view and this is the so you understand the the basic PHP things actually it's self-explanatory actually but things you may find out they are using something called blade templating engine this is the we are using index dot PHP but they are using dot plate dot PHP so whether you can go with dot PHP or rather go with dot bleed dot PHP but using blade PSP is Paracon because it gives you a lot of flexibility so we will actually always go with the dot dot PHP so blade actually the templating language and it's very easy even it's very easy easier than raw PHP you'll find out in this video itself so we clear about the route doing things model things view things controller things so now one thing is slipped think about we have a fruit right but we want to pass those fruits inside this view so we have to pass an array fruits will be these proofs the first we getting from here now force will be available here this index dot later PSP so we can eat a red force so normally we used to it this porridge slope I mean the PSP porous loops but blade has more flexible centers just for each and for each so suppose in our case fruits as food so this is kind of Ecotec we can equal using say fruit now if I reload this page will get excuse me okay we did not echo here eco-floor if I reload here I am getting the three fruits here since I am iterating here more we can use the blade syntax for echo this is double curly brace same thing just if I called fruit they're set up so it's kind of berry simpler actually so I that the reason blade is much flexible than the raw PHP so far we learn Model View controller route and how to pass variable to the view and how to eat right using the blade directive this thing called directive so if I see the get status we change actually they're out and the pace controller based at peace with those well we are just new created so we will going to delete all those thing now we are clean we delayed everything now we start from scratch now we know the model we know that B we know the controller and we know the how to pass data to abuse and how to keep named some route now our objectives to make proud proud application so rod means create read update delete we all know that so I am planning to make a post where will be title and content only to field so so how many routes we have to write for that if you think about we will read all forced we will read single first we will create a page to showing a form to create first then we will make a action page where actually through this action we will store the first content I mean form content into database I kept name in store out so another thing for the editing suppose you want to edit something so you need to make edit fish you need to make up update raw route you know I mean after editing where those forms should be actioned then last one is dillert we actually need seven things so this is called gate since we just want to get in from some database this is Colgate since we want to getting from database in this route we will just show a form for creating first so this is also good but when it comes to store it will be forced one is come to edit timing when we will just show a form for editing that will be get for update so this is kind of different this is called put or patch in HTML we have only forced and gate sctv bar but in sabah we have actually the fight things post gate port purge and deal it normally force destatte before creating a new record in database gate for getting any file or getting any bu and getting any data and food for actually updating best for updating and delayed for deleting any data so Lara will already have those thing but since our HTTP don't have so horrible already about some function that way we can told to the server that it actually put route it actually the dealer trout wine we making cloud you will understand all those things we can know that all router East using the PSP what is on route list common so currently it has only the three doubt so I'm going to the route dot PHP file I'm delet the whole thing ok I'm not deleting all came part so we'll make all those four file using this single command PSP artisan make model model name is post you always have to consider I mean it's kind of a convention model name always will be the singular and the singular form of the tables name so I tell all I mean using - a flag so it get creating therefore file so if I go to the app you will find out this post has been created if I go to the HTTP controller and this is the force controller and if I go to the database factory this is force factory this factory file is created and this is the migration file this is the migration where where I will state what will be the column of my first say table STR ing stream title table text content so this is actually the variable character for the my sequel and this is the text data type of the my sequel so now we need to make it out of it and connect those database with my lovable project so I am login to my my sequel I create a database blog I'm quitting from my sequel in the route something called dot e and B I mean the environment file here I'll telling my database name is blog username is root and I do not have any password if you have a older my sequel you have to tell arabel that default string length should be one ninety one character or less than one ninety one character so if you want to change this you need to go to the app service provider you have service provider I mean app service provider is a file final Allah will load you to all file before loading every file it actually first go check this F service provider boot method so here I am telling inaudible my default string length should be 191 schema default STR ing string lien GTS length 191 and since it has an M space so we have to tell laravel use schema so you may find out in that case we are using the whole path but here we are using some Elias this is because a schema is available in the Elias so where you will find all Elias if I go to the confit AB dot PHP you will find out all a Lea's there so for the schema this is the scheme alias if we can use the whole thing or we can easily just use this use schema so it's pretty convenient so I'm go with this schema so everything right now I have to make it with the database PHP artisan my kit so it's migrated successfully now if I log in to our my sequel huge block select describe post so this is the structure it has title content which we give and Laurel already has comes with ID and created and content updated at those three fields so we just added to Phil so I'm quitting from here I stop this server and run the server again whenever you change the roti and be filed you have to restart your server again PHP artisan salt so now the first thing we need to make some dummy data inside our database so in order to make a dummy data we will go to the database host factory here so I'm telling in database title will be they are passing some fake a library thicker for seeding your database with your fake data say take a sentence then content will be fake our paragraph say six Farah group so now I have to register this post factory here data b'seder factory factory will be forced class and create function so I have to include this namespace here Jewish app post PHP artisan DB C okay my paragraph is spelling is strong surely there is a type for GRA pH paragraph now if I run this command again PSP what is on DB : seed now my daughter settings inside they don't get any error if I go to my sickle here's your root block select so here this force to dummy foot has been seeded successfully now I am quitting here no way you have to add our out inside this Y dot PHP file routes wipe dot PHP file we will use resource out we know in case of card we need a seven endpoint so resource route already has so I mean if we make the single route it will make the seventh route and host controller already has seven function for that since we are using flag a so recess controller look like that resource we are telling whenever the first will be the our base note and the controller name so control enemies host controller so PHP artisan route list you'll find out there is seven route no this is this is Paul this is the name host dot index hose dot store this port storing and the method is forced and this is for creating this is for showing the single post this for updating look at her it's a put or patch method and put the deleting this is a delayed method and it has a name posted or destroy and for the editing it is a great method and this is name is was dot edit so our route completed now we first go to our model model let me suppose dot PHP so we have to tell this model all the field inside this forced table should be fillable so we can tell fillable equal title and content so this is the one thing or same thing we can s it through the protected guarded equal to nothing I mean this is kind of rebirths if you want to feel able any column of your database you just put insert this fee level array but if you have a lot of data and I mean a lot of column in that case might be guarded will be the base charges excuse me codec is spilling wrong GU er de D guarded recorded it nothing I mean I'm not going to card any column of this database so it actually I can if I submitted any data through the form it will actually receive data and create a post and set my database so now we will go to the first controller so I need essential the for view for the single post for the all forced for the edit page and for the create page so resource inside views I make a folder call first make a file let that PSP this poor all forced created played PSP and this is for creating a forced edit dot let dot php' this is for editing a host shoulder-blade PSP for this is for showing a single first so I first got stem l5 I personally try to use the butcher and Kofi so all the CSS content actually CSS or any asset actually stay inside this public folder so this is the CSS oh I can make a file call push up dot CSS and I'm investing all the push up content here so it's a Gousha file so we can linking link / CSS slash dot CSS so you may understand right now the public is there actually the root folder of our replication so this is the root and on inside public there is for that name CSS insert CSS boost up your CSS our Boosh your file so there so so here I make a container margin to five so if I go to the first controller index method we will just return this be written view view be locating inside host slash index so instead of food / we can use dot so our server already running if I go our server / post so this is doll first so now we will make a query to getting post from the database for Stickle our host model all that's all it'll actually getting all data from database so we have to use this F host we already using a post since we run this comment that there isn't actually already having this new statement here so I am getting all the first here but I have to fast those postings at this view so in order to fast Bo I just tell post first their soul actually now I can use the forced it actually a they are forced if I go to the index dot blooded PHP I'll eat it all this post here so I make a card say host title so if I go or good browser very load this page so this is all forced actually we are getting here so there is starting 31st might be in between margin will be good for looking say merchant of for if I read order page this is now much look this and so this is the list of hosts now we have to give the appropriate link for the showing page so this is the link so if I go out I will find out for the showing certain this is the name of the route post show and it takes a one parameter call forced so link will be route post-show and it will take a ID as a parameter for study so if I reload this thing in my Chrome browser so this is one if I click the second one this is to go to our show page so this is our show page so now something comes in mind think about so in show page also we'll have such kind of bullsháá file header footer those file so that could be a good practice so if we make a master file so in rockiest we don't have such kind of master concept but here we have such kind of concept master dot blade dot PHP so I'm coughing whole thing from index dot PHP and fasting here and I'm deleting from body I'm deleting everything from body and I'm yielding here I mean everything will be as as well in every page but I'm telling that this is kind of place where all the content having all the variable content will be flesh now if I go to index page I can delete all those things right now now I have to tell that it extends or master so you may find out master I actually write direct insert this views if you have a master's inside any folder you have to tell folder dot or folder slash now I tell another directed call section content and section so here we are telling we are exchanging your masters file and this is the content and this content we already yielding here this is real content I mean the all content we are putting inside this indexed or played with PHP file that will be actually locate here in this place okay so since container is needing everywhere that could be good idea to keep container inside master so if I go to the index tablet at PHP I can remove content right so in this case also we will get the same result if I reload this page again we are getting same okay so now we have to work with the single page sugar plate dot PHP so it will extends our master file then section will be content I will write our all end section okay we can you stop directive as well if I tell the stop that is also same thing so I make a card so that'll be the first title the third body I make a pee tag and here I'll give post content so we have to load this page from the controller host controller so this is actually the show method we have seven method we visit the seven bit mammography browse the seven method index create store show edit update and destroy so you will get the some little bit about documentation about every before every method so we'll return b so b name will be host show and we will pass the post so if I click on this host they'll find out this is the first exploding single post this is post number one so if I click on the another post this day another flossed so our to read file done I mean index and show page now we will work with the create page okay rather it would be better if we make some navigation bar so navigation bar will make insert the our footer I mean hey master say busy info text white 13 5 so this route is for post index and another one is create post create create post so if I go all post we are getting this thing okay after navigation I will give little margin bottom say 3 so now it's location might be footer giving footer also feel good before body PG dark text void so fading for takes center so if we reload our page we make our footer as well already reception you name 2018 so our header footer done now if I click on create first let's take me to the create first paste but we didn't make this page yet create dot plate dot PHP extend master this section will be content section so I'm making using a form so for method of it certainly will be the post and we have a only title and content so I'm I need three form group level for title title giving a boost up classical form control so this poem group for content and another chord pattern so button type suddenly will be the submit class will be button button offline safe primary class will be first so before for my make a s2 margin top bottom say 3 so if I reload this page okay so we have to load this view so we have to go to the force controller and function is create duplicate function we have to actually just written this view view is post create yourself so if we reload this thing so this is the at first page okay I mean we made some typos here but on outline it should be out lane okay instead of finally I think in phase talking good okay till load here nice look decent so I bet I just feel content feel whenever something someone click on post it should we make a first okay so now we have to tell the action page so if I go here so this is this is our route name for the action I mean for the story first store route force store so whenever we pass a full shakers to the Lara Bell star bar so Lara will solve our actually tracking something called cross-site request forgery this is called CSRF when we make a website by aroun using the rope ESP we generally don't concern about the security issue but Lara Bell is the interface level software I mean framework they think about lot of security shoots a Caesar is one of the sig one of the major security issue actually and it's a very elementary security issue I mean see a syrup no one can't make a forced other than you domain suppose you you do mean you name dot-com I mean only this Duman will be allowed in order to make a certain forced so using adding the CSRF token is pretty is in laravel just yet see a set up at CSRF that's all it will make are they talkin to your phone so we don't open you can't make any forced if i dilute here and if i click right button and be you face source they'll find out some token is added here this token actually came from server your server so whenever you force something first your server check whether this token and earlier the token which is centered from the server is same or not if there is same then your server is will allow you to update your content there so lectures sounds simple if you don't use this thing there might be some vulnerability issue so we'll go to our force controller will go to inside store method this is the store method where actually we'll get all the request data which actually collecting from the phone we just the Queen requests excuse me request say title so we say this this is the title if I click at first here we'll find out this is the title it actually getting from the this controller I mean store store method what we will do it's actually pretty simple we'll just you from the request variable we will get that data from form and we will store data in our model so our model name is forced we are creating a new first we'll just make a Aryan side so there is two column on its title so title will getting from request title and another one is content content so there so it actually make a post but think is think about it someone submitted their form without putting some value inside this form so that could be error he will get error so before inserting in our form we actually have to billeted this form data so easily we can build it in laravel something called Billy Depp method so this debilitated it takes two parameter the first parameter is request you request and then second parameter is an array of rules so rule is say I am telling the title you are passing it is required and the content you are passing this is also required so two things is record we can add a another argument like minimum character will be say three character and for the content meaning character will be say Jane character excuse me that will be five character actually so suppose we are echoing something here say return raga it's our capital u you may understand I mean if it's returned akka that means our bill addition is successful if it's not written indica that miss our bill addition is not successful it's a kind of childish why checking anyway so post create so if I click on it forced I am NOT getting Daka but if I putting some title here and if I click at first I am getting data so I mean it's bill addition in done so thing is why did those thing is bullied it or not belated I'm not checking here in this create the created blade do PHP file so I have to check this thing if there is some validation error I have to show to users that you already miss you title you already miss your content so it's also pretty simple I'll go to the create blade what PHP again so before form I will checking Joe either this form I mean user has some error or not so it's called using if statement I can check if errors if there is some errors okay errors all actually if there is some errors this block will be executed so a lot a lot danger Shoei very dilute here again if I click on at first you'll find out you have some error okay so what is error we have to eat iterate over all the error so it's also simple just for each error all has better and for each okay so if I click on at first now it's showing the title face is record subside giving a little below suppose a in content also a so it will give me the difference the title must be at least three characters the content must be at least 10 characters so this is the magic of laravel really easily we can actually build a tower form data if we put in appropriate title and content it will update our first table so after creating this data I should redirect him to the index page so I'll just tell written redirect and why we want to read it this is a route post index page now go to create page again so I'm making title this is my first post so I was I put some lorem ipsum data here and if I click on at first it's sexually hosting successful if I go to the bottom this is my first post this is the first this is my first so we successfully we have been created but thing is whenever we clear something and if I go to home page we have we will get this thing in the bottom of this page so this is not a accepted behavior so we have to loading all the forced actually in descending order so we'll go to the index version this is all forced so instead of all we are using so order by ID and that will be a descending order if I reload this page now it's different this is descending order this is my first and this is 31 number first so another thing you may find out here is about 31 first so this is also not convenient I mean loading the 31 post in a single that would be better if we loading only 10 first so it also pretty simple in laravel instead of gate I will tell page in it so it should be 10 now we will go to the indexed or belated PSP after porridge we will link the rest page post links using post links function so if I go to the bottom so this is okay I have to give some margin top margin of say 4 so that's all so very simpler way we can make resonation functionality in our page so 3 things done we can create force we can store force we can read a single forced we can read all the first now our edit part and alert part is slept so next to the each post I will add a delete an edit button so after here I will make another anchor tag so that will be for Eddy so for the editing this is for started it and it takes a one an argument the argument will be forced ID so I am telling it said it class will be taught on it's about on info if I reload here so if I click her ready it will take me to the edit page what didn't make our edit page so it's showing nothing currently okay no now I will let the delete button here so in case of delayed you may find out it's kind of different method it's not a great method so I can't send to the delete route using the anchor tag I have to use the form method will be forced and action will be action will be forced to destroy it out and it will also take a one-parameter when is post ID I mean which forced it I'm going to destroy and we have to pass the see a set up token since there's a form data and another thing it's do it's a method is forced in from the HTML we can pass only Gator post method but it actually a delayed method so Laura will has some helper function called method directive Here I am telling this it's a delayed method I think they're self so I reload this page excuse me I have to add a button it's a bottom typhus submit class Barton Barton danger so here would be delayed if I reload this page so this is the delayed so since form is a block level element it get down from this earlier line so I have to make it the inline block class display:inline-block let's say boo chef class very alert this page now I'd become in the same line this this is my first ball post if I click here it actually going this route the force 31 so we have to tell the rebel we want to delete this thing so I have to go to the force controller I have I have to go to the destroyed method so here we already have forced we'll just delete this post so after deleting first what should I do I mean why should I go will redirect back to the index page if I suppose click on delete it actually deleting if I click on delete it's deleted so that could be a good give a user indication either you should really want to delete this thing or not I mean that's kind of a lot so we can easily put this thing so I have to go to the index dot belated PHP on submit I'm returning a confirm box let this post so if I reload this page again and if I click on delete it it actually asking me are you sure your hunter they delete this post if I cancel this thing it won't delay if I click on delete it will delete so for the editing I will go to the Edit blender PSP so edit and clear will be same so I'm coughing whole thing from created blood-red PSP infesting inherited PSP so the only one different will be this route this is from action is out that force would store but for the editing it actually post dot update and another thing is method is food there will be forced store method will be put like instead of add a first update the first and as submit button as well object the post and it will loading with the earlier below having the hole below so bill will be post title I mean gold below and insert this content so in between text area alright forced content okay in between texts today you shouldn't put any other space otherwise it will make a space in your text area box so first content now I have to load this edit page I go to the first controller edit so we'll return Bo so beauty sets in post edit and I'm going to pass post compact okay so earlier I you used to pass using the area and this this compact forced actually make those area so if I reload this page again and take a look to the edit page so this is their it pays okay we don't have title it should be inside this input field not in level if I click edit again it's loading with edit page so the last thing for the cloud is updating this part so if I click on operate it should be update so if I click on update it actually doing nothing we have to change the this thing instead of post it will be update and we have to pass the ID post id so I'm reloading this again if I click on update first we are getting this update first page so current update first is empty post controller object so here if you look if you remember the store part this is the request which actually give me the form data and this is the forced itself this forced title request title post content would be my request content there so excuse me it will be semicolon so after that I will just save this thing redirect back so suppose I had to then they click on update first now it's updating so either this thing operating or not I should keep user indication that your post has been updated so it also we can give this indication using the session session flash same message you post now in edit pitch I can use this session so I'm go to the Edit bloodroot PSP so before forum I was checking fast if it has a session or not if Xiao chuan has message obsession has message and it obsession has message what should we do we will give him users a alert that you're forced has been successful so deep toward alert successful that'll be session forget message alert success and click on edit so instead of three I put for update first you first have been updated successfully that's all so or create read update delete everything is done so thing is create an update I mean edit part it should be done by only the Authenticator not as usual user can do that so laravel comes with built-in authentication our crowd for totally done so authentication is pretty easy in laravel so just simple PHP artisan make what the simple common make the built-in authentication quickly now authentication is done so now if I go to home page if I go to the localhost $8,000 in and registration so so I click here register so my name is Paulo email address below the training at the rate of gmail.com password is hello okay what should be more than five character secret secret you are logged in so up to logged in I mean their home but it should be in the first place actually in current state anyone can create first update post and delete first so we you let authentication in those out so that only authenticate user will able to create update and delete first so we will go to the first controller so we are now inside this post controller will make a construct function which actually authenticate our all of the method public function TR you city construct so we are telling this module are auth so what actually this function will do so we know the construct about the construct function in PHP it's a magic method so before loading any of the function it actually that loading the construct method in the construct matter method we are telling that before loading any of the method we need the authentication so there's all pieces are pretty simple but thing is we need authentication for create update delete such kind of things right so in this case we are telling except we need everywhere authentication but only two places where we don't need authentication one is index here we'll only the method name another one is sure this space don't require any authentication this is the first I can visit this post if I click on create first it will take me to the register page I mean login page so this is the basic functionality of the authentication okay so here I should put a logout button from higher user can log out from this post page another thing after login user should redirect our four space not the home page so this do thing I have to make functional so first is log out log out should be in the mustard red dot PHP so before workout I want to show something inside terminal TSP partition route list so you may find out this is the log out so log out is a method is forced it's not a gate method it's a forced method so we have to AC block out functionality through the form not using the anchor element after create first I will put the log out button so I'm making a form so form action will be no lockout method will be forced CSRF button I think girsl if I D load this page this is the log or thing so so log out log out generally people keep blogger in the right side so and another thing form is a block level element so we have to make the display:inline-block class display:inline-block float now if it'll load this page so this is the logout button so the thing is when should we show logout to the users when you are already logged in so here I will make another if condition if user is logged in that time I will show those thing at what if user is authenticated else I will show the another thing so this is very convenient directive authentication and else and authentication so else so hein every user do not logged in I will just show him the login page so it will be anchored to okay.i for the quicken navigation I am making such kind of silly things but in real life when you make any project you shouldn't use such kind of navigation you should go with the bush up default navigation you just coffee from bush even reuse their navigation there so so if I reload this page again excuse me there will be end of my spelling and okay so this is logging correctly clogging it will take me to the login page polo in depth in my password is secret so now I am logging and I have a logout button so now I can access any page on page I can edit things I can have great things I could create any forced there so I can do anything since I'm logged in user so if I log out so route actually a PSP method so it should be inside curly brace I should back to this page so suppose if I click on logout now I am love it if I click on login say I can keep giving my name again and password is secret the thing is after login it will take me to the home page but after login it should be take me to the first page so I'm opening something called register controller resistor controller here a variable call I mean property is called redirect to redirect to so I'm telling after after making registration I should redirect to the forced-air as well redirect - should be I mean after login successful it should read it to the first page so if you log out here so try to log in again follow the train at the rate of gmail.com secret so there so can climb in my first page there is no way to know about who actually logged in so that that would be good things if we show the user's name who actually the authenticated right now so this is the revision we need to go to the master taught later PHP file so before logout I'll just give the user streaming authenticated user name inside double curly brace Oh user name this Auton user it actually give the authenticate user so from the authenticated user I will just show the name of the user so if I reload this page it will show the name suppose Polo tab so if I give a hyphen or a five character how can you run this application in your machine first you should download this thing so if I go to the download folder so this is the download folder I extract this thing so now I open this file in my terminal so first thing I have to do I install all the bender file composer installed so it installed the bender file now I have to open this project in my sublime editor I make a dot in file dot E and B and coffee everything from the dot a and B dot example when my database name will be blog say block to username is root password I don't have any password so I'll go to my my sequel create database block to now I have to delete old configuration PSP artisan cache clear PSP partition config clear PSP partition key generate now I can migrate PHP artisan migrate and now I can see data PSP artisan DB C now I will run the development server by PSP a distance R so if I go to the local host 8080 Belle and if you want to know further about Laura Bell you should visit the laravel come and go through the documentation and if you are a visual learner lara a site called are accustomed you can visit here and they have lot of tutorial and most of the tutorial is free actually though it's a and a paid side the things I bought laRocca's they said made by Jeff Priory I think if anyone asked me who is the best trainer in the planet I will tell Jeff player is the best trainer you can't get sus kind of trainer in the whole world so if I click on browse down there are series most of the series is paid but to learn horrible most of the series um for the beginner most of the series is free so you can check out this site as well thank you for watching these videos and take care
Info
Channel: polodev
Views: 25,403
Rating: undefined out of 5
Keywords: laravel 5.6, laravel, laravel crud, create read update delete in laravel 5.6, authentication in laravel 5.6, pagination in laravel 5.6, laravel laracast, php artisan, laravel blade, laravel mvc, laravel tutorial
Id: wvCDej8Cf9Y
Channel Id: undefined
Length: 76min 10sec (4570 seconds)
Published: Sun Mar 11 2018
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.