Laravel 5.2 PHP Build a social network - Signup Controller & Model
HTML-код
- Опубликовано: 29 июн 2024
- Build a complete Social Network Web Application with PHP Laravel. In this video we'll create the signup controller and model as well as the necessary database entries.
Complete source code: github.com/mschwarzmueller/la...
Complete Laravel-course on Udemy: www.udemy.com/modern-web-deve... (Coupon: RUclips1)
In this course we'll build a neat little social network and cover the basics of developing with Laravel.
If you feel like doing so, please subscribe, like and share this course! All feedback is highly appreciated!
You can follow me on Twitter (@maxedapps), Facebook ( / academindchannel ) or visit our Website (www.academind.com).
See you in the videos! - Наука
For those who wondering if there is no File named "routes.php" in Laravel 5.3, you just need to use the File under the Routes Directory which is titled as "web.php"..Its the same..don't create "routes.php" or it may conflict. I wasted a lot of time figuring this out !
oh I had tge sane trouble. and ended up using web.php but i still get and Error like:
ReflectionException in Route.php line 335:
Function () does not exist
Do you have any idea how i can solve that?
Aqil Asadi Check if these lines within web.php are as follows
whooow, I missed uses as well :D buuut now it says
ReflectionException in Route.php line 339:
Class App\Http\Controllers\Request does not exist
And it is actually right I dont see anything such as Request inside Controllers
Aqil Asadi This UserController file should be placed within App\HTTP\Controllers.
In your "UserController.php" file only add this much.
oooooh dude you are tottaly AMAZING :D
Thank you for the time you've spent on this and the great job you've done. Im just starting with Laravel and your video is very useful! Im always respectful to the people like you, who spare their time to share their knowledge
Thanks so much Vladimir, I'm really happy to hear you're liking the content!
I have watched alot of Laravel guides and i have never learned as much as i have learned from this video alone. Good work, keep it up
That's really great to hear, many thanks for this awesome feedback!
Finally, someone showing how to build an authentication system from the ground up! Thanks a bunch!
Also, I like how you pronounce "view". "Phew".
That was the plan, I'm extremely happy that you liked it! :) I also work on my "View" pronouncement :D
Great! I'm really glad you didn't just say "just php artisan make:auth"!
Thank you so so much for creating this video series!!! I've been stuck on Laravel for over a month since January. I was so confused with how to use the Validator via their documentations and stuff. Subscribing and liking. :) #greatful
+Eric Liang
Hey, great to hear that!
Thanks a ton man! My suggestion to all of my friends those who ever wanna learn Laravel or just know how it works, after watching this particular series of videos , is a link to this particular series. (y)
Best of the Best.
Thanks once again for sharing your knowledge.
Many, many thanks for your great feedback Sumit! :)
Really am a beginner to laravel n I've wasted my time in searching other related guides in youtube which is waste of my time
But your video has helped me a lot and easy to understand !!
Keep on uploading sir!!
God bless U
Thanks so much for that amazing feedback Vasim! :)
great i am looking for a something to start laravel finally got 1 .Good job man! need more videos on laravel it would be great help for starters.
@Mindspace. Thanks for the awesome tutorial. I'm currently using php at my college and i'm enjoying php. Now it's time to step it up a notch with Laravel :)
Thanks so much for your nice feedback!
Thumbs up! thank you for the hard work and sharing knowledge to everyone. :) More power!
Many thanks for your amazing feedback John!
Another one great tutorial, thank you once again. Hope to do more of these videos with laravel great framework.
I got lot of plans! Happy to hear, that you like it!
I have been developing PHP applications with just coding and no framework and as I learn Laravel I'm literally laughing at how easy and intuitive it is.
It really is - happy to hear that my video was helpful to you! :)
Now, i use laravel 6, it`s very very amazing development of framework.
You are awesome... Thanks for your valuable time and making such a great tutorial.
Great Videos! Thank you for posting them!
+Jerin Oommen Thank you!
Wow you are awesome!!!!!i will watch all your videos.Thank you
Thanks so much - I'm really happy to hear you're liking it!
Works well! Thank you!
100% Perfectly Worked !!
Thank U Very Much Bro !! :D
Awesome to hear that Kistlak, thanks for your great feedback!
Great work man!
Great guide and really well executed! As you know alot of these methods have changed in laravel 7.x and I was wondering if you would update the guide to the current version?
Amazing Tutorial. If anybody having problem with not finding the routes.php for the new Laravel version, the same file exists in routes/web.php i.e the codes of routes.php in the video is to be written in web.php in routes directory.
For those who have and going to have a problem with 𝐌𝐞𝐭𝐡𝐨𝐝𝐍𝐨𝐭𝐀𝐥𝐥𝐨𝐰𝐞𝐝𝐇𝐭𝐭𝐩𝐄𝐱𝐜𝐞𝐩𝐭𝐢𝐨𝐧, and you are sure that method in form is correct and you using the right method in web.php route file.
The problem occurs when you have two forms one has and action but the other one does not have, and somehow they get in conflict trough sending. They both need to have action(just make one for the sign-in) or just comment out the sign-in form or just put # in an action of second form. Trust me guys, it works.
thanks, very good video, nice work! Please, continue doing it!
+Captain Bamboo
Hi, great you like it! Of course I'll continue the series. :)
Good job mate ! You really helped me allot
That's great to hear, many thanks for the feedback! :)
First of all. Thank you for your video! It is gr8 for beginners!
laravelcollective/html is better for forms
and to many code for postSignUp function
Better to make new request vith validation, create users with several lines of code by requesting all with protected $fillable fields and setPasswordAttribute to bycript.
+Jurij Rizhov
Hi, great to hear you like the videos. Yes you can always include other packages to add functionality and potentially make your development process easier. But when I teach certain concepts I want to talk about the core topic of the video and not distract with a couple of other packages etc. included.
Awesome videos...
Thanx for posting
I'm very happy to hear that you're enjoying it! :)
Thank you for this video!!
Thanks so much for your comment!
I really enjoyed using middleware in routing.
Sounds great! :)
thank you so much for this effort !!
You're welcome, I'm happy to hear that it helped! :)
+Mindspace help a lot
you're amazing man thank you
+Motassem Syrian
Thank you so much Motassem!
Hey Max!, outstanding tutorials man, one of the best series i've seen!. I'm a beginner and at first i didn't understand diddly squat about the first 20 min. of your first video, it took me 3 or 4 days to set up a development enviroment, and i went with Xampp and Sublime Text 2 (just because i could'nt figure out what IDE you're using in your videos), but your way of teaching is revolutionary and i find it very easy to learn and fun.
Now, i was able to follow step by step everything you do in your videos perfectly, but i have encountered a problem with MySQL which is that i can't run the migrate command "php artisan migrate" in the windows cmd because it gives the following error:
[PDOException]
SQLSTATE[HY000] [1045] Access denied for user 'homestead'@'localhost'
Any way you could help? Thanks.
+El Julian
Hi Julian, I'm really happy to hear that you're enjoying the videos. I'll also soon release videos about my IDEs.
Regarding your error: Are you using homestead? Probably not since you mention xampp. You have to adjust the db connection settings in your .env file to reflect your actual database in your xampp setup (i.e. the database name, username and password)
Hey, I got the same error, but much later in the tutorial. I got it around minute 23, after I enter an example email, name and password. My error also says 'homestead' although I am not sure where it is gettting that name. My .env file matches everything correctly, even the information on my phpmyadmin.
I get these errors:
(2/2) QueryException
SQLSTATE[HY000] [1045] Access denied for user 'homestead'@'localhost' (using password: YES) (SQL: insert into `users` (`email`, `first_name`, `password`, `updated_at`, `created_at`) values (test@test.com, jose, $2y$10$CwJjMRwXPkn.gA69ujd1se1it5TFIcI1pyuR1yw9dQAJRnD4YtxA2, 2017-06-17 02:00:13, 2017-06-17 02:00:13))
(1/2) PDOException
SQLSTATE[HY000] [1045] Access denied for user 'homestead'@'localhost' (using password: YES)
I hope you will be able to help me, thanks!
Ooffs !!!:-)
I got the program after 2 days with no error Got a perfect output So happy :-) And very very thanks for the help
Great to hear that! :)
this video very good ! I got it . thanks~~
Thanks for the vid!
Happy to hear you liked it Craig!
You really look like Seth Rogen haha, btw your tuitorial is great!
+Lester Dave Guerrero
I've heard that from time to time ;) Happy to hear you're liking the videos!
i suggest when making controller file use this command to avoid problems later and to develop a good habit of let the ready made tools do the work for you.
"php artisan make:controller UserController"
I do see your point, but I argue that it's extremely important to understand what's happening in the background. If you use tools and shortcuts all over the place, you'll be faster (and possibly safer), but you don't know how the framework works, what's happening.
Once you got the basics, there of course is nothing wrong about using these shortcuts.
Only my opinion of course
Really A beginner And Got some Errors firstly got Really frustrated.........Again solving one did leave me to another Error but i didn't gave up and solved at last....Errors like Web Class.....Function() not found and Query Error and all the stuff but Solved it hopefully
Really Great Videos And also Looking Forward to your Paid 20$ Tutorial to learn deeply after This Series of Tutorial For the same Laravel...
That's amazing to hear! I know how frustrating errors can be, but digging through them on your own will help you so much! Great job!
did all this and when i click submit error *Sorry, the page you are looking for could not be found*
Wow ...... you are awesome.....
+Shaon Islam
Haha, thank you! But what's really awesome, is the fact that you're enjoying it and I manage to pass my knowledge on Laravel. I'm really happy that I'm able to share :)
+Mindspace
i am enjoying the way you are teaching ......
basically i am new in learning laravel....
i am trying to learn laravel ......
can you suggest me what to follow to learn and start working with laravel ......
thanks in advance ..... :)
I think a good next step is to google for Laravel examples and other tutorials. Also create little "fun projects" in which you try out different things and practice with your newly gained knowledge.
If you are using Laravel 7 , Routes are now defined in the Routes folder under web.php
great tutorial :-)
+Wasid Hossain (Ocean)
Great to hear this, thank you :)
Thanks a lottt sir for creating this series :) Already liked and subscribed the channel. Your Udemy courses are also really helpful. I just have a doubt in this 3rd video, I don't have Route.php file in Http folder . Maybe the folder structure is changed. I just installed setup on 15th july 2020. I would be really grateful to you if you could guide me:)
Hello man! Thanks for great videos so much! Will you use Laravelcollective?
Nope, I don't use that throughout the series, I think you learn the most if you don't use all the packages/ helpers available ;)
Which IDE you use in your Sublime? Sorry if this question is fool, but it's so simple for you in the moment of Request parameter class (when the editor suggest to you the class) and it added the use package automatically...
+Jhonatan Costa Westphal
I don't use Sublime, I use PHPStorm by Jetbrains.
Hello, Thanks for all tutorials (i'm French) but I clearly understand what you said in your videos :)
But, i'm just stuck at 18:30
Laravel decided to remove routes.php so I can't find this file.. They talked about a RouteServiceProvider method or use the new method for defining routes
How can we use this instead of routes.php ?
Thanks ;)
I have finaly found !
I use the last update (5.3) of Lavarel, and in this version, route are separated in the folder ./routes in two files:
- Web.php
- Api .php
I just put the code in Web.php and now it works :p
I'm happy you're enjoying my videos :)
Regarding your issue: Actually it's not that complicated, there's a new routes folder now. There, you have two files. Use the web.php file for your routes (the api.php file is needed for API apps - e.g. RESTful services built with Laravel).
@@academind Actually i tried that and still got error ! May be because of version issue ...
Great videos! But I thought you might want to make a note that the "Web Middleware" is always on by default now, so you don't have to group your routes for it.
+MaxWilder
Hi, I'm happy you're liking it. I know, the videos are a bit older. I have added an annotation in the first video where I tell people that this group is important (the validation video) but you still see the placement in all videos as I can't edit them after uploading unfortunately.
+Mindspace
So if i understood right, in root file there is no necessary to put routes in groupe ?
I just wondering, if i put routes in groupe i get error: "nesting reached 100" but if i put routs out of group all is good... Greate videos thanks!
The web middleware is no longer needed, yes
Hi, great tutorial. What editor are you using?
Hi, what laravel helper plugin do you recommend or use for syntax highlighting or lets say if you write $user = new Use()r; it will automatically use the correct namespace at top, etc?
I use PHPStorm as an IDE and it has this functionality built-in. I don't know any plugins for other editors/ IDEs, simply because I haven't used them for Laravel development for a very long time. :/
When you created the Migration Users, add added the 'db fields' you didn't have first_name,
and at the end when you inserted the value it showed up.
When that field was created ?
To me looks like it was created during a pause time of the video.
You could use the default authentication template from laravel.
Yes, but you definitely learn more if you don't use everything/ every shortcut which is built in. I think it's important to understand (at least a bit more than with the built-in templates) what actually happens.
As of Laravel 5.2 you can now use the Blade built-in function {{ csrf_field() }} to generate the hidden input field.
Yes, I know, but I believe it's important to understand what's being generated behind the scenes. Of course using helpers/"magic" in "real" projects makes sense, but for learning it, you should know what happens :)
I think it would do better if you showed the source code of the page on the browser, that way you'd show the quick way AND better explain what it does ;)
I see your point, that's a good idea indeed!
Does the route file include any 'namespace's or 'use's? I am currently using laravel 5.4 and there wasn't a default route.php and I had to create my own.
After you manually delete the migration run:
composer dump-autoload to clear the cache
Great videos! can you please tell me how can we make admin to manage users/posts ?
please please please make a video on managing users and roles in laravel 5.2 .
Thanks :)
+Adeel Fiaz
Hi, I'll soon create such a video :)
+Mindspace Great.. Really waiting for next videos :)
not sure was this possible at time of recording of video, but when you create new entry isnt it simpler just to use
$data = $request->only('name','email','password');
$data['password'] = bcrypt($data['password']);
$user = User::create($data);
I get the following error when I click sign up NotFoundHttpException in RouteCollection.php line 161 :(
I had some problems with route, since the laravel updated after your video, but I seem to solve it, now the problem is:
ReflectionException in Route.php line 335:
Function () does not exist
seems like the function was changed since than or renamed?
Your help would be amazing, and thanx for the tutorials.
did you resolved your error ?
Also, rewatching the video, why do you have to setup the Route::post to the /signup page as the first parameter? I mean, the page straight up calls the route on the form action. (not saying that anything would work, but IDK why would I need to call it in the first place)
Any route that isn't ::get already confuses the hell out of me because with "get" we're talking about data that's on the URI, but we don't have this for other types.
You should maybe have a look at some basic tutorials on GET and POST requests. The POST request sends the data with the body of the request instead of the URL.
Hi!
In first place thank you for your awsome videos... That was i'm searching for, auth from scratch as i'm struggling with default Laravel implementation trying to understand what happens in background. You use {{ Session::token() }} i supose that {!! csrf_field() !!} will be the same thing but for all line of input hiden ?
Waiting for more :)
+José Longo
Yes you can use {!! csrf_field !!} instead of .
It is short I guess, I just prefer the other way ;-)
+José Longo It didnt' work for me too. But it worked after using this.
Hi guys, I am getting "404 Not Found" after clicking the submit button. The path is localhost:63342/iConfess/public/index.php/signup. I am not sure what is the issue here. I followed every step from this video. Can someone please assist me on this?
Hi Mindspace, Great tutorial. really helped me a lot
Would u mind to tell me the IDE that u were using in this video?
I'm very happy that you learned a lot and liked it! I use PHPStorm by Jetbrains.
Thanks
See this if you want to configure it like PHPStorm + laravel + WAMP
laracasts.com/discuss/channels/laravel/setup-laravel-5-through-phpstorm-via-composer-for-wampserver-3
i'm having this problem
MethodNotAllowedHttpException in RouteCollection.php line 218:
could you help me please ?
Hi
Can i get som help please ? I got this error ( and i think i ve did it exactly like in this tutorial but..
1/1
FatalErrorException in UserController.php line 15:
Class 'App\Http\Controllers\User' not found
in UserController.php line 15
on line 15 is $user = new User();
+Pecunia Loquitur
You're probably missing the user import at the top of the file:
=> use App\User;
Importing App\Http\Controller\User is wrong, this should just be 'use App\Http\Controller'
+Mindspace Thank you very much , that was the problem. It works now !
I have to be more watchful at the next videos ...You are doing a great job here , and you have all my respectful for these hours spended on making videos for newbies like me .
Hi, I tried upgrading my existing laravel 5.1 project by updating composer.json and doing a composer update. However I'm getting this error now "ReflectionException in Container.php line 738: Class web does not exist".
You just said that the "web" middleware is new to 5.2. So does it mean my app hasn't been updated yet? What should I do? Sorry if it's a noob question and thanks for the videos.
+Sankhadeep Roy
Hi, I think it's best if I link the official upgrade guide which explains all steps necessary to upgrade your Laravel app: laravel.com/docs/5.2/upgrade
I hope this helps you!
sir i am big fan of your programming i am learning laravel with your chanel and i feel like i am in the classroom.but i am facing a little problem related to design .when i put the field {{session::token()}} in blade page than i got form will hide.i have face problem only one form which is responsive.
Thanks for your effort
please can u explain how to upload video?
Good video. I am slowly getting there. I came across the
TokenmismatchException
error when I ran it in Mozilla Firefox and it was under the Middleware Section.
But when I run it in Chrome, it works fine. Is there a particular reason behind this? Should we only be testing with Chrome?
+Dale Pinn
Uhm, it should work fine in all browsers. This error occurs if you forget to pass the token in the hidden input field. The fact that it works in one browser but not in the others is very strange... Maybe some security setting in Firefox which prevents cookies or something like that?
Very very helpful tutorial... very nice clarification of each concept... How can I contact you if I want to have some help from you on any topic?
Thank you very much :)
Well to be honest I currently don't really have time to offer any 1-to-1 coaching ;-). But in general the best way will be to send me a message through my Facebook channel (facebook.com/mindspacechannel/). I'll then see what I can do.
+Rahul Sharda At least go ahead and buy @MindSpace's Udemy course before asking free consultation. People have to feed their family too. :)
what did you do to fix the error, right before the end of this video?
Super good tutorial from you, but I've got a problem when I click on register button
____
Not Found
The requested URL /mamp/laravel/public/signup was not found on this server.
___
I use web.php in routes folder that I'm using another version of laravel
I'm having the same problem. Did you solve yours? How do I solve this?
MethodNotAllowedHttpException in RouteCollection.php line 233:
Can anyone help me?
I'm lost at the 17:00 mark in the video. I do not know what information to type, and what program are you using at 17:53? I am using Windows 10, so I downloaded MySQL workbench, but no luck connecting it to my c9.
I'm new to server-side, new databases, new to laravel.
+MarketWolf
Hi, sorry to hear that. I didn't explain more about it since the program is not needed for the app to work. Sometimes it's just nice to have a look at the database.
Since you're on Cloud9, the quickest way to access your db would be to use 'phpmyadmin'. Here you'll find an explanation how to set it up on Cloud 9: c9.io/blog/phpmyadmin/
+Mindspace Thank you so much! I purchased your class on Udemy. I hope to learn a lot from you.
I'm sure you will, I wish you a lot of fun with the course there!
Hi, your videos are really helpful. i am on laravel 5.7 and i noticed there are different route files. i was able to put this code in api.php
Route::group(['middleware' => ['web']], function () {
Route::post('/signup', [
'uses' => 'UserController@postSignUp',
'as' => 'signup'
]);
});
rest is the same. but when i try to click on submit it says 419 session expired. what am i doing wrong?
Thank you for your video. It's very useful. I have a problem. Could you help me?
"Could not open input file: artisan". What should I do without removing this laravel project to install again?
make sure your command line on base directory of ur project.
bachtiar panjaitan I fixed! Thanks ☺
MethodNotAllowedHttpException is the error i get .what must be the problem ? middleware is undefined group so i used the defined route under the default route
Hi while doing php artisan migrate it throws me the following exception
[Illuminate\Database\QueryException]
SQLSTATE[HY000] [1049] Unknown database 'forge' (SQL: select * from information_schema.tables where table_schema =
forge and table_name = migrations)
Any ideas
Hi ! Thanks for the video.
Why not use Blade enginee form syntax?
It's not part of Laravel anymore. Yes you can still add it, but I never liked it. I prefer to write my forms myself - and especially in a tutorial video it may be the better approach, as you see what's actually happening behind the scenes
Mindspace Thanks for reply. I'm working with laravel 5.0 and I need to make a login authentication, your tutorial has the best didactic. No problem to follow you with my version? Do you have a specific video only about Auth? Thanks for the videos!
No, right now I don't have a pure-auth video, though that may change in the future ;)
thanks
Thank you for your comment Willy!
can you say me which editor are you using please?
Ist das Video veraltet, sodass nur der Aufruf über ein Webserver ("php artisan serve") funktioniert?
I am getting
[BadMethodCallException]
Method varchar does not exist.
error when I run 'php artisan migrate'. It create migration table but doesn't create users table, what should I do?
i have this error when i press submit
ErrorException in UserController.php line 29:
Use of undefined constant - assumed ''
can help me please?
Hi! What did you erase Auth directory from Controllers? Now when I'm posting users data at signup I get this error: NotFoundHttpException in RouteCollection.php line 161
I don't need the Auth directory since I'm writing the Auth logic myself throughout this series.
Regarding the error: As the error implies => You seem to be missing some route. Maybe you missed to name it or have a typo in a route name.
hi i work on laravel 6 and i get that mistake
Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException
The POST method is not supported for this route. Supported methods: GET, HEAD.
Help here!
just when i am clicking on the "submit" button, there are multiple errors: "/1) NotFoundHttpException" )
inRouteCollection
at Kernel e.t.c
everything was working fine in my laravel but i notice that there is no Requests folder ... and policies and provider folder.
First , thanks you so much for your series.
I have one problem, can you help me ?
When I run "php artisan migrate" I received in command window :
"[ReflectionException]
Class App\Http\Controllers\Auth\AuthController does not exist".
So I can't go to next step :(
+Nguyễn Mạnh
You probably still have the default migration files, Laravel creates automatically upon installation. If you're not using Laravel's default User model, you may just get rid of those two migration files you find in the "migration" folder
+Mindspace Tks you !
hm... it works now without moving that route in middleware, should I leave it seperate or move it inside and why
The web middleware isn't needed anymore (with the latest version of Laravel).
jus tsaw in release notes
'keep in mind the web middleware group is already applied to your routes by default since the RouteServiceProvider includes it in the default middleware group'
thanks
hi, thanks for this great tutorial :) I have some troubles. 1st, I do not have Route::group in my routes.php file. Then, I've written the same code that you wrote. When I click the submit button, it throws an error => "working_directory_name/signup was not found on this server". What can I do in this situation? Please, help me. I use Laravel Framework version 5.2.37
Hi Soltan,
happy to hear that you're enjoying it! Route::group() with the "web" middleware is no longer needed. The other error sounds a bit like a server error. Is your server configured correctly to point towards the public folder of your Laravel project?
if it is not needed, than how should I write the code in routes.php file? Is to wrte ony inside of Route::group ?
The other error, I think it is looking for a signup.php file, isn't it? Because, when I run the code "php artisan migrate" it worked well. What you mean, when you saying configured correctly? I cant get it. I think, it works well, because, signup and signin forms are seen on browser.
I solved the problem. I am sharing the how to solve this problem to guys who have the same problem. Follow the steps in this link stackoverflow.com/questions/28242495/laravel-the-requested-url-was-not-found-on-this-server
For Laravel 5.7 there is no app/routes.php. You now use routes/web.php. When adding the postSignUp route, you no longer use an array. Instead write
Route::post('/signup', 'UserController@postSignUp')->name('signup');
You also do not need to put this inside the web middleware group as this is now handled by the RouteServiceProvider.
You will also need to add a hidden csrf field to the form with @csrf or you will get an error that your session has timed out.
i am using laravel 5.4 does this work on laravel 5.4?? can i do the same thing u did??
When clicking submit i get the error page, 1/1 NotFoundHttpException in RouteCollection.php line 179 , not a clue what i did wrong but then again im running a new version of laravel than this video tutorial.
The same !! Did You Solve It ??
has anyone figured this out?
Hi, thanks for the tutorial. I have a problem. In my homepage I have a modal that has two tabs one for signUp and the other for signIn. I tried setting a tag for each tab but cant seem to work. Please help me out. Thanks
Hi, I think you also messages me on Facebook. As I wrote there, I'm happy to help with any video related questions. I'd love to also help with questions which are a bit beyond the video scope, but I simply can't do that for close to 10.000 subscribers - simply due to time restrictions.
Thats fine, this message was posted before my message on facebook. pardon me.
What font are you using in PhpStorm?
Can I use my old database in Laravel 5.2? And what if my old user table has own auth, will laravel can read it?
+Danna whaha
You may use your old database but if you want to use Eloquent (i.e. access the database through your Models) you have to make sure that the correct tables are associated (=> protected $table property in the Model classes).
Why are the tables and model naming conventions disconnected? i.e users and user. As they are two very different things.
Not sure if I understand you correctly. It's simply a (Laravel) convention to have the Model name being the singular version of the object (i.e. User) with the database table being the plural version of that (i.e. users). That's how Laravel will try to find tables for models when using Eloquent.
Cheers for the reply, awesome tutorial btw. It was just one of those little things with Laravel that I'm going to have to get use to as it's a bit odd.
Using the -m keep failing to create the database migration file. so i created it manually and now when i migrate. it shows migration file but empty and no users table in db
I found a solution of it. Run the command: composer dump-autoload and then php artisan make:model User -m
You will get the following response:
C:\xampp\htdocs\adfun>php artisan make:model User -m
Model created successfully.
Created Migration: 2016_08_26_111059_create_users_table
Thanks
thank you very much man
Thank You
Your'e a life saver!!!
im getting a redirection error to /login after adding '/' welcome route inside the middleware group it works when i leave it outside
nvm lol had to do this ['middleware' => ['web']]
Cool stuff. I don't know how much you've improved your speaking now, but I suggest you should make a clear and concise explanation/sentence first, then say it to the audience. You can edit the video later.
Hi Kazma,
thanks for your feedback. I'm not a native speaker but I get a lot of feedback that people like my explanations and are able to follow them quite well. If I would start reading sentence from paper my videos would really suck and it would not be me anymore. I'll stay who I am and live with some occasional errors ;)
thnks
Thank YOU osama!
WHy can't you just create the controller with "php artisan make:controller User" ?? btw good tutorial. Will buy your course at udemy this week :)
+Jay Mayu (Mayooresan)
Hi Jay,
good question (received the same one in my Udemy course btw. ;-). The answer is simple: I can. But creating controllers is really easy and I'm convinced you learn more (both about a framework as well as PHP/Developing itself) if you don't 'outsource' or automate every task that could be automated. That's the only reason. I will use php artisan to create models, migrations etc.
Mindspace That makes sense. Thanks for taking time to reply :)
I am receiving the following error when I ran the command in the terminal:
C:\xampp\htdocs\adfun>php artisan make:model User -m
Model created successfully.
[ErrorException]
include(C:\xampp\htdocs\adfun\vendor\composer/../../database/migrations/2014_10_12_000000_create_users_table.php): failed to open stream: No such file or directory
Will you please guide me in this regard.
I found a solution of it. Run the command: composer dump-autoload and then php artisan make:model User -m
You will get the following response:
C:\xampp\htdocs\adfun>php artisan make:model User -m
Model created successfully.
Created Migration: 2016_08_26_111059_create_users_table
thank you very much
My Pleasure!