Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / NewStats: 3,150,431 members, 7,808,540 topics. Date: Thursday, 25 April 2024 at 01:13 PM |
Nairaland Forum / Preciousaang's Profile / Preciousaang's Posts
Jobs/Vacancies / Re: I Got A Job Interview From Facebook,but... by preciousaang(m): 10:57am On Jul 07, 2021 |
Facebook will never do written test for you. It's always video call. |
Celebrities / Re: Kemi Olunloyo Tells Emmanuella: "Tell Us Your Source Of Income" by preciousaang(m): 10:01am On Nov 15, 2020 |
BabaOwen:It's not enough to amass such wealth. There are many youtubers who have much more views and subscribers and they don't make that much from YouTube. I think Kemi has a point. |
Fashion / Re: JEWELRY/WATCHES by preciousaang(m): 12:36pm On May 11, 2020 |
.
|
Business / Re: Online Store For Sale by preciousaang(m): 12:18pm On Jan 16, 2020 |
There are a lot of errors on the website. No offense but i don't think anyone would be interested in a website with such errors. |
Politics / Re: Lai Mohammed: Attack On South African Businesses Will Hurt Nigerians More by preciousaang(m): 3:44am On Sep 04, 2019 |
Each time I think this guy has reached his limit, he just surprises me with reinforced stupidity. 1 Like 1 Share |
Science/Technology / Re: Civet Killed In Akwa Ibom For Terrorising Fowls (photos) by preciousaang(m): 11:14am On Aug 25, 2019 |
daddytime:Animal, Messiah? Na wa for you self o. 1 Like 1 Share |
Science/Technology / Re: Whales Caught In USA And Nigeria: The Difference (Photos) by preciousaang(m): 8:03am On Jul 30, 2019 |
Flier: Whale is not fish. It's a mammal. So yes it's supposed to be like that. 2 Likes |
Webmasters / Re: Learn Laravel From Scratch... by preciousaang(m): 7:06pm On Jan 22, 2019 |
abdeiz: Not my fault o. When NEPA say no nobody can say yes.... Don't worry update coming soon. |
Webmasters / Re: Learn Laravel From Scratch... by preciousaang(m): 3:21am On Jan 16, 2019 |
Since I may not have enough words to explain blade templating on my own before NEPA does their work again. Please read the document in this link and ask questions where you're lost. https://laravel.com/docs/5.7/blade |
Webmasters / Re: Learn Laravel From Scratch... by preciousaang(m): 3:02am On Jan 16, 2019 |
In PHP, we normally list arrays using the foreach statement. We do the same in Laravel, only a little differently. We write a “@” symbol, followed by our foreach statement. We end our statement with and endforeach.
|
Webmasters / Re: Learn Laravel From Scratch... by preciousaang(m): 3:00am On Jan 16, 2019 |
We can also pass out other object types from the controller to the view, in this instance we’ll pass out an array. As you notice, I am putting the whole data we want to pass into the view into an associative array called “Context”.
|
Webmasters / Re: Learn Laravel From Scratch... by preciousaang(m): 3:08pm On Jan 15, 2019 |
I'm sorry for not posting soon. You know now. When NEPA decide to be NEPA. So j haven't been able to use my system. Abeg don't think I'm unserious. I'll find a way to post soon enough. Up next. We will learn about sending more types of data from the controller to the view. And I'll also teach about the blade templating language. |
Webmasters / Re: Learn Laravel From Scratch... by preciousaang(m): 8:11pm On Jan 14, 2019 |
abdeiz:Alright No Qualms |
Webmasters / Re: Learn Laravel From Scratch... by preciousaang(m): 12:40pm On Jan 14, 2019 |
abdeiz: If I'm being honest, I'm not sure. Reason being I'm not exactly a web designer per say. I'm a backend developer. So if we're going to to build a project. it won't exactly have the best frontend interface. But you can rest assured that it will touch everything I will teach you. |
Webmasters / Re: Learn Laravel From Scratch... by preciousaang(m): 6:21am On Jan 11, 2019 |
abdeiz:No. It's actually a syntax for the templating language of Laravel. If you like you can use <?PHP echo $name; ?> instead. But that will suck the whole fun out of it. Because the double curly braces actually do a lot of things for you behind the scene. For example it helps you escape the strings. |
Webmasters / Re: Learn Laravel From Scratch... by preciousaang(m): 10:58pm On Jan 10, 2019 |
If it is unclear to you or you have any corrections, or you want to contribute, please comment. |
Webmasters / Re: Learn Laravel From Scratch... by preciousaang(m): 10:56pm On Jan 10, 2019 |
So let see some functionalities of controllers. We can pass data from controllers to views. All we have to do in pass a second argument into the view() function. This argument should be an associative array in which the key is the name of the data and the value is the actual data being passed.
|
Webmasters / Re: Learn Laravel From Scratch... by preciousaang(m): 10:08pm On Jan 10, 2019 |
Note: The way we return templates. The view() function accepts “/” or “.” as means of directory separators. And the we do not add the extension of the file we are returning. We just write the name of the file. In our case, instead of writing “frontend/index.blade.php”, we write “frontend.index”. Because if we write it as “frontend/index.blade.php”, laravel will take frontend, index and blade as folder names and php as the name of the file we are trying access.
|
Webmasters / Re: Learn Laravel From Scratch... by preciousaang(m): 9:46pm On Jan 10, 2019 |
But this is very stupid way for me to introduce controller since I introduced it as a badass function of Laravel. Sorry for that. Let’s get into the fun stuff with controllers. Well remember the first route we created, where we returned a view, well we originally do that in a controller. So let’s see how we can do that. But first let me create a folder in our views folder, you know, the folder where we keep our HTML files. Note that all files here must have the “.blade.php” extension. So you know how I’m always calling them HTML files, well I lied. They are actually called templates. So I’ll create a folder called frontend.
|
Webmasters / Re: Learn Laravel From Scratch... by preciousaang(m): 6:02pm On Jan 10, 2019 |
Please drop your comments for any question or corrections..................... |
Webmasters / Re: Learn Laravel From Scratch... by preciousaang(m): 6:01pm On Jan 10, 2019 |
So how do we make this work? Simple. We just go to web.php which is our routes folder to link the controller method/action to a URI. We write our unique URI name as we've done before, but this time instead of writing function next, we write the name of the controller followed by an "@", then the name of our method. 1 Like
|
Webmasters / Re: Learn Laravel From Scratch... by preciousaang(m): 5:52pm On Jan 10, 2019 |
Now that we have created our controller, let us look inside the file that was created. As you can see inside the file laravel automatically writes somethings inside for us. The first line tells laravel what folder the file is in. Note that they all title case. Let us forget about the second line for now and look at the class that was created. All we need to do in the class is create methods that we can connect routes to. So for that we create a public method called index, and return something with it.
|
Webmasters / Re: Learn Laravel From Scratch... by preciousaang(m): 4:56pm On Jan 10, 2019 |
That just about it. To see the controller, goto the project folder. Go into app > Http > Controllers. There you will see the new controller that you just created. Note: Every controller name as a matter of convention and good practice must end with the word “Controller”. Also note, I did not write firstcontroller or Firstcontroller. Writing controller names like this won’t give you any errors, but as a matter of conventions, it if required that you use camel casing. That is if you have more than one word as the name of the controller, make each of the words capital letter, then join them together. For example “test controller” becomes “TestController”, “sweet good controller” becomes “SweetGoodController”. 1 Like |
Webmasters / Re: Learn Laravel From Scratch... by preciousaang(m): 4:53pm On Jan 10, 2019 |
Introduction to controllers One awesome thing about Laravel is that it tries as much as possible to separate your HTML documents, routing, database manipulation, logic and many more other functionalities from each other for easy manipulation. As Nick Fury told Captain America in Avengers, “IT’S IS CALLED COMPARTMENTALIZATION”. Now one of the most vital compartments of Laravel is the “C” in MVC: Controllers. Controllers are where the most if not all our business logic takes place. I call it business logic because that’s what guys smarter than I am call it. What can I say, I’m pretty dumb. Steps in creating a controller 1. Navigate to your project folder using command prompt or powershell. 2. Type: php artisan make:controller FirstController where FirstController is the name of the controller.
|
Webmasters / Re: Learn Laravel From Scratch... by preciousaang(m): 3:42pm On Jan 09, 2019 |
You'll notice that in the screenshot I pasted, i am using port 2. i.e http://localhost:2 Don't let these confuse you. Th default port for Laravel is 8000. i.e http://localhost:8000 If you want to use a run your server in a different port, Type: php artisan serve --port 2 Where 2 is the port number u want to use A reason why you might want to use a different port is probably because another program might be using port 8000 or maybe port 8000 is not just responding, which is what is happening to me currently. 1 Like |
Webmasters / Re: Learn Laravel From Scratch... by preciousaang(m): 10:10pm On Jan 08, 2019 |
Now let's move ahead. Now let's look in the web.php which is in the routes folder. Let's take a look at the route that was created for use when we installed laravel. I'm talking about the Route::get('/', function () { return view('welcome'); }); You'll notice that it is returning a function called view() and view has a parameter of 'welcome'. Well view is a global function in Laravel that is used to call a view. What is a view? A view is the page returned to the user. And Laravel does a superb job of helping us separate them in a different folder. Now that brings use to the "resources"folder... Open the "resources" folder. Under it you will see a folder called views Under views, you'll see a file called "welcome.blade.php" Open it in your text editor and you'll see some familiar HTML files. Well this file is the file responsible for the page you see when you visit http://localhost:8000. Let us edit it. On line 84, change the word "Laravel" to "Welcome To My First Laravel View" If your server is not already on start it. And go to the homepage. Voila, your first view. You can edit it how ever you like.......
|
Webmasters / Re: Learn Laravel From Scratch... by preciousaang(m): 10:01pm On Jan 08, 2019 |
I know you must be asking yourself, What the hell is verb again? Well verbs are the methods which the browser uses to send requests to the server. The most common verbs which intermediate PHP programmers use are the POST and GET. And I can tell you that many intermediate PHP programmers only think you use this verb when you want to submit a form. "I used that ignorant too".... GET Every time you visit a page, you are making a GET request to the server. And this makes GET the most used verb on the internet. POST and GET like I said are not the only verbs available. We have others like UPDATE, DELETE, PUT, PATCH and OPTIONS... And Yes, we use the other verbs mostly when we want to submit forms in laravel. So Hurray, you were right. 1 Like |
Webmasters / Re: Learn Laravel From Scratch... by preciousaang(m): 9:49pm On Jan 08, 2019 |
Rules for creating routes in Laravel 1. No two routes can have the same URI and the same verb. 2. No two routes can have the same name(I will have to explain this in future; For now just accept it like that). 3. Do not put space between route URI. (Of course you should know this as I assume you are familiar with PHP). |
Webmasters / Re: Learn Laravel From Scratch... by preciousaang(m): 2:38pm On Jan 08, 2019 |
Please comment if you have any questions and corrections
|
Webmasters / Re: Learn Laravel From Scratch... by preciousaang(m): 2:29pm On Jan 08, 2019 |
[center]ROUTING[/center] The first thing I will be explaining in laravel is routing. And that has to do with routes folder in your project folder. I don’t need explain the meaning of routes, because like I said earlier, you should understand PHP to and intermediate level. Well, if you open your “routes folder”, you should see a file called web.php, that’s the file your want to open in your text editor. You should see something like this inside. Route::get('/', function () { return view('welcome'); }); Well as you can see this is a basic Laravel route. It accepts a URI, and a closure. This is the route to the page you are currently seeing in your browser when you visit http://localhost:8000. If you clean the whole thing and your try to reload the file, you will get a page not found error on your browser. To create your own route, go to a new line and type: Route::get(‘first-route’, function(){ return “This is my route”; }); Now in your browser, goto http://localhost:8000/first-route Voila, you get a message saying “This is my route”. |
Webmasters / Re: Learn Laravel From Scratch... by preciousaang(m): 2:26pm On Jan 08, 2019 |
Now that you’ve gotten Laravel installed, we can start the main stuff. Looking inside your project folder, you will see several folders. 1. App 2. Bootstrap 3. Config 4. Database 5. Public 6. Resources 7. Routes 8. Storage 9. Tests 10. Vendors Well, as a Nigerian, I know how impatient we can be when it comes to explaining things one by one. So I’m not going to bore you with everything. At least not now. The folders you need to worry about for now are the routes, app and resources folder. Then we’ll look at the storage and public folder later.
|
Webmasters / Re: Learn Laravel From Scratch... by preciousaang(m): 2:24pm On Jan 08, 2019 |
abdeiz: Yes, sorry for not mentioning that earlier. I can be a shitty teacher.... But here's a tip for you incase you can't be downloading fresh project everytime. Once you've downloaded a project the first time, duplicate the folder so you can reuse it when you like |
(Go Up)
Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health religion celebs tv-movies music-radio literature webmasters programming techmarket Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 42 |