<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Rohit Adhikari]]></title><description><![CDATA[Rohit Adhikari]]></description><link>https://blog.rohitadhikari.com.np</link><image><url>https://cdn.hashnode.com/res/hashnode/image/upload/v1650706323750/VXv-qIH6a.png</url><title>Rohit Adhikari</title><link>https://blog.rohitadhikari.com.np</link></image><generator>RSS for Node</generator><lastBuildDate>Wed, 15 Apr 2026 18:11:57 GMT</lastBuildDate><atom:link href="https://blog.rohitadhikari.com.np/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[PHP Laravel Tutorial for Beginners 19 - Finishing File Upload]]></title><description><![CDATA[hey what's up guys welcome back to our blog and welcome to this blog so this is the last part of our laravel for beginners tutorial and in this blog we're going to continue working on with our image feature so in the previous blog we have added the d...]]></description><link>https://blog.rohitadhikari.com.np/php-laravel-tutorial-for-beginners-19-finishing-file-upload</link><guid isPermaLink="true">https://blog.rohitadhikari.com.np/php-laravel-tutorial-for-beginners-19-finishing-file-upload</guid><category><![CDATA[PHP]]></category><dc:creator><![CDATA[Rohit Adhikari]]></dc:creator><pubDate>Thu, 07 Jan 2021 06:49:00 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1650705944352/5-RfwcXvB.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><a target="_blank" href="https://1.bp.blogspot.com/-P6XAzyhwufI/X7M6Xa6hdpI/AAAAAAAAAcg/zjyC1PKMgtA9bd3F0VuM1RAKmT4tpxBygCPcBGAYYCw/s1920/Untitled%2Bdesign%2B%25281%2529.png"><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1650705942039/sEn6JgCJYN.png" alt /></a></p>
<p> hey what's up guys welcome back to our blog and welcome to this blog so this is the last part of our laravel for beginners tutorial and in this blog we're going to continue working on with our image feature so in the previous blog we have added the display image and actually added the feature of uploading an image by creating a post so when adding a post we can have we now have the option to browse an image and then include that image and save that into our database so now let's continue working on with this so if we try to view the actual post so we want to also add the image here and the individual post so let's go back to our code editor and try to add that so this is the index that played that PHP and then we're just going to open up the show that yeah show that played that PHP so in here we have displayed we're displaying the post title and the post body of our post so again we're just going to add the image on top of our post so in order for us to do that let's just add a div here so this will be I think before the body tag so Dave and then this hope this will be row and another column or then for a column so called MD shelve and then we're just going to add the image here where you can just copy the tab coming from here so and then the width is hundred-percent and then we're getting the actual or the physical image coming from our cover underscore images directory so let's try to preview this in refresh so now we have the image so the title and then the image of our post and of course the body of our post and then the meta tag meta information with just a written on with a date okay so another thing for this feature is that we need to add this in our create or edit because for now we don't have the element to edit or update the image that has been uploaded so let's go back to our code editor and God the final element in here so the same with the create that laid that based me we're just going to copy this arm group and then Eddie near end it that way that PHP and just before the submission of the page you can place the cover image file input element and then of course we need to change the something here for our Inc type so it should be of course multi-part for data so we're just going to copy this one and paste it here so Inc type equals this multi-part slash form - data so we're just going to save this and refresh our page to show that we have already added the input file element so refresh so in here we have now the browse file input element we need to add some logic into our edit function from our post controller so let's go ahead and try to open up or post controller that page B and inside here in our edit function so we're going to add yeah the logic of our edit function or actually we're not editing the function edit we're actually going to modify the update function so all we have to do here is I think we just have to copy all the logic that we have in the store function so validate and then update okay so we're just going to paste here the validation and of course all the logic that will handle our file upload so this is going to be a bit different from the store logic because we're not going to have this line here which means that we don't want to update when the user has not uploaded the image so remove that and then we're just going to have another check here if the user has submitted the file or uploaded the files of the request if the request has fine so another cover image here that's the name of our file input element and then we're just going to get or set the cover image by using the file name to store so okay and save this so refresh view first opposed so we have here the post and then we have the actual post and then reckon edit that one and if we try to submit without selecting any image then we can just update the post but not updating the image right here but let's try to update the image so let's browse another image and then open and then submit post has been updated and as you can see the image share has been updated also because we have updated or uploaded an image coming from our edit page so the next thing is or delete okay so if we try to go to a post and we have this delete so whenever we have to delete this post we want to actually delete also this file coming from our project so if we try to open up or our project in our browser or M in our file directory we can see that we have here the public and then storage and then the cover images so this are the uploaded files in our project right so whenever a user wants to delete the post we we would also want our project to actually delete this files right here so in order for us to do that let's go back to our post controller and edit the delete function or destroy function right here so we're going to bring in first the storage library so if we're going to use illuminate slash support and then back slash massage backslash storage okay and then in our destroy function below so we're going to check if the user has uploaded the file for this particular post so that will be if this post cover image it's not equal to it's not equal to host and then user I mean not equal to no image that JPEG or jpg so this will be our default image when the user has not uploaded a file for their particular post so we don't want this to be deleted if the user hasn't uploaded a file so this will be storage and then delete so we're going to public and then cover images and of course the actual file name of our cover image so save this and then try to delete this post post has been removed or 
%%[advertisement]
removed and as you can see the image from the cover images directory has been deleted one last concern also is if we try to go to our blog and add posts so say for example we're going to add first post here respose are the first post and then we're going to browse an image okay submit and also another one so second post body of second pose and then we're not going to browse or upload an image here so submit so as you can see we have here a broken image icon which means that the user has not uploaded image for this particular post so we don't we don't want that and we want to have a default image here so our default no image so let's go and search for a new image picture so that we will be able to have a default no image here so after finding a default no image so make sure to copy and paste that in your cover underscore images directory and this is what I have chosen from from new no image default and the file name is that J PG so we should be able to display this in our page so make sure to change this also to the right file extension and then save and then refresh so there you go we have now the no available image as our default image of our posts so I think that's all there is to it for this tutorial and this will end our tutorial for beginners tutorial and I hope you have learned something from this series and in this blog so thank you for reading our blog</p>
]]></content:encoded></item><item><title><![CDATA[PHP Laravel Tutorial for Beginners 18 - retrieve images from database]]></title><description><![CDATA[hey what's up guys welcome back to our blog and welcome to this blog so in this blog guys we're going to continue working with our file image upload so in the previous blog we have laid out this logic here which is we're checking if the user has subm...]]></description><link>https://blog.rohitadhikari.com.np/php-laravel-tutorial-for-beginners-18-retrieve-images-from-database</link><guid isPermaLink="true">https://blog.rohitadhikari.com.np/php-laravel-tutorial-for-beginners-18-retrieve-images-from-database</guid><dc:creator><![CDATA[Rohit Adhikari]]></dc:creator><pubDate>Tue, 05 Jan 2021 06:45:00 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1650705956311/J7j1Ezq-d.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><a target="_blank" href="https://1.bp.blogspot.com/-P6XAzyhwufI/X7M6Xa6hdpI/AAAAAAAAAcg/zjyC1PKMgtA9bd3F0VuM1RAKmT4tpxBygCPcBGAYYCw/s1920/Untitled%2Bdesign%2B%25281%2529.png"><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1650705954201/PZo8L893G.png" alt /></a></p>
<p> hey what's up guys welcome back to our blog and welcome to this blog so in this blog guys we're going to continue working with our file image upload so in the previous blog we have laid out this logic here which is we're checking if the user has submitted a cover image or uploaded an image and then we're getting the filename and extension here and also we're getting the file name from the actual image that has been uploaded and now let's continue adding to this logic so we have here the file name and then the next step is to get the extension okay so in order for us to do that we need to add a new variable extension and then by using the request object we're going to use the file method and then cover image and we're going to get the original client extension okay and next is we need to define a file name that we're going to store into our database so file name to store that will be path and then or first we need yeah file name finally file name to store equals the final file name that we got from the actual file and then we're going to concatenate with an underscore and then time and then another concatenation with the extension so this will be extension we're doing this because we're just we're just trying to avoid if say for example the user uploads a file or a an image with the same file name so in order for us to some of that is we we get the file name and then we're adding underscore and then we're adding the time so it won't be a problem for us if the user will upload files or image that has the same name and the last part of that is we need to actually upload the image so that will be upload image we need to get the path and request and then file again cover image and need to store this store us we're going to store this on our public folder so public and then cover images we need to create this directory and then the new file name will be file name to store and now whatever the user upload the file so let's try to see database resources and then we have here the storage and an app and then we have this public folder so it will create the cover underscore images directory here but the problem is this public directory is not accessible when you try to open up this directory in your browser so we need to make sure that all the changes that we are making here is reflected to the click folder here because this is a accessible to the web browser so in order for us to do that let's open up our terminal and we need to run a command to link this storage a public folder into our actual public folder so the command for that is PHP artisan and storage then link so there you go the public storage directory has been linked so whatever changes that we're making here in our storage file or storage directory will be reflected here in a public directory now the last thing that we want to do here is to actually save the file name to store so that will be post and then the cover image equals the file name to store ok save this and let's try it in our browser so refresh and then add post so you post with an image this will be the body of the post with an image then we're just going to select a certain image and open and then submit so we're getting an error here the cover image must be an image so I think the problem with this is here in our create laid that PHP so multi-part slash it should be form data so there you go save and refresh so new posted image as body and then browse for the abstract image and then submit so we're getting guideline original image does not exist so we have a typo here so I think we're going to use instead of great client original image so we're going to use get client original name so that will be post controller and get client original name so right then posted image test browse the image and submit so we're getting path in info underscore file name so undefined constant so we need to change that instead of just file it should say file name let's go back and refresh just to make sure and then new post test and browse the image and then submit so again we're getting the get original client accept extension that's not exist so I think we also have a typo so we're just going to copy this get client original extension so let's go back to our code editor and replace this with get client original extension so save that let's go back refresh and save another one so I hope it it will be successful this time so browse and then submit so there you go post created so the new post with image has been created and the next step that we're going to take is to display the image in our show post and also in our new post with image where we can actually see the individual post since we have successfully uploaded an image we can see here in our storage and then the cover image direct has been created and we can see here the link of our storage directory with also the cover under underscore images with the actual file or image that we have uploaded so let's try to view that in our PHP myadmin so in here so post and we have new post and then the buggy and of course the link or the file name of the uploaded file and actually we're just going to get rid of this records with no cover image so we're just going to delete that and let us now try to display the images coming from the database into our show and index plate that by HP so that will be resources and then views and then index that PHP so we have here displayed the post so before that it's just going to add a new live road so this is just a bootstrap tag and we're going to add another DEATH this will be column MD for and also another one for another column so it should be 8 and we can just copy and paste this here and also you can you can remove this I think and just remove that and here we need to display the image so that will be image and then the source is coming from the storage directory and cover images in the filename so this will be coming from our post and cover image and I'm just going to add a style here for our image which is the way it should be 100 percent 100 percent so save this so refresh and then log so we're not getting any post here and if we tried to go to our post we have one record so let's try to check our code here so index that way dot PHP and we have here if greater than one and we have one record right now so it should be greater than zero so refresh so there you go we have the image and then we have the title here and also the return on information so in the next blog we're going to continue working on with this feature and also we're going to add that in our blog list and individual posts here and also we're going to add the feature in our edit post where we can also edit or update the images so see you in the next blog thanks</p>
]]></content:encoded></item><item><title><![CDATA[PHP Laravel Tutorial for Beginners 17 - Laravel File Upload Example]]></title><description><![CDATA[hey what's up guys welcome back to our blog and welcome to this blog so this is part 17 of our laravel for beginners tutorial and as a sort of review in the last blog we have added the access control for the post or blog post available in our project...]]></description><link>https://blog.rohitadhikari.com.np/php-laravel-tutorial-for-beginners-17-laravel-file-upload-example</link><guid isPermaLink="true">https://blog.rohitadhikari.com.np/php-laravel-tutorial-for-beginners-17-laravel-file-upload-example</guid><dc:creator><![CDATA[Rohit Adhikari]]></dc:creator><pubDate>Sun, 03 Jan 2021 06:42:00 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1650705966096/T6ZfDrkgd.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><a target="_blank" href="https://1.bp.blogspot.com/-P6XAzyhwufI/X7M6Xa6hdpI/AAAAAAAAAcg/zjyC1PKMgtA9bd3F0VuM1RAKmT4tpxBygCPcBGAYYCw/s1920/Untitled%2Bdesign%2B%25281%2529.png"><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1650705964120/zI4B1T3o8D.png" alt /></a></p>
<p>hey what's up guys welcome back to our blog and welcome to this blog so this is part 17 of our laravel for beginners tutorial and as a sort of review in the last blog we have added the access control for the post or blog post available in our project and we also limit the edit and delete buttons for those owners of the actual post so in this blog we're going to add a file upload so in here so for example if we add post so in here what we want is to add a file upload where we can actually upload an image so we will be able to do that and let's try to go back to our code editor and open up our create that laid that PHP and we'll try to add the file upload capability in our project so under resources and then use post and then create that blade that PHP so we have here deform that enables us to add a post so we're just going to add here the element for our file upload so in here we need to add the live with class form group and of course we need to add the actual form element which is we're going to use the laravel collective's for that so form and then file and then we're just going to name it as a cover image okay so in order for us to submit or upload the file in this particular form we need to change also the ink type for this form in this particular part we need to add another which is the ink type for our form and then it should say multi-part multi-part /data and then save let's try to preview that refresh and then you can see here the file upload element where we can browse the actual file in our file system but if you try to select an image here and then submit it's not it's not going anywhere for now it's not saving to our database and it's not saving into our project because this is only the user interface and there's nothing logic or there's no logic behind this file element so in order for us to have the actual logic we need to go back to our auditor code editor and open up the controller so HTTP controllers and then inside our post controller but before we forgot I think we need to add first the attribute or the field into our database let's open up our database and try to add the field first by using our migration so I'm just going to show you here so inter post structure and we don't have yet the field for our image or cover image so we need to add that by using our migration so open up the terminal first and here we need to run the command PHP HP artisan and then make migration and then the name of this migration is odd cover image to the post okay okay so the migration has been created so let's open up it here in our database and then migrations so odd cover image to post and we need to add logic here to actually add the cover image attribute so table and then string this will just add the cover image into our post table and of course in here we also have the down functions okay so we're just going to drop column in here so drop column and then we're just going to say cover image and after that we need to run the migration so PHP artisan and then migrate so migrated if you try to go back to our page me my admin and then refresh our structure so we can see here the cover image field or attribute so now let's go add the logic to actually upload the file into our file system and also save the file name into our database so in our file upload as I've said there are two things that will happen so we need to add the string path or a dealer the name of the file in here in our cover image attribute or field and then we also need to upload the actual file into our project so now let's go back to our post controller open up our post controller and and here we need to modify let's just go close the terminal for now [Music] let's just close this and then we need to modify the store function so we need to add the validation for our cover image first so the cover image should be image and then it is nullable meaning the user can have the option to upload or not upload a file for their cover image and also we're going to set the maximum size of the file in to 1999 because most common page settings they're allowing only 2 MB of file upload so we're going to set the maximum size of our image into 1999 which is almost 2 MB or 2 megabytes and then in here we need to set up few things so we're going to handle the under file upload and the file upload and in here we have to say request and then pass file we're just going to check if the user has opted to upload the file so else we need to set the file name file name to store yes/no image that JPEG so this isn't going to be the default image for our user if he has opted to not upload cover image for for himself so this will be the default so if the user has opted to submit or upload the file so it should say here we need to get fire we need to get the file name with the extension in here so get file name with extension get file in with extensions okay and then it should say file name with ext is constant request and then the file which has the name of cover image and we're just going to get client original original image okay and then we're just going to get just the file name of the file in order for us to do that so file name and then path info and then we're going to pass in parameters in here finally name with extension and we're just going to get the part info underscore file name so I think this blog is further along so we will continue working on with this file upload in the next blog so see you in the next blog thanks</p>
]]></content:encoded></item><item><title><![CDATA[How to Get Free Ssl? Why You Need Ssl?]]></title><description><![CDATA[**_image source:- [pixabay](https://pixabay.com/illustrations/https-web-page-internet-security-3344700/)_**
Welcome to the New Blog Of This Site! We are Testing That This Site Visitor Like Or Not This Type Of Content. We all Know Ssl Is very Importan...]]></description><link>https://blog.rohitadhikari.com.np/how-to-get-free-ssl-why-you-need-ssl</link><guid isPermaLink="true">https://blog.rohitadhikari.com.np/how-to-get-free-ssl-why-you-need-ssl</guid><dc:creator><![CDATA[Rohit Adhikari]]></dc:creator><pubDate>Thu, 31 Dec 2020 18:15:00 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1650705975591/m-PehGKWI.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><a target="_blank" href="https://1.bp.blogspot.com/-qFRyTPaKRvA/X8Y4_-8xhWI/AAAAAAAAAd8/C4KrQt8wSao2RUJBaosuwmJg03Srb6SLQCLcBGAsYHQ/s1920/https-3344700_1920.jpg"><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1650705974415/bsdviPFQ1.jpeg" alt /></a></p>
<pre><code>                      **<span class="hljs-selector-tag">_image</span> <span class="hljs-selector-tag">source</span><span class="hljs-selector-pseudo">:-</span> <span class="hljs-selector-attr">[pixabay]</span>(<span class="hljs-attribute">https</span>:<span class="hljs-comment">//pixabay.com/illustrations/https-web-page-internet-security-3344700/)_**</span>
</code></pre><p><strong>Welcome</strong> to the New Blog Of This Site! We are Testing That This Site Visitor Like Or Not This Type Of Content. We all Know <strong>Ssl</strong> Is very Important Part Of All Site's Which are on Internet If They Want To sade Their User's Data While Login and Other thing's.</p>
<p>But Many Site which are probably Runned By students Like Me can't Afford Premium Hosting And premium SSL. But Also Many students Try To Make Their Site On Blogger Because It's Free and Also From Google Like Me So they Don't Need this type Of topic Because They can activate Ssl From Their blogger Dashboard.</p>
<p>But also Some people Like WordPress Instead Of Blogger And Use That On Free So What About That People As well Many Free Hosting doesn't Gives You Ssl On Free You Need to Get it From Outside So in this topic we're going To Discuss About how to get Free Ssl. First of all We will see about infinityfree Free Hosting.</p>
<p>Infinityfree Hosting:- This is On of the top and suggested Free Hosting Providing Site. But Can i get Free Ssl From this site? Yeah! Infinityfree Provide Free Ssl that expires on 3 Months (You Can Renew It After Expired) and also You Can choose Ssl From Let's Encrypt And GoGetSsl. For That You Need to login On infinityfree And click On menu you will see A Menu That Names Free Ssl click On that add your domain Name and Click on Request Ssl Certificate Then add Cname and The address From VistaPanel Then After That They Will Verify That Cname If everything Is Done then you will get your Ssl Certificate Then you can Install It from Vistapanel!</p>
<p><a target="_blank" href="http://freessl.space/">Freessl.space</a>:- <a target="_blank" href="http://freessl.space/">freessl.space</a> Is one of the top Free Ssl Providing Site. <a target="_blank" href="http://freessl.space/">Freessl.space</a> Provide Free Ssl Of GoGetSsl For 3 month then you can renew it then you need to verify domain with cname records or using site mail (Professional Mail).</p>
<p>At the end we Have Discussed about this two Site Which Are Providing Free ssl For Everyone. So enjoy with free Ssl Also There Have Many Site That provide Free Ssl But I personally Use these site To Get Ssl On My some Sites Which Are Not Hosted On Blogger And Also If you're Developer Or have a plan how to promote you <a target="_blank" href="http://freessl.space/">freessl.space</a> Ssl Then You can Apply To be Reseller On <a target="_blank" href="mailto:info@freessl.space">info@freessl.space</a> With Details. Thanks For Reading  ️😊 And Happy new Year</p>
]]></content:encoded></item><item><title><![CDATA[PHP Laravel Tutorial for Beginners 16 - How to Add User Access Control]]></title><description><![CDATA[hey what's up guys welcome back to our blog and welcome to this blog so this is part 16 of our laravel for beginners tutorial series and in the previous blog we have worked with user authentication and we have laid the modal relationships and in this...]]></description><link>https://blog.rohitadhikari.com.np/php-laravel-tutorial-for-beginners-16-how-to-add-user-access-control</link><guid isPermaLink="true">https://blog.rohitadhikari.com.np/php-laravel-tutorial-for-beginners-16-how-to-add-user-access-control</guid><dc:creator><![CDATA[Rohit Adhikari]]></dc:creator><pubDate>Thu, 31 Dec 2020 04:26:00 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1650705986133/yfUO6G2jr.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><a target="_blank" href="https://1.bp.blogspot.com/-P6XAzyhwufI/X7M6Xa6hdpI/AAAAAAAAAcg/zjyC1PKMgtA9bd3F0VuM1RAKmT4tpxBygCPcBGAYYCw/s1920/Untitled%2Bdesign%2B%25281%2529.png"><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1650705984588/r8YQk7oyo.png" alt /></a></p>
<p> hey what's up guys welcome back to our blog and welcome to this blog so this is part 16 of our laravel for beginners tutorial series and in the previous blog we have worked with user authentication and we have laid the modal relationships and in this blog we're going to discuss about how to actually implement the user access control so basically we're just going to add a feature that will just enable us to control which pages will our user be able to access so in here let's try to see we have here in our project or home page of our project and as you can see we can always access the post create so if you go to post and then great so we can already create a post even if we have or we are not logged in right so apparently we're not login with our account and we can create certain post but we don't want that the user should login first before they can create a post so also you can see that if we go to blood and then click the post we can see the buttons and edit and delete even if you are not logged in as a user so again we don't want that we want the user to login first before they can modify you can delete and create a post so in order for us to do that let's go back to our code editor and try to modify our project if we go to the controller of our homepage so app and then HTTP controllers and then home controller we can see here we're adding the middle we're both in this construct method so we're just going to copy this for our other con controllers so copy and then we're going to do the same thing for our post controller so that's post and then we're just going to paste the construct method or function coming from the home controller class again we're doing this just to control the access of the non log end users so if you try to go back to our browser so if you try to go to slash a post and then create so we won't be able to create a post right now and it booted us out from the create forum or create post form so it says that we need to log in but there's a problem with this because if you try to go to our blog so it says that we need to login just to view the blogs right so we don't want that and we just want to limit the access when we try to create a post so let's try to accept the other pages for that so in here we need to pass in an array so this will be an array of pages that will be accepted so accept and then the array or the actual array of pages so it's going to be the index and of course the show page sort of say that and go to our browser so we should be able to view the blog so this are the post and we can you just we can't access the create for now right because we're not login oh should be post and then great so try to log in by using our account so log in there you go we can access deep great post and now let's just solve the problem with the individual post if you try to go to a single post you can see even if we get lag out from this page love and then post we can see the edit and delete buttons and we don't want that we just want to see the post without these buttons edit and delete so in order for us to do that let's go to the post so that's where is it resources and then views and post and then show so where's let's go to this part right here when displaying the edit and delete button so I think we're just going to add a certain if statement here so oath and then not guess and then let's just say and if here so basically we're just limiting the access to these buttons and it should be gone there for now so if you are not logged in and you go to a single post you can not edit and delete the post but if we try to lag in by using our account so basically we should be able to have the yeah edit and delete button so log out and go back to that particular post no edit and delete button but also we need to change something here because we need to only show those edit and delete buttons if you are the owner of that particular post so let's go back to the show that later and in here we need to add another if so that will be if and then o'the user so basically we're just going to check if the currently logged in user is the owner of this particular post so that will be post and then the user ID so remember we are we added that particular attribute user ID by using the migration so and we're going to end the if statement here so there you go so you won't be able to access the edit and delete button even if you are logged in if you're not the owner of that particular post so so for example this one so we're not the owner or the currently login user is not the owner of this particular post so but this one is the one posted this particular post so he should be able to edit and delete this post but we need to solve another problem here so as you can see we can edit this particular post but if we try to have like five here this is a post from another user so right so we don't need or we don't want this actual user or this particular user to be editing other post or other users post so what we need is to go to our post controller and in our edit in our ad function we need to have a some sort of check in here so below this one we need to check if the user or authenticated user meaning the login user ID is not equal to the post user ID so again we're just checking a this particular login the user is the owner or not the owner of the post so if is not the owner of the post so it should return read the wreck and then we need to pass in the post it should redirect to the post page and then with an error message so error and then it should say an authorized an authorized page okay so save that and let's go back to our browser and try to go to blog and then first post so the ID is 6 and then edit so if you try to have or put 5 in here so it should say or it should redirect into the post page but I think we don't have the error message here so let's try to add that in our layout so that will be from the layout and then app that laid that PHP we have to include the error messages or messages here in our page so it should be here so in here let's just add the messages layout so include and then i NC folder and then messages so it will refer to the I NC and then messages that made that pay HP so save this and let's go back to the browser and host indeed and 5 so it should say an authorised page because we're not authorized to access this post or this particular post and we cannot edit this because this is not the post or this is not a post of this team so user so I think we need to do the same with the delete button also so let's go to the post controller and then we also have the destroy here so I think we're just going to copy the illogic that we have used in our edit function and paste it here in our destroy function so after that so post so if all user ID is not equal to the post user ID so it should redirect to the post page and with an error message of delete so I think that's all there is to it for this tutorial and in this case we have limited the users capability when it comes to the posts that do not belong to them so see you in the next blog thanks</p>
]]></content:encoded></item><item><title><![CDATA[PHP Laravel Tutorial for Beginners 15 - Model Relationships]]></title><description><![CDATA[hey what's up guys welcome back to our blog and welcome to this blog so this is part 15 of our larval for beginners tutorial and in this blog we're going to add or we're going to discuss the modal relationships so in the previous blog we've worked wi...]]></description><link>https://blog.rohitadhikari.com.np/php-laravel-tutorial-for-beginners-15-model-relationships</link><guid isPermaLink="true">https://blog.rohitadhikari.com.np/php-laravel-tutorial-for-beginners-15-model-relationships</guid><dc:creator><![CDATA[Rohit Adhikari]]></dc:creator><pubDate>Wed, 30 Dec 2020 04:16:00 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1650705996138/oSQ4Qy9Rq.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><a target="_blank" href="https://1.bp.blogspot.com/-P6XAzyhwufI/X7M6Xa6hdpI/AAAAAAAAAcg/zjyC1PKMgtA9bd3F0VuM1RAKmT4tpxBygCPcBGAYYCw/s1920/Untitled%2Bdesign%2B%25281%2529.png"><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1650705994340/bu0uBdz4n.png" alt /></a></p>
<p> hey what's up guys welcome back to our blog and welcome to this blog so this is part 15 of our larval for beginners tutorial and in this blog we're going to add or we're going to discuss the modal relationships so in the previous blog we've worked with the user ID so where we added the user ID to our database and the I think it's from the post so we've added our user underscore ID by using the migration and in this blog we're going to add the relationships relationship to this user ID to the actual users ID here in this table so that will enable us to only limit the blog's or the posts that are belonging to a certain user so so for example we're going to try to view the post so we all one or what we want is to only display the posts that are created by the logged in user in order for us to do that let's go back to our code editor and try to add the model in our models okay so let's open up our post modal so all we have to do here is to add a certain function so it is it is very simple to add relationships in laravel so as I've said all we have to do is add a function here so for example public function and then user and then return this and then belongs to the and then backslash user and the same thing with our user modal let's add a function here so public function and then post and then this should return has many relationship because a user can have many posts right so the user can post like thousands or hundreds of posts and let's go ahead open up our dashboard controller or home controller because that's where we were trying to display the post so in here we just need to get the user ID by using the oath and then user function and then supplying the ID or I think it's like that one instead of using it as parameter so user ID equals old and then user and then the ID attribute and then let's find the user fine and the user ID and then we need to pass in this user post into the home so that's squid and then close so it means that this post or this post are belonging to this political particular user supposed and comma and user post okay so if we go to the home home view so resources and then views and then home so after lagging in or after the user lag in so we need to display a table here that display or that will display all the posts belonging to the lag end-user so that's tabled and then class is table table stripe and then we're just going to define the headers or header for our table so that's eh and then I tell each and we're just going to add two other th here for our edit and delete button so th this is going to be just empty because this is going to be populated with ID or I'm in the edit and button edit and delete button so that's the H so in here I think you just need to check if the actual host at if and then count the post so if it is greater than 0 then we need to display the table right table and here we need to add the else and of course we need to say if the count of post is not greater than zero then we have to say you have no post no post and then and our if statement and if and of course in here we also need to populate the table rows so the title should be getting the title from the post so it's post and then the title of our post so there you go and then in here we just need to add the edit button first so a track and then the a track is post and then slash the post ID so that's basically post and then the ID and then we're just going to say slash Eddie and [Music] so just let's just add a class for this so class v TN v TN default before and then this should say it so let's try that refresh our page so let's go back to the home page refresh and then we need to log in so I think we forgot the user password let's try logging in so Tom Gmail that phone and then the password so log in we're just going to wait for a few seconds just to allow the log in so we have an error user not found in our home controller because I think we need to add that which one so home controller 27 home controller there you go so we need to add here the [Music] class so that's app and then backslash user okay let's try that save and refresh app user constant okay so I think we need to to remove the single code for that work and then refresh defined variable posts in home that laid that PHP so let's try to solve that home plain that PHP so it says here that we don't have access to the post for the actual post okay so I think we need to either it first in here to actually have the individual post so that's for each and then the post variable has single post and then let's just add the end of our for each here for each pair go so save and then refresh so we have here the new and updated view of our post so we can see the title which is post one post two and certain title of a post so let's try to add a new user so that in and then user 2 or make sure let's just say theme to solve and then team at gmail.com and then the password let's just apply a certain password okay and then register so as you can see the home or the location home it says you have no post because we just want the posts to show if the certain user lackin and then he has a or he has post so it should be displayed here but in case of our new user team so he has no posts or let's try to add a new post first post of team saw the body body of the post of teams so and then submit so this page displays all the post but if we try to go to the project application and then home it only displaced the first post or the single post out or a new user team saw so in the next blog we're going to discuss how to actually have the access control for this because we don't want the guests to actually create post and we just want the user to actually see his own post see you in the next blog thanks</p>
]]></content:encoded></item><item><title><![CDATA[PHP Laravel Tutorial for Beginners 14 - User Authentication]]></title><description><![CDATA[hey what's up guys welcome back to our blog and welcome to this blog so this is the part 14 of our laravel for beginners tutorial and in this blog we're going to discuss about user authentication but as a sort of review in the previous tutorials we h...]]></description><link>https://blog.rohitadhikari.com.np/php-laravel-tutorial-for-beginners-14-user-authentication</link><guid isPermaLink="true">https://blog.rohitadhikari.com.np/php-laravel-tutorial-for-beginners-14-user-authentication</guid><dc:creator><![CDATA[Rohit Adhikari]]></dc:creator><pubDate>Mon, 28 Dec 2020 04:07:00 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1650706006575/JuFtLgq7R.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><a target="_blank" href="https://1.bp.blogspot.com/-P6XAzyhwufI/X7M6Xa6hdpI/AAAAAAAAAcg/zjyC1PKMgtA9bd3F0VuM1RAKmT4tpxBygCPcBGAYYCw/s1920/Untitled%2Bdesign%2B%25281%2529.png"><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1650706004589/PqCHiwedn.png" alt /></a></p>
<p> hey what's up guys welcome back to our blog and welcome to this blog so this is the part 14 of our laravel for beginners tutorial and in this blog we're going to discuss about user authentication but as a sort of review in the previous tutorials we have worked with our create read update delete functionality for our project so as I've said in this blog we're going to discuss user authentication so as you can see we have here the land in register functions and if tried to go to our database we can see we have already created or populated our users table with the attributes ID name email email verified password token and the created and updated fields or attributes so let's go back to our code editor and try to add more features to our project and add the user authentication and perhaps the user access control to our project so let's go back to our code editor and let's try to see the views in the views we have already this file right so as you can see we have different options and different menus the home services blog the about and of course we have added the login and register links so that we will be able to log in and of course we will be able to register it to our project and for now let's just copy this because we're going to overwrite this file so let's do that by creating a new file as a sort of back up and let's start to open up our command line so that we'll be able to create the authentication or user authentication for our project so in here let's just type in PHP artisan and then make Colin and then the keyword oath and then let's just try to wait for a few seconds to enable the so as you can see we have here a problem come and make both is not defined so I think we have Oh so instead of using the artisan make oath so I think we need to run the command PHP artisan instead and then you I and then oath so this will enable the authentication or user authentication for our project and we have here a prompt that says the oath plug-in that laid that page review already exist do you want to replace it so for now let's just say yes because you want them to be replaced with a new version of the login dot PHP the way that page B email that PHP and I'm just gonna answer yes to this prompt verify so this will again override our old files so authentication scaffolding generated successfully so if we try to run our project right now let's say refresh ok so as you can see we have already alright or every than our our old files and as you can see we don't have any additional options here for our blog services and adding the post so we need to add that in our app that laid that PHP files so as you can see we have the backup for our app that blade that page we file and we have here the new one okay so all we have to do is just you can just copy the for example the link from here so starting from here to the the first navigation item for our home and then paste it here there you go and of course we need to add also the navigation for adding a post so you L left side of our navigation okay so we have here the option to add post and of course guys we can make the navigation bar instead of light you can say inverse just gonna remove this so navigation bar inverse and then save this one and let's go back to our browser and then refresh so as you can see we have added all the options to add post we also have the home services blog about and of course the login and register pages and as you can see we need to fix this display right here because I think it's not indented so let's go back to our code editor and try to modify that so index for our content so we don't have here the div container so we need to add that in our up that way that PHP file okay so we have here the content yielding of content but we need to add the container class or it could inner div with a class on container okay so this should solve the problem of the intention or the margin left for our project refresh so as you can see now the content is indented and if we try to go to register we can already we can already register here by using our names of our example Tom saw and an email let's just say Tom at gmail.com and then password okay and then register and as you can see we have redirected and so our home and prompted that we are now back in so you can see we have enabled the user authentication and the laravel takes care of all the intricacies of using the user authentication within our project okay now so we can close this and let's try to edit our home that played that PHP so instead of just showing your now login let's just say we can add a post here so that will be post and then click yeah great and a host and then we're just going to add a class for our button or link BT and BT and primary and let's just say here your love posts let me say this try to preview and then refresh so we have here the updated dashboard or home page then we can just create a post but if you try to do up in our database post suppose because we want to add the ID of the user that has posted the certain post so we need to make immigration for that at the attribute ID of our user so now let's add the migration for adding our user ID into our database table so in here you need to run the command aah we make HP artisan then make and then migration and then the name of our migration is add user ID to post ok so PHP artisan make Colin in the migration add user ID to post and it says it created the migration so if we try to go back to our file and then under database in the migrations we now have the migration add user ID to post ok so if you try to run our migration right now that nothing will happen because we don't have any logic inside the app and the down function so in order for us to add the ID so the user table in our database we need to have some logic here and also run the migration so inside here we need to say table and then integer because the value of the user ID is of integer type so user and then underscore ID and semicolon and of course whenever we want to roll back the changes that we made in our migrations we can just say table and drop column and then specifying the column user ID so okay so after that one save this and then let's just say PHP artisan migrate so migrating user ID post and it says migrated so let's track our page we my admin so inside here in our database we can see we have already the user underscore ID and for now let's just say it belongs to user 1 this particular post and also this one it belongs to the user 1 so it just it belongs to someone okay so now let's try to edit the controller for our post because whenever we need whenever we add a certain post we want the user ID or grab the user ID and add that along with the other information of the post so let's just go to http and then controllers and then post controllers okay so oh so inside our store function we just need to have the user ID or pass in the is ready so here post and then user ID equals and this time we're not gonna use the request because the user ID doesn't come from the user our I mean doesn't come from request it comes from the user both so it should say both and then user and then we're just going to have or you grab the ID hey and then save so here refresh at post then certain title of a pose new body of a pose and then submit so we have now the certain title of a post and we try to check the third post we can see that the user ID has been populated by value of 1 which means that this particular post belongs to the user with the ID 1 so I think that's all there is to it for this tutorial in the next blog we're going to discuss about access control for our post so see you in the next blog thanks</p>
]]></content:encoded></item><item><title><![CDATA[PHP Laravel Tutorial for Beginners 13 - Update and Delete record from MySQL in Laravel]]></title><description><![CDATA[hey what's going on guys welcome back to our blog and welcome to this blog so this is the part 13 of our laravel for beginners tutorial and in this blog we're going to discuss or we're going to talk about how to enable editing and deleting of informa...]]></description><link>https://blog.rohitadhikari.com.np/php-laravel-tutorial-for-beginners-13-update-and-delete-record-from-mysql-in-laravel</link><guid isPermaLink="true">https://blog.rohitadhikari.com.np/php-laravel-tutorial-for-beginners-13-update-and-delete-record-from-mysql-in-laravel</guid><dc:creator><![CDATA[Rohit Adhikari]]></dc:creator><pubDate>Sat, 26 Dec 2020 04:02:00 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1650706018089/Cgq9i-DB6.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><a target="_blank" href="https://1.bp.blogspot.com/-P6XAzyhwufI/X7M6Xa6hdpI/AAAAAAAAAcg/zjyC1PKMgtA9bd3F0VuM1RAKmT4tpxBygCPcBGAYYCw/s1920/Untitled%2Bdesign%2B%25281%2529.png"><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1650706016540/fOPBNgxVh.png" alt /></a></p>
<p> hey what's going on guys welcome back to our blog and welcome to this blog so this is the part 13 of our laravel for beginners tutorial and in this blog we're going to discuss or we're going to talk about how to enable editing and deleting of information or deleting of our data coming from our database so in the previous blog we have worked with our post or our blog right so we can now have or we can I will see all the posts coming from our database and of course we can also go into details by clicking the specific post in this particular page so there we go we have here the post 3 and of course we have post two with all the details and now let's try to add the added functionality and also the delete functionality of this particular post so if there are several post here on this particular page so we have an option to edit or even delete that particular post so in order for us to do that we need to go to our code editor and try to modify our show page so as you can see we have the resources the views and of course the page and we also have here the files for our post so we have here - oh that lady at the HP and in here we need to add a link so right after the written iron information so we need to add a link for our edit so let's just try to add furs and HR element to have a separation of these two elements they are small and of course the link that we're going to add so this link should redirect to post then the ID of our post and of course the Edit and then it should say edit and it should have a class VPN and VPN default so if you try to save this and go back to our browser and refresh so we now have the Edit link here and you try to click on this one we are being redirected to this page PK project that LOC slash post and then slash one and then add it so now let's go back to our code editor and try to modify our post controller so up and then HTTP controllers and of course our post controller so we have here the store function and of course we have also the show before or from the previous blog we have worked with show and then we're just getting the post so we're just going to do that also for our edit function and also we can just copy this line and just modify instead of saying show it should have the Edit keyword and of course we're also passing the post variable to our edit page so let's go back to our resources and then post we need to create a new file here to say edit blade that PHP okay and we're going to copy the mark-up from create blade that PHP because I think there are almost the same so in this page or are creating a post and of course in this page we're editing the particular post so instead of saying create a post it should be edit post and of course in here yes we need to say instead of empty we need to say post and of course the title of our post the same with the body of a post so post and body of the post and since we're editing a particular post we need to include or submit also the post ID so instead of just passing the post controller at store so we need to make it an array to pass also the ID of our post so that's post ID there you go and as you can see we have here the post method but if you try to view our route list by opening our terminal so let's try to view first our list so that's the HP artisan and then route list so we have here all the route for our project and as you can see we have here the update right so post and then of course the idea of our post and as you can see the method for this particular route as put or patch but we can't directly say here put so we need to have some kind of mechanism to enable to say put so in here we need to pass in some hidden field so form and then he then and of course the underscore method good so this is somewhat like a bypass because we cannot directly go here and say put so instead it should be post here and then here we can say the method should be put for our update route so save this and then I'm just going to close that terminal and let's go back to our post controller and try to update our update function here so in here in our update function you could just copy the logic coming from our store function so we can copy all this lines and paste it here there you go and we just need to change the post because we're not doing or we're not creating a new post we're editing the post so what we need here is to find the particular post fine and then passing in the ID of the post and of course instead of saying post updated or post created it should be post updated so there you go save our post controller that PHP and let's go back to our browser and in here refresh so we have here the Edit post page so let's try to go back to our blog first and then try to see post two and then this is the post oh and then if you try to click on edit we can see that the title is postal and we can just edit the body here so this is the second post body and this is updated by a certain user just to make sure just to show that we have updated this particular post so submit so we're getting this exception so the put method is not supported for this route so I think we need to change something here so oh there you go so instead of using store it should be update here so save that and let's go back to our page so Doug and then post two and then edit this is the second post buddy and this is updated and then submit so there you go post updated and then if you try to go see the post to we can now see that the post has been updated so now let's add the delete function just like what we have in our edit function or edit form we need to submit also the post ID for our delete function and also specify the move method so you know in that manner we need to also make our delete function as a form so we need to add a form here instead of just a pure link so that's form form and then open and the action of our form that will be post controller and then I destroy because we're using this for particular function to delete our post and then of course the idea of our post post IB specify the post ID and then for this we need to specify the method here so method and of course this should be post and we need to add a class here for our form so class all right because we want this to float right side of our Edit link so pull right and then we're going to close this one close our form and in here we need to add two things the method or the spoofing method that we have the same like for our edit so we need to add hidden field so underscore method and of course the keyword elite and of course here we also need to add the submit so form and then submit open and close and then delete this is our submit button so delete and we need to add a class here for our button so that's BTN and then BTN danger so let's try this refresh so we're getting syntax error and expected period so let's go back to our editor and identify the oh there you go so post it should be the post ID so Save let's go back to our page post three so it says undefined class constant closed so I think we also missed that instead of closed so it should have the open and closed parenthesis so let's go back to our page post three and then delete so now we are being redirected to the destroy function of our post controller so let's go to that function so destroy and in here we just need to find the post just like what we have in our update and show so find the post and then of course we need to delete the post using that function and then we need to redirect to our post page so that's post post and of course we need to pass in a message so that's success and then the post remove so save that and then refresh or maybe it's better to go to our post first so blog and then post three and then press the delete so as you can see we have removed the post number three and we have the message here post remove so we have successfully created our create read update and delete and in the next blog we're going to talk about or we're going to discuss about user authentication so thanks and see you in the next blog</p>
]]></content:encoded></item><item><title><![CDATA[PHP Laravel Tutorial for Beginners 12 - Forms and Saving Data Part 2]]></title><description><![CDATA[hey what's going on guys welcome back to our blog and welcome to this particular blog so this is actually the part 12 of our laravel tutorial for beginner series and in the previous blog we have laid out the basic structure of our form to enable us t...]]></description><link>https://blog.rohitadhikari.com.np/php-laravel-tutorial-for-beginners-12-forms-and-saving-data-part-2</link><guid isPermaLink="true">https://blog.rohitadhikari.com.np/php-laravel-tutorial-for-beginners-12-forms-and-saving-data-part-2</guid><dc:creator><![CDATA[Rohit Adhikari]]></dc:creator><pubDate>Thu, 24 Dec 2020 03:57:00 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1650706028111/cMOEFLXfg.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><a target="_blank" href="https://1.bp.blogspot.com/-P6XAzyhwufI/X7M6Xa6hdpI/AAAAAAAAAcg/zjyC1PKMgtA9bd3F0VuM1RAKmT4tpxBygCPcBGAYYCw/s1920/Untitled%2Bdesign%2B%25281%2529.png"><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1650706025670/YWYpUAXXF.png" alt /></a></p>
<p> hey what's going on guys welcome back to our blog and welcome to this particular blog so this is actually the part 12 of our laravel tutorial for beginner series and in the previous blog we have laid out the basic structure of our form to enable us to submit data using our form into our database so in this blog we're going to continue working on with this form and let's try to add some template for our messages inside our create page so let's go to our views and let's create another directory here so this should be in a NC and then this we will create a new file here called messages that laid that PHP and then we're going to include this file into our app that laid that PHP so we're just going to configure first this messages that laid that page wait for now and first let's just check if the count for errors is greater than zero so let's just close first the if statement and we're going to define a for each here and let's just close the for each below and inside this for each as we're going to iterate the errors and this is an object so all and then as error and of course we're going to define a very basic alert to our user by using the bootstrap alert elements so this should have a class alert and of course because this is an error so it should be danger right and of course the error itself display and also we're going to check for messages for session coming from our page so session and then if it has a success value so we're just going to end the end if here so just bear with me guys because I'm just going I'm just laying out the messages or the feedback to our user if they have something or if there's if there were errors during the process of submitting the information so div and then of course it should have the alert also alert success and the value of our session and success and then we're just going to do the same for our error coming from the session so this should be error also and instead of success it should be danger and also here is the error okay so we need to include this inside our layout up that laid out by HP so I think somewhere before the main container okay or after the container element so we're just going to include the messages here so add and then include and of course the directory and the template messages so save this one and try to let's try to preview it in our page so refresh and then submit so there you go we can see the title field is required and also the body field is required and try to populate the title and then only the body field is required because we don't have the because we did not populate the body of our post so now let's go back to our post controller and continue working with our store function so you remember that we use tinker before to populate our database so we can actually use that also in here so post and then equal and the new post and we can use that instance for now so post and then set the title for our post which has the request or the value coming from a request and technically it is the value coming from the forum so we we should specify the input which has the title and then of course we can actually get the value of our body the same thing as the titles or requests and then the input and of course the body and save this supposed and then save then we can read the req to another page or to the post page so returned in the redirect to the post page and it should have additional information so with and then of course success so remember we have defined this in our messages that laid that PHP file and this is how you set the value of the message so post created and then something like that and try to save this and let's go back to our browser and try to preview it so refresh and then let's try third post because technically this is the third post so post three and then this is the body D post number three and then submit so it is now redirected to the post page and it has a feedback post created so the alert message that we have created in our messages that made that PHP so now we have three records in our database post one post two and post E and then if you try to click any of this post we can redirect to another page with all the information included or displayed in this post and now I wanted to add a link to create a post because for now we don't have any link here that says we can create a post so let's go back to our app that laid that PHP file and then we can see here all the links from our navigation the home services blog and about and this is the right side of our navigation so I think we can just copy this now item here and then paste it on this left side of our navigation so this is create post or we can just say add post post and then it should be direct in to post create so let's try this so save and then let's go back to our browser and refresh so as you can see we now have the add post link here and it should redirect us to deform once we click it so we a working link to add post now and I think it's high time for me to add a sin tax highlighter for now for the blade templating because as you can see we have all the syntax here or all the scripts for our blade templates here but we don't have a syntax highlighter for that all we see is a white tax and then I think it's not readable for us so let's go to file and then settings and then packages and then let's try to install or try to go here in in install and search the package language and played so language blade so it is a syntax highlighter for the blade templating engine used in laravel so we're just going to install this so it should enable us to read the syntax of our blade or syntax of the blade much easily so let's try this and then let's just wait for a few seconds to allow the installation to complete and I think it's it is now complete let's go back to our file and as you can see we do have now the syntax highlighter or syntax highlighting for rate templates and it it will be only activated on files that has blade that PHP file extensions so I think that's all there is to it for this tutorial and I hope you have learned something from this blog and in the next blog we're going to discuss how to edit and update our records by using our laravel project so thank you and see you in the next blog</p>
]]></content:encoded></item><item><title><![CDATA[PHP Laravel Tutorial for Beginners 11 - Forms and Saving Data Part 1]]></title><description><![CDATA[hey what's going on guys welcome back to our blog and welcome to this particular blog this is the part number 11 of our laravel tutorial for beginners series and in this blog we're going to discuss forms and how to save data and if you try to go to t...]]></description><link>https://blog.rohitadhikari.com.np/php-laravel-tutorial-for-beginners-11-forms-and-saving-data-part-1</link><guid isPermaLink="true">https://blog.rohitadhikari.com.np/php-laravel-tutorial-for-beginners-11-forms-and-saving-data-part-1</guid><dc:creator><![CDATA[Rohit Adhikari]]></dc:creator><pubDate>Tue, 22 Dec 2020 03:52:00 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1650706038462/4FanJwUbc.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><a target="_blank" href="https://1.bp.blogspot.com/-P6XAzyhwufI/X7M6Xa6hdpI/AAAAAAAAAcg/zjyC1PKMgtA9bd3F0VuM1RAKmT4tpxBygCPcBGAYYCw/s1920/Untitled%2Bdesign%2B%25281%2529.png"><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1650706036655/ArQXUFpVN.png" alt /></a></p>
<p>hey what's going on guys welcome back to our blog and welcome to this particular blog this is the part number 11 of our laravel tutorial for beginners series and in this blog we're going to discuss forms and how to save data and if you try to go to the correct or PK project that LOC create and then you can see that we have a 404 not found because it is loading the create function of our post controller and as you can see we don't have any logic from here yet so all we have to do now is modify this function and to actually return a view so this should return a view coming from our post directory and create template and let's go ahead and and create that inside our post directory so new file and of course the name of our template is create blade great blade that PHP and then we're just going to copy the mark-up from this index that laid that PHP and paste it here and it should say create post instead of just saying post and then we're going to get rid of all this markup here because we're going to use a form for us to save information coming from a form into our database and for now let us save this and try to preview in our browser so refresh so as you can see we still have the peak a project that LOC create and we're getting a 404 not found that's because I think we need to specify first the post here before they create so post and then create and there you see the create post h1 that we have added in or create that plate that page we find so let's try to add a form into this page and we're going to use laravel collective for that so they have a some sort of a template for forms and we just need to install and add some dependencies into our project so we can see here HTML so laravel collective and we can also open up their website laravel collective and here we can see the different versions so for example 6.0 so installation for the lateral collective is here so composer require laravel collective / HTML so we're going to do that in our code editor Adam and we're going to open up the integrate the terminal from more code editor Adam and then paste just the composer required laravel collective so there you go and then enter we're just going to wait for a few seconds and now the installation is complete let's go back to the website and in here we have a guide on how to open up a form inside inside our template so we have here opening our form and then we can just copy and paste this one and paste it in our create that blade PHP so below here let's just paste this code and try to change this in because this is how the default on how to open up a form by specifying the URL and where to submit the data coming from this form but we can actually change this so in here we're going to specify the action instead of the URL so the action for this one is post controller and then add symbol and of course the store function inside our post controller class and we can also specify the method from here so it should be method and of course method with single code and the equal and greater than sign and here we specify the method which is post also in here we can specify a division with a class form group so this is actually coming from a bootstrap so we can also add a form label here so this will be form and then label and specifying that this is a label for our title and the actual label of our title field and of course we can also specify here the actual input so form and then tax we can specify the name of our input which is title and then the value so this is a create form so we should not specify a default value and of course we can also specify classes here or additional attributes so for classes or for classes for this particular input and this should have a class form control and of course a placeholder for this particular input so equal sign and then greater than and the actual placeholder which is title so let's try to save this for now and let's go back to our browser to preview and try to see here we have the actual label an input field which has the placeholder title but I think we don't have yet the correct classes for our input so it looks ugly for now so let's go back to our code editor and try to see so we have here instead of class we have specified classes so save that and try to refresh and there you go we have a much much better input for our title and then we can also the same or we can also do the same for our body so we're just going to copy this and instead of title we're going to say body and of course this is for body also and by d2 and so with this placeholder and of course instead of tax or using tax it should be taxed area there you go and save that can refresh our page so we have a title and a body now and the last part is to add a submit button for our form so before the closing tag of our form let's add the button submit which is form and then submit and of course we need to specify some values here also so submit and then of course the class for our button which has class and then we can specify the BTN class with the N primary to signify that it is a button so save and refresh so now we have a complete form with all the fields and of course the submit button and if you try to submit now so it redirect to another page and basically we're not doing anything for now because we should modify also the store function of our post controller so let's go back first or code editor and edit our post controller so inside here I'm just going to close this real quick and in here we need to add some logic to actually save our data coming from the forum we can also add the validation from this function also so we can specify this and then the function validate and of course we need to have the request here and also the area of the rules which as for our title it should be required okay so it should be required and also the body tag or the body or the body of our post should be also required so and then we're just going to return a number for now so 143 something like that save this and go back to our browser refresh and then try to submit so it is not allowing us to submit or any data because air is empty for now so but we don't have a message that it it is submitting an empty information but if we try to have an information here and then submit so as you can see we now have the return information 1 for 3 so I think this blog is rather long so we're going to continue working on with this forms and how to save data in the next blog and I hope you learned something from this blog and see you in the next blog thanks</p>
]]></content:encoded></item><item><title><![CDATA[PHP Laravel Tutorial for Beginners 10 - Fetching Data Using Eloquent ORM Part 3]]></title><description><![CDATA[what's going on guys welcome back to our blog and welcome to this blog so this is part number 10 of our laravel for beginners tutorials and in this blog we're going to cover how to display the information coming from our database and using the Luke w...]]></description><link>https://blog.rohitadhikari.com.np/php-laravel-tutorial-for-beginners-10-fetching-data-using-eloquent-orm-part-3</link><guid isPermaLink="true">https://blog.rohitadhikari.com.np/php-laravel-tutorial-for-beginners-10-fetching-data-using-eloquent-orm-part-3</guid><dc:creator><![CDATA[Rohit Adhikari]]></dc:creator><pubDate>Sun, 20 Dec 2020 03:46:00 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1650706048778/BoHlmPSbS.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><a target="_blank" href="https://1.bp.blogspot.com/-P6XAzyhwufI/X7M6Xa6hdpI/AAAAAAAAAcg/zjyC1PKMgtA9bd3F0VuM1RAKmT4tpxBygCPcBGAYYCw/s1920/Untitled%2Bdesign%2B%25281%2529.png"><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1650706047084/niSbe4de7.png" alt /></a></p>
<p>what's going on guys welcome back to our blog and welcome to this blog so this is part number 10 of our laravel for beginners tutorials and in this blog we're going to cover how to display the information coming from our database and using the Luke went over em so we're going to display our post so basically from the previous tutorial we have worked with our controller post controller and our post model and of course we have laid out the basic layout of our index that laid that PHP where in which we already iterated the post coming from our database and also making our title as link so that we could click on that link and then be redirected to another page where in which you can see the full details of that particular post and also we have added the created at or written on date and then I have realized that we are we use the class well which is not included in in bootstrap anymore so we're going to use card for this class and in our app that blade that PHP file we're going to add the post page so we have here all the items are all the links from our navigation so home services and about so we're going to add another link or another item in our navigation bar so this should be all about the blog which contain all the posts and of course this should be all about posts so let's go back to our browser and try to preview and let's try to refresh the page so as you can see we now have the home services and of course the blog which is added recently so click on that and you can see we have here a deposed and I think we can take this further so instead as you can see this is somewhat ugly for now so let's try to modify this in our code editor so let's go back here in our index that played that PHP and yet as you can see we have here with the card right but instead of using a ch3 I think we're gonna use the UL for now so this is coming from our bootstrap integration on so so you L so inside this and it should have a class list group and then list group flush flush there you go and then of course inside here is the list item which has the title of our post so it should have a class list group item and in here we're going to place instead of using the h3 so we're going to or I think we could keep this h3 in this area so h3 so there you go instead of using HC only so we're facing the title and acclaim created add date inside a list item we should reiterate the list item so let's go back and try to add or remove this and add it here and so with the closing dev and closing l unordered list tag so there you go and then save that and refresh so as you can see we have now a slightly different version of our post so if you try to click on this post so we still have a blank page so we'll try to work on that for now and let's go back to our code editor so let's go to our post controller and as you can see we have here a function that says show that takes in a parameter ID so we can just edit this function and try to return a single post so return and then post and of course you can use a function here called fine and then specifying the ID and let's just save this and try to preview in our page so refresh and here you can see that this is the post one and this is the body of the post one so let's try to check and click on the post to so there you go the idea is to and the title is post own and now let's take this further and try to beautify this instead of just seeing the array of data so let's go back to our code editor and instead of returning basically just the post so we're going to return a view just like what we have in our index function so post and then we're going to return a certain view so this view will be a post or under the folder post or directory post with the show that blade that PHP file name and this should go with our post variable so and then the actual variable post and of course we can try to get this on our post as show file so let's try to create that on our post directory so let's try to create a new file here so this should be show that laid that PHP ok and then we're just going to copy the mark-up from this index that laid that PHP and paste it here and then we're going to extend the layouts as well and of course you can get rid of this because we're not dealing with we're not dealing with an area so we can just have or we can just use the post variable and then you can get the title from there and of course we can also get the other attributes so the post body and of course the created on attribute so we're going to add it here by placing it inside a small tag so this should be written on and of course double curly braces and then in our post variable with the created on attribute and I think we can add an HR here so HR horizontal rule and then of course we're going to add the body or the post body of the particular post so post and then the body of the post so let's try to save this and preview on our page so this is the current version all we see is an array of values coming from a particular post but if we try to refresh this now we can see the post title and the post body and of course the I think we misspelled instead of using created on I think it is created underscore AET or at and then save that and refresh so we have here all the information the post title post body and of course d created at date so post one and then post two and I think we could also add a button or back button here so let's do that so above the post title we'll just try to add a back button here so it should be a link that goes to the post and of course it should go it should say go back and it should have a class of a button so BTN and then BTN default so save and refresh so we have here a link that tells us to go back to the post or to the page where all the posts are displayed so I there you go post two and then post one and then let's go back so what if you want to sort by maybe title or ID ascending or descending so let's try that on our index function of our post controller so as you can see we are doing the post and then post modal and then double double colon and then all so we can actually sort by title or ID so whatever you want to sort by so say for example let's just comment this one out and try to copy that suppose we can say here order by and then the attribute that you want your records to be sorted by so title say for example in this case title and we can say descending or the des e and of course we need to say get and refresh here so as you can see now the post o is the first one to appear here instead of the post one and if you try to go as sort by ascending sort by title as ascending there you go refresh so the post one is the first one two we're here in our post page and actually you can also use the SQL commands or SQL statement and our controller to get all the post coming from our database so all you have to do is use the DB class so actually I'm going to show you that real quick because it it is very easy to get all the records coming from our database by using the DB class so we're just going to use DB and of course and here we're going to comment that one out for now and use this as our variable per a post so post and then equals the DB and of course the Select function and our SQL command which is select all from host and then let's just save this and refresh so we still have all the post coming from our database so post one and post all so I think that's all for this particular blog and in the next blog we're going to discuss forms and how to save data so I hope you learned something from this blog and see you in the next blog thanks</p>
]]></content:encoded></item><item><title><![CDATA[PHP Laravel Tutorial for Beginners 9 - Fetching Data Using Eloquent ORM Part 2]]></title><description><![CDATA[hey what's up guys welcome back to our blog and welcome to this blog this is the part 9 of our laravel for beginners tutorial series in the previous blog we have worked with the controller or post controllers we have added their outs so you've tried ...]]></description><link>https://blog.rohitadhikari.com.np/php-laravel-tutorial-for-beginners-9-fetching-data-using-eloquent-orm-part-2</link><guid isPermaLink="true">https://blog.rohitadhikari.com.np/php-laravel-tutorial-for-beginners-9-fetching-data-using-eloquent-orm-part-2</guid><dc:creator><![CDATA[Rohit Adhikari]]></dc:creator><pubDate>Fri, 18 Dec 2020 03:39:00 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1650706058218/ISghsFkAM.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><a target="_blank" href="https://1.bp.blogspot.com/-P6XAzyhwufI/X7M6Xa6hdpI/AAAAAAAAAcg/zjyC1PKMgtA9bd3F0VuM1RAKmT4tpxBygCPcBGAYYCw/s1920/Untitled%2Bdesign%2B%25281%2529.png"><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1650706056714/zT_Jh6jIA.png" alt /></a></p>
<p> hey what's up guys welcome back to our blog and welcome to this blog this is the part 9 of our laravel for beginners tutorial series in the previous blog we have worked with the controller or post controllers we have added their outs so you've tried to open the web dot PHP in our routes folder so as you can see we have defined here route and then the resource and then the name is post and our controller which is post controller and then we also added or generated the post controller class so ii see here we have here all the functions that we need in order for us to work with our code or create read update and delete functionality of our project and in this blog we're going to continue working with our post controller and try to fetch data coming from our database and display it on our browser by the way guys if you try to open our post model so as you can see we haven't done much here and if you want to change the table name you can change it here and also you can change the primary key so it's a for example you want to change the table name here so for table name and then protected and of course the variable table equals the new name or the name of your table that you want in your database and of course you can also change the primary key because by default we have we are using the ID auto increment ID so you can also change that in here so protected say for example protected and then the primary key primary key it was ID there you go or you can change it into public so public primary key and then say for example you if you want to name it as item underscore so for example you want to name it as item underscore ID as the primary key so you can do that also by by default we're using the ID right and also if you want to change or if you don't want to include the timestamps that we have or that has been added automatically for us so time stamps remember that created at and updated at fields so we can set it to false to not include that in our database so you can do that here but I'm going to show you now how to display the data coming from our database into our page or post page because let's open our project in our breath so this is the home page right and if you try to go to the post section and the page is currently now blank but we can change it because currently it is loading the index function coming from our post controller which is now returning or it doesn't return anything for now so we will change this and we will return in the view for our index so we're just going to edit this so instead of returning empty it should return a view so it should be a file under post directory and then the name should be indexed at blade that PHP so there you go so we need to create that in our view so resources and then views and then we need to create a new folder here so it should be post and there should be a file here that says index that blade that PHP so there you go and in here let's just stay the layout coming from our layouts folder so layouts and app and of course we need to add the suction content for our content to be here especially the post so and section need to add end of the section here and of course we are going to place an h1 to have our post there and now let's try to preview our post page so as you can see we have the navigation bar and the h1 post and now let's try to get all the posts coming from our database so in our post controller instead of returning just the post index so we can return the actual post so we can use the post model because we're using the eloquent so it is basically just a object relational mapper and in here we can just say post double colon and then all so it will return all the records or all the posts coming from our database so I just comment this one out and also this and also this one so save and then review our code so refresh this page and we have some sort of error here so class HTTP controllers post not found so that's because we then click or use the app post here so we're just going to add that so use app backslash and then post and then semicolon and then save that and let's go back to our browser and refresh so there you go you can see that all the posts coming from our post table in our database has been loaded and it is an array so let's go back to our post page and try to iterate this array to actually display the title so instead of returning the just the post so we're just going to return the actual variable post so this will be returned view with and of course the name is post and our actual variable is post so it should be S or with s because this variable should contain all the posts coming from our database so save this and in our index that laid that PHP we're going to iterate all the posts coming from our database so let's just do that and in here we'll be adding a condition so at if and then count so first we're going to check if the post array has an element so pose is greater than 1 and then we're just going to have an else here and of course the end of our if statement if there's an element inside the post array so we're going to iterate that by using the for each and then post and individual posts there and we're just going to use the bootstrap element for a division so and if for now or end of our for each and of course this one is coming from our bootstrap implementation so class well and it should contain the h3 it will hold the title of our posts so post and then the title of course and let's try to preview this in our browser so save this one and refresh so there you go we have the post one in post too so we can add also decorated add variable or created add attribute in this so we can see that when it is created and also we can make this title as link so we can actually click on this and then redirect it to another page specifying the ID and then we can see all the details of that particular post so let's go back to our code and and in here let's add an element so small so this will hold the date that the post has been created so small and then it should be written on the double braces the post variable and of course decorated add attribute so save this and preview our page in a browser and refresh so as you can see we have the post one post over and of course the day that when it is created and let's make this post one or post two as a link so let's go back to our code editor and instead of just returning the h3 here we're going to add a link element so H or h3 and inside that is the link element so href and then double code so we should close this one here so a for our link and then of course it should be redirecting into the post page specifying the post ID so and then ID let's try that save this and let's go back to our browser and refresh so as you can see the post 1 and post o title has been converted into link and then we can actually click on this and we can see that is blank for now because we haven't configured yet this particular page so in the next blog we're going to discuss and continue working on with this how to view your information coming from the database so I hope you learned something from this blog and see you in the next blog of Thanks</p>
]]></content:encoded></item><item><title><![CDATA[PHP Laravel Tutorial for Beginners 8 - Fetching Data Using Eloquent ORM Part 1]]></title><description><![CDATA[alright guys welcome back to our blog and welcome to this blog this is the part 8 of the Lara blog for beginners tutorial and in this blog we're going to discuss how to fetch data with Luke rent and also we're going to populate our database by use by...]]></description><link>https://blog.rohitadhikari.com.np/php-laravel-tutorial-for-beginners-8-fetching-data-using-eloquent-orm-part-1</link><guid isPermaLink="true">https://blog.rohitadhikari.com.np/php-laravel-tutorial-for-beginners-8-fetching-data-using-eloquent-orm-part-1</guid><dc:creator><![CDATA[Rohit Adhikari]]></dc:creator><pubDate>Wed, 16 Dec 2020 03:35:00 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1650706068421/AEFTsaagz.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><a target="_blank" href="https://1.bp.blogspot.com/-P6XAzyhwufI/X7M6Xa6hdpI/AAAAAAAAAcg/zjyC1PKMgtA9bd3F0VuM1RAKmT4tpxBygCPcBGAYYCw/s1920/Untitled%2Bdesign%2B%25281%2529.png"><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1650706066648/WyM9A3cW3.png" alt /></a></p>
<p> alright guys welcome back to our blog and welcome to this blog this is the part 8 of the Lara blog for beginners tutorial and in this blog we're going to discuss how to fetch data with Luke rent and also we're going to populate our database by use by using the tinker command and in order for us to do that let's open or integrate the terminal of our atom editor so in order for us to do that is we have to press shift alt and T and there you go we have opened our integrated terminal and in here we can type we can run the tinker commands from here and also we can populate our database by using the tinker so all we have to do now is type in PHP artisan and then tinker and as you can see we have here the brackets that let us know that we are inside the tinker program and from here we can directly work with our database and directly work with our models so for now let's bring in the post model so app and backslash and then post and then we can have a function in here so for example count and it will return zero which means we don't have yet a post in our post table or post model so now let's create a new instance of our post so in order for us to do that is define the variable dollar sign post and then equal sign and then our in model and then new app backslash and then post then semicolon and make sure you have the backslash instead of forward slash so this will be the backslash and enter so now we have a instance or an instance of our post so it is being saved in our memory and by that we can use that in order for us to move forward and add a post to our post table so now we can use the post instance and then set the title for our first post so let's just make it the title into post one and then semicolon there we go and then of course for our post body let's just do the same for our post body so this is this is the post body semicolon and then there you go this is the post body and then after that one we can save this save the information for our title and our body so post and then save and then enter and it returned it returns true which means that we have saved a certain post to our post table now if we try to check our database inside our PHP myadmin we can see here that we have a post and of course we have the first post which is which has the idea of one that I tell we have set this into post one and of course we have set the body content this is the post body and it also have the created at and updated at fields which is automatically populated for us so let's try to add another one and first let us create a new instance of our post model so new and then app backslash and then post this will create another instance and then we're going to set the title for this this is post two and the post body also we need to set a value for this this is the second post body there you go and we will say finally we will save this values so our database so it returns true again which means that we have now have to post in our post table in our database so refresh here and then you can see we have two posts or two records of our post table so post two and then this is the second post body with D created at and updated at fields now if you try to go back into our project and if you want to add a functionality here for our create read update and delete we're going to need to have different functions and different routes in our laravel project so let's go back to our code editor and try to edit our post controller let us open our post controller and as you can see here it is pretty much empty for now so in order for us to add the functionality for our create read update and delete I think we're gonna need functions or several functions from here so we need the first one is index so it is just a way of listing all our posts from our database another one is create and I'm just going to type it in here you don't need to follow this time so store to actually save our data into our database and then we have the function to add it and also we have a function that should be updating our data and of course we have also show and of course the last one too delete our record from our database so we could actually create this functions manually but we'll try to create this by using some commands so I think I haven't shown you this yet so I think I just have to delete this post controller for now and generate another one so I have deleted the post controller for now and I'm going to generate it again by using some commands so in order for us to do that let's run the command PHP artisan and then make and then controller and of course the name of our controller is post controller with s post controller and then we're just gonna add the resource keyword here and then we're just going to wait for a few seconds to allow the generation of our controller so there you go controller generate that are created successfully and if we try to open up the new post controller we can see that all the functions that we have listed earlier has been generated successfully so we have here the function index so display a listing of the resource and some of the functions here don't need or doesn't need the parameters but there are also functions that need the parameter so say for example this one we have D create so show the form for creating a new resource and then the store has this parameter request and we're going to define some of the logic later on in this function and also we have the show so it has the ID that will identify the record that we want to show here and also we have the edit the same thing it has the ID parameter and also we have the update that requires two parameters the request and of course the ID of the resource and of course the destroy function that will enable us to delete based on the ID of the resource so now that we have laid out all these functions in our controller we need to have a route for each functions right so we're going to add or we're going to go to the web page P of our routes and as you can see we have here the route that we have currently and if you try to go to our command or our terminal let's try to list our routes for now so PHP artisan and then route and then list so these are the currently generated routes for our project so as you can see we have here drag in the home the password the register and all other functions or all other routes that we have set and now let's try to add a route for all our functions because it is a kind of pain in the ass if you try to generate individual routes for our functions right so let's try to generate route for all our resource in our post controller so route and then resource and of course the name will be post and of course the name of our controller which is post controller and then we're going to save this for now save and then let's go back to our terminal and try to run another one PHP artisan and then route and then list so let's try to find our resource or generate that routes for our post controller so as you can see we have here all the the routes related to our post controller so we have here the post store post index post create post show and of course post update and all other functions or all other routes that we that we need in our post controller and I think that's it for this particular blog and in the next blog we're going to continue working on with our fetching data with Lucan so we're working with the create read update and delete so see you in the next blog</p>
]]></content:encoded></item><item><title><![CDATA[PHP Laravel Tutorial for Beginners 7 - Models and Migrations (Models & Database Migrations)]]></title><description><![CDATA[hey what's going on guys welcome back to our blog and welcome to this blog this is the part 7 of our laravel tutorial series and in this blog we're going to discuss how to work with models and migrations but before going into models and database migr...]]></description><link>https://blog.rohitadhikari.com.np/php-laravel-tutorial-for-beginners-7-models-and-migrations-models-and-database-migrations</link><guid isPermaLink="true">https://blog.rohitadhikari.com.np/php-laravel-tutorial-for-beginners-7-models-and-migrations-models-and-database-migrations</guid><dc:creator><![CDATA[Rohit Adhikari]]></dc:creator><pubDate>Mon, 14 Dec 2020 03:32:00 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1650706079093/AHac4uLzy.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><a target="_blank" href="https://1.bp.blogspot.com/-P6XAzyhwufI/X7M6Xa6hdpI/AAAAAAAAAcg/zjyC1PKMgtA9bd3F0VuM1RAKmT4tpxBygCPcBGAYYCw/s1920/Untitled%2Bdesign%2B%25281%2529.png"><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1650706077309/C4P4_1TU2.png" alt /></a></p>
<p> hey what's going on guys welcome back to our blog and welcome to this blog this is the part 7 of our laravel tutorial series and in this blog we're going to discuss how to work with models and migrations but before going into models and database migrations let's try to add first the about and services links here in our navigation bar so let's go ahead and try to do that in our code editor and in here we can try to open up our app that blade dot PHP so let's go ahead under views and then layout app that blade that PHP and as you can see here we have here the links of the login and register so all we have to do now is just copy this and paste it here so we'll just add the links suffer example for our home let's just put slash there for our home and then copy that for our services so the link for our services is slash services and the same thing with our about page that there and change this link in to slash about and then let's just go ahead save this and let's refresh our page and there you go we can see that we have the Home Services and About section but I think we need to modify the layout because we want this home services and about to align with login and register so in order for us to do that let's go back to our code editor and in here instead of having one nav item so let's make it free for our home and then the same thing for our services close the list item tag and paste another one so save this and here refresh so as you can see now we have the home services about login and register links online together and if you try to click any of these links it should work for all of them so the about services home and also the login and register links one last thing that we will modify here is that we need to add some class to our content to properly position our text services and also the about Us section let's go back to our code editor and try to modify this and in here let's go to the main element and it has a class of B Y - 4 for now so let's add a container class for this and then say go back to our browser and refresh there you go you can see that the about or this elements are slightly indented from the left so about us and also with the services now that we have that covered let's try to go to the topic models and database migrations so the first thing that we're gonna need is the page B my admin if you are using one or Sam or any versions of the wampserver so the PHP myadmin is embedded into that and included on the installation process and I hope that you included that during the installation process of the one server or lamp or any version or any variation of the one server now we need page we may admin because we're going we're going to add a database here so all we have to do is click the new and then we're just gonna name our database ah speak a project there you go and then create now we don't want to create tables here because we want our laravel project to automatically create tables for us so let's go back to our code editor and make some changes and add controllers add borders for our project and in here let's try to open our terminal so I'll shift e so this will open up our integrated terminal for our atom code editor and from here we can issue commands or run commands artisan commands page B commands or any other commands that we need so the first thing that we're gonna need is to create a controller for our post so the key word for that is PHP artisan make and then Colin and then controller and of course the name of our controller which is post controller and then enter and we're just going to wait for a few seconds to allow the installations or to allow the generation of files so there you go controller created successfully and the next thing is we need to we need to add a controller or I mean a modal but for now let's try to check first if the controller has been generated for us here in our project so as you can see we have here the post controller the deck extends controllers and really use the illuminate coming from the laravel and added the namespace controllers so the next thing that we're going to generate is a modal so in order for us to do that just like the controller is to issue a command PHP artisan and then make and then instead of controller we're going to use a modal and try to generate a post model so as you can see we need to or I think the best way here is to use a singular form of post so here we are using post and then enter and before that we need to add /m because we're going to use the migrations so this will enable us to generate the table from our laravel project so - m and then enter and there you go model created successfully and created migration post table so as you can see if we try to go to our database view database and then migrations we have here the create post table a great post table migrations so as you can see it extends migration class and then it has the two function up and down and then we need to modify this method function up because currently this particular function create a post table with this attribute ID which is Auto incremented and also it includes the time stamps for created and updated add which will be automatically filled in when we try to run the migration command and since we're dealing with post we probably need to more algebra which are title and body so in order for us to do that is we need to add it here in our app function so table and then string and then of course we need to name our attributes such as title there you go and another one for our body so table and then we want to make sure that we use the medium text here because usually the body of a post tends to be longer than the title right so medium tags and then this will be the body of our post so save this and as you can see here if you try to go to migrations we also have the migration or create user stable migration for our users so with including all the attributes ID name email password and all other attributes included here now we will make few changes here before we run the migration and create our table so let's try to go to our ENB file to input our database details so we have here the database the username and the password so I think the username and password are already set but we have to update the database name which is in our case we have used the PK project there we go and then save this so before we run the migration command and generate the tables I'm going to show you a quick change that I made in providers app service provider dot PHP so under provider folder or providers directory and then app service provider dot PHP make sure to import the illuminate support passage and facade and then schema and inside this function book make sure to add this schema default string land which is 191 and if you have added that already we're good to go and we're now going to issue the PHP artisan migrate command so PHP artisan and then migrate and if we try to check our page with my admin and refresh our project core PK project so as you can see we have here all the tables generated coming from our project or PK project so we have here the post inside this post we have the ID which is the auto-generated ID and the title which is the land is 191 so we have set this in our code and the body and of course the time stamps decorated that and updated that so in the next tutorial I'm going to show you how to populate this table by using the tinker command and also we're going to work with fetching data in our database so I think that's all there is to it for this tutorial and I hope you have learned something and see you in the next tutorial thanks</p>
]]></content:encoded></item><item><title><![CDATA[PHP Laravel Tutorial for Beginners 6 - How to Compile Assets in Laravel]]></title><description><![CDATA[hey what's going on guys welcome back to our blog and welcome to this laravel tutorial series and this is the sixth part or part six of our tutorial series and in the previous blog we talked about blade templates and for today's blog we're going to d...]]></description><link>https://blog.rohitadhikari.com.np/php-laravel-tutorial-for-beginners-6-how-to-compile-assets-in-laravel</link><guid isPermaLink="true">https://blog.rohitadhikari.com.np/php-laravel-tutorial-for-beginners-6-how-to-compile-assets-in-laravel</guid><dc:creator><![CDATA[Rohit Adhikari]]></dc:creator><pubDate>Sat, 12 Dec 2020 03:29:00 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1650706088894/y_Nn6v8In.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><a target="_blank" href="https://1.bp.blogspot.com/-P6XAzyhwufI/X7M6Xa6hdpI/AAAAAAAAAcg/zjyC1PKMgtA9bd3F0VuM1RAKmT4tpxBygCPcBGAYYCw/s1920/Untitled%2Bdesign%2B%25281%2529.png"><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1650706087057/C-Rg4wFOL.png" alt /></a></p>
<p> hey what's going on guys welcome back to our blog and welcome to this laravel tutorial series and this is the sixth part or part six of our tutorial series and in the previous blog we talked about blade templates and for today's blog we're going to discuss about how to compile assets in our laravel project but first let us try to pass data as an array of values so last time we passed parameter as array but what if try to pass data or an array of data inside an array so we'll try to do that here in this blog and let's go ahead and instead of passing only the title we'll just pass another array of data here so services and then we're going to add we're going to add regular array here for our services so number one will be web design second one is programming third will be SEO all right so since we're passing this services inside the data array so we should be able to access that in our services that laid that PHP file and in order for us to do that we need to check if there is if the services array contains something so we could add a logic here so if count and then the services is greater than zero and below here let's try to add the and if there you go and of course we need to iterate our services array if it is not empty so add for each for each and then the services as service and we need to add also the N of our 4-h and of course inside inside this for each we need to like if we need to add the LI for our service something like that and then we need to get the server's itself and we need to add the UL for our or inside this if statement so you well here save and let's try to preview our page this is the home page of our application and if you try to go to services we can see here we have the data coming from our pages controller and we're passing the data including the web design programming and SEO now let's talk about compiling or how to compile assets in our laravel project so before we proceed let's download first the no genius so if you're Windows user or Mac OS X user so there is available and solar for you and you can have the 32-bit 64-bit options but we'll just try to install it by using this means windows installer and install it in our local machine so after downloading we can just install it right away open up the installation package and then try to click on next and then accept the terms and the license agreement so next and then the installation path and then next and then make sure to enable all this options here the node.js runtime the NPM package manager online the commendation shortcuts and then add to our environment path in the next and there's an option here the to automatically install the necessary tools and there's a note that this will also install the chocolaty and the script will pop up in a new window after installation process so to save us from trouble so let's just enable this and then next and install and then we'll just wait for a few seconds to enable the node G as installation to complete and then after installation we should be able to like for example include bootstrap in our project to include other dependencies for our project and so on and now that the installation is complete so let's go back to our project here we are we can try to open up our PowerShell window and then let's try to see the version of our nodejs so we have the V version 12.13.12 also we can see the version for our NPM which is also 6.12 point one so by this time we can already include our bootstrap insulation for our project now we just want to run the command composer require laravel and then /uy and then we're just going to wait for a few seconds to allow the installation to complete and we should be able to incorporate the necessary libraries for our laravel UI so as you can see this will also install the bootstrap in our normal project so we can already use that if we have a successful installation for our laravel UI and now that the insulation for our laravel UI has been completed so we need to run also or to include also the dependencies for our oath so this will include the login and register view so PHP artisan and then UI views - - oath and this will install the log in register and after that we need to run the command npm install to compile the CSS and other dependences of our project so we should be able to see the login the register and other views included for our UI and view oath or oath dependencies so i'll try to show you that after this installation so we're just going to wait for a few seconds for it to complete and then we should be able to see the changes in our browser by the way if you can see here at the top there's a prompt here that the layout app blade that PHP view already exists so do you want to replace it so in my case I have said or I have set it to N or no but you can try to accept it or to replace the existing layout of our app that late at page please so you can try to answer yes for that and then the layout of our project will be changed according to this update and this layout balloon will also include the old the login and then register as I've mentioned before and as you can see here I have here the layout view already exist and do you want to replace it and I just answered why or yes for that so I just want to replace the existing app that made that page way that we have been working on in the previous tutorial and after that you need to run also the command npm run dev to compile all the necessary assets that we have so here we have the app that CSS and app dot j s and after running this command we should be able to see the changes of our project so i'm going to show you the project now and what it looks like so this is our project should look right now and as you can see we have here the CSS folder that contains the app that CSS or generated app that CSS that contains all twitter bootstrap styles necessary to apply to our project and we also have the J's file or GS directory with the app that J s file as you can see with all the scripts needed for our project so this is the compiled versions of all the Java scripts or scripts for our project and as you can see here the resources we have here the app GS and the bootstrap Jas and as I've mentioned before we also include the oath files so it should be the log in that Lagoon blade that PHP registered blade that PHP and verify that they are verified that blade that PHP and of course we also have this files for our passwords so confirm email and reset and now let's try to preview our code in our browser so this is the home page of our project right now and if we try to go to about section so we can still see the about us and then this is the about page tax and of course we can also see the services with all the services included the web design programming and SEO so this are the pages that we have added the login and then register if you try to click on that so as you can see we have here the ready-made login form and the same thing with our register so I think that's it for this tutorial and in the next blog we're going to talk about models and database migrations so see you in the next blog thanks</p>
]]></content:encoded></item><item><title><![CDATA[PHP Laravel Tutorial for Beginners 5 - Laravel Blade Templating]]></title><description><![CDATA[hey what's going on guys welcome back to our blog and welcome to this laravel for beginners tutorial series so actually this is the part 5 of this tutorial series and in this blog we're going to talk about blade templates and of course a sort of reca...]]></description><link>https://blog.rohitadhikari.com.np/php-laravel-tutorial-for-beginners-5-laravel-blade-templating</link><guid isPermaLink="true">https://blog.rohitadhikari.com.np/php-laravel-tutorial-for-beginners-5-laravel-blade-templating</guid><dc:creator><![CDATA[Rohit Adhikari]]></dc:creator><pubDate>Thu, 10 Dec 2020 03:20:00 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1650706098894/Y-Tp0zfTa.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><a target="_blank" href="https://1.bp.blogspot.com/-P6XAzyhwufI/X7M6Xa6hdpI/AAAAAAAAAcg/zjyC1PKMgtA9bd3F0VuM1RAKmT4tpxBygCPcBGAYYCw/s1920/Untitled%2Bdesign%2B%25281%2529.png"><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1650706097127/ENU2AenYf.png" alt /></a></p>
<p> hey what's going on guys welcome back to our blog and welcome to this laravel for beginners tutorial series so actually this is the part 5 of this tutorial series and in this blog we're going to talk about blade templates and of course a sort of recap from the previous blog we work with the controllers and we set up controllers by using the artisan and as I've said in this blog we're going to talk about blade templates so let's go ahead and create a new folder inside our resources folder and under views so we're going to create here a layout directory so new folder and then we're just going to name it layouts because as you can see if we try to open up our pages the about the index and the services you can see we have repeating HTML for our services page our index page and our about page so we'll try to minimize that by using our layout files so under layouts this is under view so under layout we will create a new file called up that laid that PHP and then we're going to substitute or we're going to add some keywords here that will enable us to minimize this repeating HTML and inside here we're just going to copy the HTML from our about V dot PHP and paste it here in our app that laid dot PHP and in here we'll just say add symbol and then yield and and then keyword content so save this and inside our index dot PHP so instead of using all this HTML we'll just delete this and we'll just leave this h1 and paragraph tag and at the top we'll just say extends and then open in close single quote and then layouts that up so the reason behind we we put layout set up because this particularly out belongs or under layouts folder and the name of the layout is app so that's why we extend layout that up here and of course let's just delete this also the body and the HTML tag and in here was just gonna put a section and it should be the content right there and in here let's we'll just end the section okay there you go let us save this and copy all this code or maybe here and then go tour about that page P so instead of using all this HTML we'll just replace that and put the end section there same thing with our services so remove all that HTML and type in the end section here so let's go ahead and try to preview if all of our code are working so here we are at our index let's just refresh that and as you can see our index dot PHP file is still working with all the h1 and paragraph tag there and if we try to go to about it should work as well and of course the services okay so this is the index right so maybe we'll just change the stacks and try to see if it's working or if it's really working or not so let's go back to our code editor and index that blade that PHP so welcome to laravel for beginners and we'll just delete that save our file and let's go back to our browser mmm refresh there you go as you can see the h1 tag only contains now D welcome to laravel for beginners tax so in that manner we won't have to repeat all the ugly HTML that we had before and now let's try if we want to pass some values or parameters to our blade templates so let's go to our pages controller in the app HTTP and then under controllers so pages controllers and let's try to pass some values or parameters to our layout by just using this mechanism here so let's just say title and then welcome to programming knowledge something like this programming knowledge there you go and actually there's two ways on how to do this but I will show you both ways on passing values to our template so the first way is this so let's just pass parameters so view and then compact compact there and pass in the title as the parameter and let's go to our index so instead of using this text here let's type in curly braces and then tighten there we go and let's try to save this and go back to our browser so this is the original text welcome to larval for beginners and let's refresh our page so I think we have an error use of undefined constant title assume so I think we forgot to type in the dollar sign or money sign so instead of only the title we'll type in the dollar sign for our placeholder and then save that and refresh there you go as you can see welcome to programming knowledge so let's just just to make sure let's just change something here in our text so instead of the title let's just say welcome to programming knowledge and then let's try to add a mark there or at the exclamation mark and refresh our page and there you can see welcome to programming knowledge with the exclamation mark another way of passing parameters to our layout is by using the keyword width so instead of using this let's just comment this out and paste it here and also change this instead of compact let's just say width and of course the title keyword and the actual variable title let's just go ahead and do the same thing for our about pages so in here we can pass in the about us tax and this should be with and of course title with the actual variable title here and also in this particular method we can pass in multiple data by using array and instead of using the title variable so let's just say data and then we will define an array here array and inside this array let's just say we have a title here and then services okay and of course we need to pass this to our services page or services layout with the keyword with let's just not forget the greater than sign in of course you can use the theta volleyball and let's just go to our pages be about so instead of using the about here let's just go ahead and type in the title and also for our services here we can just say title there you go so about and our services and including our index that made that made that PHP and let's try to refresh our page and let's go to our about page as you can see we have here that dated about page and also the services with I think we have misspelled a bit so let's try to change that in our code editor so services I think it's in our pages controller and of course by deleting the D because we have misspelled there and refresh and there you have it services this is the service page so I think that's it for this tutorial and in the next blog we're going to discuss compiling assets and maybe models and database migrations so see you in the next blog thanks</p>
]]></content:encoded></item><item><title><![CDATA[PHP Laravel Tutorial for Beginners 4 - Controllers in Laravel]]></title><description><![CDATA[hey what's going on guys welcome back to our blog and welcome to this laravel for beginners tutorials and in this blog guys we're going to discuss how to work with controllers inside our novel project and as a sort of review a recap in the previous b...]]></description><link>https://blog.rohitadhikari.com.np/php-laravel-tutorial-for-beginners-4-controllers-in-laravel</link><guid isPermaLink="true">https://blog.rohitadhikari.com.np/php-laravel-tutorial-for-beginners-4-controllers-in-laravel</guid><dc:creator><![CDATA[Rohit Adhikari]]></dc:creator><pubDate>Tue, 08 Dec 2020 03:13:00 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1650706110374/r53YUOXWY.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><a target="_blank" href="https://1.bp.blogspot.com/-P6XAzyhwufI/X7M6Xa6hdpI/AAAAAAAAAcg/zjyC1PKMgtA9bd3F0VuM1RAKmT4tpxBygCPcBGAYYCw/s1920/Untitled%2Bdesign%2B%25281%2529.png"><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1650706108300/S9CzoHKGA.png" alt /></a></p>
<p> hey what's going on guys welcome back to our blog and welcome to this laravel for beginners tutorials and in this blog guys we're going to discuss how to work with controllers inside our novel project and as a sort of review a recap in the previous blog we work on how to use the basic routings so we have discussed basic routing in the previous tutorial and like I've said in this tutorial we're going to discuss controllers but firstly we need some configurations especially if you are or if you're using the atom code editor so basically we're going to install some packages required for us to continue working with our laravel project so one thing that we need is the terminal because by default terminal or the built-in terminal of atom is not currently installed so we need to install the atom terminal for this particular code editor so in order for us to do that we need to go to file and in settings and then under packages we can see all the packages installed here in our code editor and in order for us to install so let's go here in the installed section and then we need to search for atom terminal and then we're going to use this terminal for us to issue a command by using the artist sign for us to create controllers automatically so there are a lot of terminal available if we search for terminal inside the atom code editor but I'm using this one this is Adam - terminal 0.8.0 so accordingly it open terminal terminal the current files directory so whenever we activated this we'll be inside the current files directory so go ahead and try to install that so it is developed by Karen so as you can see here and this will be our basis and this will be we will be using this to issue commands by using the artisan 2 to create our controllers automatically so after installing the terminal we can finally issued artisan commands by using the built-in add-on terminal and in order for us to activate that we need to press alt shift e in our keyboard so ctrl or alt shift e and then this will be or this will open the current files directory which is the name of our project currently is M or PK project and then from here we can issue the artisan command to create the controller's of our project so let's try to issue command or others issue artisan command to create our controller so the key word for that is we need to use the PHP and then artisan and of course the key word make next to that is the controller keyword and of course the name of our controller which is pages so for example were using pages and then pages controller so you might want to use this code or I mean the naming notation so all the first letter of the word or any word is capitalized so example for this the P in the pages is capitalized and of course the C in controller is capitalized so every first letter of words in our controller must be like this like a naming convention for our controller so after that you just need to press ENTER and then wait for a few seconds and there you have it controller created successfully and then if we try to check our app directory inside here and there HTTP and then controllers and then there you can see the pages controller that pastry file has been generated with all the necessary terms and code included so we have here the name namespace up HTTP controllers and also it automatically added the illuminate HTTP request and then created the class pages controllers which extends the controller class and any controller that you created should extend the controller class and inside here we can create a function or method so a function inside the class is can be called a method also so public function and then index okay so public means that we can access this outside of this class so for now let's just say it will return a tax or word index and let's go back to our routes folder and web dot PHP so we have here the index setup like this so instead of using this so I'm just gonna go ahead and comment this out and then paste it here so instead of using this function to return our index so let's just try the pages controller or we'll try to use our pages controller here so first let's use the occultations pages controller and add symbol and of course the method or the function that we have defined which is the index and now let's try this in our browser so I'm just gonna save this web dot PHP and go back to our browser and try to refresh so as you can see we are on the root folder or the root directory of our file or our project and it says the index which is coming from our pages controller and index method so now we want to return the view index instead of this string index so let's go back to our code editor and in here let's go to pages controller and instead of returning the index we just need to return the view and of course it should be under the pages and then the file index so currently I think I think we don't have yet the index that page P file so let's just go ahead and create that so under resources so we have here the views so under pages let's just go ahead and create a new file so this should be index that blade that PHP and let's just try to copy all the HTML from welcome that way dot PHP to our index not late that PHP and just we're just going to delete this content from here and I think also the Styles all the stylings available here that's just it this and of course this font and for the title we're going to get back on this later on but for now let's just define a tag here each one and then welcome to larva for beginners right they're beginners from programming knowledge and then paragraphs there you go this is a larvan tutorial series okay so if you try to open up the dot env file it holds all the connection like the values for our database connection the database name the password username and all other values and also it holds the app name of our project so it kind it it says laravel it's instead of laudable I'm just going to rename the speak a project or programming knowledge project and save that and go back to our index that played at PHP so instead of using the laravel as title here let's just use the config file so config and then open closed parenthesis and app that name and if that is not available let's just use PK project okay and save that and let's go back to our browser and refresh our page so as you can see here we have the new HTML coming from our index that page B welcome to laravel for beginners from programming knowledge so this is a laravel tutorial series and this reflects all the content from our index dot PHP file so as you can see here the code or the HTML code behind this page okay so for now let's just do the same for our about page so let's just copy this and go to about that maybe that PHP file so instead of using the about so let's just face the HTML and let's just change this instead of welcome to level for beginners it should be about and let's just say here that this is the about page and while we're at it we're just going to do the same for our services so we need to add a new page so this will be services that laid that PHP and paste the HTML and of course change this into services right and this is the services page right so save that and I think I have misspelled the blade so I just named this in too late instead of needed and for our page controller pages controller we need to define functions as well two other functions for our services and about so instead of index this should be for about so pages that about and this will be for our services so services save that and in our route file stead of using this routing mechanism so let's just replace them with our newly updated functions from pages controllers so let's just copy this this will be for about and of course change this into the about method and this will be for our services and this will be services as well so save this and let's go back to our browser and try to check if all are working ok so try to refresh and then let's go to our about page so as you can see here we have updated our about page and of course if we try to go to our services page so services and there you have it this is the service page of our application so I think that's all there is to it for this tutorial and in the next blog we're going to discuss how to go about blade template nning because currently we are using or HTML for our about for our services and for our index that PHP file so we want to reuse and reduce the code for this particular file so we're going to look at how to go about by templating on the next blog thanks</p>
]]></content:encoded></item><item><title><![CDATA[PHP Laravel Tutorial for Beginners 3 - Basic Routing and Controllers]]></title><description><![CDATA[hey what's going on guys welcome back to this blog and this is the third part of our laravel tutorial series and in this blog we're going to talk all about the basic routing and controllers but before we do that let's just run through the code or str...]]></description><link>https://blog.rohitadhikari.com.np/php-laravel-tutorial-for-beginners-3-basic-routing-and-controllers</link><guid isPermaLink="true">https://blog.rohitadhikari.com.np/php-laravel-tutorial-for-beginners-3-basic-routing-and-controllers</guid><dc:creator><![CDATA[Rohit Adhikari]]></dc:creator><pubDate>Sun, 06 Dec 2020 03:10:00 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1650706120650/GaUoJ0i5b.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><a target="_blank" href="https://1.bp.blogspot.com/-P6XAzyhwufI/X7M6Xa6hdpI/AAAAAAAAAcg/zjyC1PKMgtA9bd3F0VuM1RAKmT4tpxBygCPcBGAYYCw/s1920/Untitled%2Bdesign%2B%25281%2529.png"><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1650706118761/e6XjFSAQX.png" alt /></a></p>
<p> hey what's going on guys welcome back to this blog and this is the third part of our laravel tutorial series and in this blog we're going to talk all about the basic routing and controllers but before we do that let's just run through the code or structure of our project right now so as we have mentioned before laravel uses the Model View controller or MVC format or structure so here in our project there's specific areas for those types of things so there's specific areas for the modal there is a specific area for the view and specific area for our controllers so we're going to get to that later on on this blog and if we try to open the app folder here we can see the user that PHP file which is this is actually a modal and we won't go through the code right now but this particular file is a user or I mean a model user that PHP and we can add all the models here inside the app folder but we can actually use or we can actually have a another folder here so you can add project folder here and try to name it as models if we have if we have like 50 or 100 models for our project so we can add a subfolder for this app folder but if you have only maybe less than 10 or less than 20 models you can just leave it here inside the app folder and also if you try to open up the folder and under HTTP and then controllers here we can see the base controller that PHP which is extending the base controller and all the methods and functions of this base controller we can use it in our controller files and also learn creates a folder for the other controllers such as the lagging controller register controller and reset password controller so all of these controllers we can use we can use this readily if we try to enable the oath for our project and if we try to create a controller we can actually manually create a file here or that PHP file which is for our controller and also we can use or we can create a model by just manually adding it here but the best way for adding controllers and and the model is by using the artisan now if you're wondering what is this namespace name space app so this is just basically grouping our classes or our cold so this is a pretty common if especially if you're working the object-oriented way of programming so we're just basically grouping or our classes and try to distinguish between different classes and the same classes inside this directory and also if you see the illuminate here don't get confused it is just basically a core files or core functions coming from the laravel so don't worry about this now views are gonna be on the resources folder and under resources juice and then here we have the Welcome that laid that PHP and as we all know that laravel uses the blade template in system so it is just basically a HTML with dynamic mechanism in them so we can see if statement we can see loops we can see variables by using the rating system okay so now that we get that out of the way we can go to basic routing for our project so basically we're what we want is to add a pages controller where we can add we about pages home pages contact or any other page that we want to add in our project so if you try to go to our project and routes here and when you can see we can see here that we have gear out and Colin Colin and then the type of request that we want and then the URL and of course the function that return something or put a lot of operation inside this function so try that for now and let's try to open up our project in a browser so here is our project and PK project that LOC slash so here's the home page where we can see all the links and the title laravel now let's try and go back to our code and try to edit and instead of our returning the Welcome we can just return something like attacks or string so return HelloWorld something like this and then save and let's go back to our browser and refresh so as you can see we have here the hello world tax that we can see and it is coming from our router or route and get and then the URL which is the slashes represent the home page of our project and of course the string hello world okay so for now let's copy this and let's just return this to the original or our index so this is the homepage of our app or application and this will be the hello page of our project so this is basically we're just going to display hello world and we can just we can also add HTML tag in here so just like that and then save and let's go back to our browser and in refresh so P key project that LOC this will be the home page right and we try to add hello here it will display our update and hello world string and this is where dh1 tab now if you are trying to submit the form or you are going to delete something so you can just change this into post if you are submitting via form so working with the route is very easy so say for example we have pages in our project and let's try to go to where is it resources and then we want to separate our pages here so let's just add a pages folder and in this folder we're going to create another file which is the name of our file will be the about about laid that PHP okay so in order about that lay that page people can just say about okay save that one and let's go back to our route file and instead of I think we're just going to change this and to get then let's just stop B and paste this here so instead of hello so we're just going to name it about or the URL will be slash about in the set of returning the HTML so we're going to return the view now and notice that we have the the about view inside our pages folder so we're just going to add pages and then add that or period they're there and then the keyword about so let's try it save the file and let's go back there about okay so here we are at our browser and instead of using the low let's change it into a brown so as you can see here we have the about word here that is coming from our about that late that page be fine and also there are times that we need to submit dynamic values in our request so say for example we want to submit or we want to request user with this particular ID so let's go back to our web page B file and let's just copy this so instead of just using the about let's change it I think for a change the two users and then in order for us to be able to submit an ID so we can just add a placeholder here and this will represent our ID and inside our function it should have a parameter ID that represents the idea of the user so instead of returning the view for now let's just display this is a user and then we're just going to add the name or the ID of the user so let's just save this and go back to our browser and refresh so instead of using the about so let's go ahead and try to open up the users and let's try to submit esteem so this is a user 15 or suffer sample name name of the user as Jo this is a user is Jo but most of most of the time warriors we are requesting a particular ID and then based on that ID we can clearly that into our database all right guys I think that's it for this particular blog and in the next blog we're going to discuss how to create controllers inside our laravel project thanks</p>
]]></content:encoded></item><item><title><![CDATA[PHP Laravel Tutorial for Beginners 2- Laravel Installation and Environment Setup]]></title><description><![CDATA[hey what's going on guys welcome back to this blog and for today's blog we're going to talk all about the environment setup and laravel solution so this is the second part of our laravel tutorial series so first thing first we need this tools so we'r...]]></description><link>https://blog.rohitadhikari.com.np/php-laravel-tutorial-for-beginners-2-laravel-installation-and-environment-setup</link><guid isPermaLink="true">https://blog.rohitadhikari.com.np/php-laravel-tutorial-for-beginners-2-laravel-installation-and-environment-setup</guid><dc:creator><![CDATA[Rohit Adhikari]]></dc:creator><pubDate>Fri, 04 Dec 2020 03:01:00 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1650706131539/pcjy0JclQ.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><a target="_blank" href="https://1.bp.blogspot.com/-P6XAzyhwufI/X7M6Xa6hdpI/AAAAAAAAAcg/zjyC1PKMgtA9bd3F0VuM1RAKmT4tpxBygCPcBGAYYCw/s1920/Untitled%2Bdesign%2B%25281%2529.png"><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1650706129559/QkLkeAt6t.png" alt /></a></p>
<p>hey what's going on guys welcome back to this blog and for today's blog we're going to talk all about the environment setup and laravel solution so this is the second part of our laravel tutorial series so first thing first we need this tools so we're going to install wampserver for our server so this will provide us with PHP the Apache server and the MySQL installation another tool that we're going to need is the composer so accordingly it is a dependency manager for PHP so if you don't have already the composer in your installation or in your environment in your local machine so you can go ahead and install the composer to your local environment or local machine so I'm gonna be putting the link in the description so that you'll be able to follow along or you don't be able to install the composer and as well as the web server so again if you're using another or other platform such as mac linux environment so you can see use other version of the web server I think they have the alum and deem mom so you can use that as well so for this tutorial we're going to use web server the composer right and we also have the kit so you can download this as well and install in your local machine so we're going to use these stones later on and also if you want you can also download and install the add-on code editor but penny I do any editor will do but for this particular tutorial series we're going to use the atom that IO or atom editor code editor so it is available for Windows so you can go ahead and install this also so once you have downloaded and install this software's or tools you're ready to install and setup your environment and also install the laravel for your projects alright our next step is to create our laravel project and in order for us to do that we need bash or get but actually we can use the windows powershell for that first on us the composer is integrated to that particular command line or command prompt or the windows powershell so let's open up our windows powershell there you go and i'm just going to change the font here so that you can see what i am typing here so instead of 12 let's make it like 24 hey I think that's better and great you were here at this directory users and an admin so we want to change this directory and go to our localhost directory so CD that that and another one so if you try to check our director we have here the one 64 so make sure you have installed already your warm server so I have here the one and also the directory for our server which is Joe the triple W so now let's create our here by typing the command composer and then great project and then our keyword larval / larval and the name of our application or the name of our directory so say for example if you have a project learning management system so you might want to name your project as LMS like that or in our case because this is for programming knowledge so this is programming knowledge project something like that and then enter press enter and then we will just wait for a few seconds or minutes and allow the installation to finish so I'm just going to pause the blog and there we have it after a few minutes or a few seconds we already have operated our laravel project and then we try to check this project in our code editor which is the atom but like I've said you can use other code editor that you prefer so some of you I think prefer is sublime and me personally I prefer the atom code editor so let's go ahead and try to check this project in our code editor so here we are at our code editor and let's try to open up the project our very own larval project so let's go to file an open folder and let's try to find the peak a project or programming project and then select folder so this is how the project looks like in our file system and if you try to check if we try to open up this in our browser so let's check this let's just close this and let's try to go to localhost and then DK project so as you can see we can see the structure of the directory of our project which is the peak a project that we have created by using the composer so this is a security issue because we can see the how of the project is structured but we don't want that we want to see the home page of our application so if you try to type in public poconos PT project / public so this is the page that we want to see this is the home page of our currently created project a lot of them in order for us to configure this project properly we need to add a virtual host and if we try later on if you tried to browse to our project we shouldn't see this file structure right here so this is some something like RS somewhat ugly for us to see the file structure here so let's go to localhost by typing in localhost and then here you can see the configuration of our one server there you can see and under tools we have here an option to add a virtual host there you go and we just need to add the name of our virtual hosts also for example project ek project that location or that LOC and then probably we need to type in as well the complete absolute path of our virtual host folder so it just literally means that we need to provide the complete path of our project folder so 64 and triple w slash the name of our project which is the PK project programming knowledge project and slash public folder so it means that whenever we have or whenever we browse our project by typing in PK project that LOC it should redirect us to the public folder where in which we can see the home page of our application so there's an option here at the bottom to add a court or listen port but this option or this field is optional for now so let's try to start and create the virtual host here so the files have been modified and virtual host pick a project that LLC was created so we need to refresh our or we need to restart our server or warm server or the Apache itself so you can go ahead and try to restart here to start all services so that the virtual host that we have created will be added to the server or the WAMP server so after a few seconds we can go to the browser and try to browse our virtual host which is PK project that LOC there you go and where is a wiki project equip right Jack so there's an option here that did you mean to go to peek a project that LOC yes of course and there you go you can see our project pick a project that that LOC and redirected the homepage of our project and this is what we see so instead of this ugly fine structure of our project so we can see here the server of our project and in the next blog we're going to talk all about the basic routing and controllers so if you want to learn about this laravel series try to check the next blog which is the basic routing and controllers thanks</p>
]]></content:encoded></item><item><title><![CDATA[PHP Laravel Tutorial for Beginners 1- Introduction to Laravel framework]]></title><description><![CDATA[hey what's going on guys welcome back to our blog and as promised we're finally going to get into laravel and i do have some good news for you which is that this is gonna be a tutorial series so initially we wanted it to be a crash course but we came...]]></description><link>https://blog.rohitadhikari.com.np/php-laravel-tutorial-for-beginners-1-introduction-to-laravel-framework</link><guid isPermaLink="true">https://blog.rohitadhikari.com.np/php-laravel-tutorial-for-beginners-1-introduction-to-laravel-framework</guid><dc:creator><![CDATA[Rohit Adhikari]]></dc:creator><pubDate>Wed, 02 Dec 2020 02:48:00 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1650706142609/IcFQmNbXL.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><a target="_blank" href="https://1.bp.blogspot.com/-P6XAzyhwufI/X7M6Xa6hdpI/AAAAAAAAAcc/7Xg5X8UjLvsk16rsIxXrMAyG-hZc4FsgwCLcBGAsYHQ/s1920/Untitled%2Bdesign%2B%25281%2529.png"><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1650706141112/nSSu-AUuw.png" alt /></a></p>
<p> hey what's going on guys welcome back to our blog and as promised we're finally going to get into laravel and i do have some good news for you which is that this is gonna be a tutorial series so initially we wanted it to be a crash course but we came here quickly came to find out that to include all the parts are horrible that we want to cover it's not going to fit in one hour or an hour and a half so and I think most of you guys prefer the modular type or modular format rather than having a crash course so this year's we're going or we're not just going to be covering the fundamentals of laravel we'll also be building a project from start to finish and in this blog we're going to take a look at what we will be building and we're also going to talk a little bit about laravel and some of the things that it can do before we get into what we will be doing let's stop a little bit about what laravel is so laravel is an open source page B framework and creators of laravel upset many times that we aim to make the development process pleasing without sacrificing equality so laravel is very elegant and things just kind of seem to work together very nicely also laravel is not only popular but also respected today and laravel uses the MVC or modal view controller design pattern so well we will be talking about that throughout the entire series but the basic idea is that the model deals with the database the view is the user interface that displays in the browser and the controller handles requests which come from either URL or forms such as the post get delete and other requests coming from URL and forms all right guys this are the topics that are included in this particular series so I think we already cover the first one which is the lower level overview so we have discussed some of the strong points of using this PHP framework and also some of the advantages of using laravel also I'm going to guide you in the installation or set up so we could get up and running with this laravel framework in our local development machine and also in this series we're going to build a website in a blog application with authentication and access control and of course at the end of this series we should be able to deploy our own or our very own laravel application alright so now that we get that out of the way let's talk about what laravel actually does for us so why would we choose to build an application with laravel over just building it straight up from scratch so actually there is too many reasons to list so I listed here the important ones so laravel handles routes in an extremely simple way you can simply define what URL and what type of request that you want to handle now most MVC PHP frameworks do this as well as you know such as CodeIgniter cakephp but some of them some of the routing files are really difficult when it comes with expressions and dynamic URLs and things like that so laravel makes everything very very simple which make it a great candidate for restful api and also Louisville adds a secretory layer to your application so it automatically escapes what it needs to and it also implements cross-site protection with forms and submitting to the database so whenever we are submitting data to our database larvell takes care of the intricacies of the security inside our application so among other things working with database is also easy or very easy laravel is shipped with an awesome command-line tool called artisan and it lets us do pretty incredible things with just a single command so one of those things is to create database migrations laravel also uses the blade template engine to display views so it means that we can extend layouts we can use control structures like loops and conditionals right inside the HTML so there's also there's many different ways to implement authentication but laravel sets that up for us to automatically create migrations and to create the user table and all we have to do is run a simple artisan command to enable everything and enable authentication also larvell can can handle sessions so we're going to do that or we're going to discuss that later in this series and also larval provides us with mechanism to compile assets with all the intricacies of storage and file management and also it comes with error handling so error handling is very important especially with bigger projects and it is very important to have this type of module or type of feature in a framework when it comes to handling errors and also we have the unit testing but I think we're not going to touch that in this series but it worth mentioning that Clarabelle comes with unit testing mechanism also email configuration for smtp so if you wanted to have like a verification emails sent from your application and things like that and laravel also handles cash pretty well so this are just some of the things that some of the benefits to using this framework so as far as environment goes our development environment I'm going to be using Windows and we're going to use one which gives us an Apache server PHP and MySQL on our local machine but level is completely cross-platform so even if you are using math or using Linux you can use some or you can use something like them or mom for your development and solan laravel is also pretty easy we're going to use composer which is a dependency manager so this is kind of like an NPM if you are a GS developer so we're going to install that and then we're going to run this simple command to create a new laravel project so by the way you can download the composer from get composer that or website I think I have already mentioned that laravel comes with the artisan CLI so it will enable us to handle many tasks so the number one is to create controllers and models we can use artisan CLI command for that when we are trying to create controllers and models and later on I'll be showing showing you some of the example commands that we can use for this particular task so creating database migration files and running migrations also we can we can use the artisan CLA for that create providers events jobs form requests and other tasks related to this and also we can show the routes we can also issue session commands we can also run tinker and also we can create custom commands by using the artisan CLI and this are the examples of artists and commands so we have the PHP artisan list we also have artisan help migrate also artisan make controller and you controller and here is the one if we want to make a model so our design make Colin and then modal and then the name of the model and - M or - M and also we have the page B artisan migrate and last example here is artisan tinker so all of these commands or some of these commands were going to use later and this tutorial series and other commands that probably we need in our development process so I think that's it for this tutorial and in the next blog we're going to look up</p>
]]></content:encoded></item></channel></rss>