Laravel: How to Name Various Things

  Рет қаралды 31,494

Laravel Daily

Laravel Daily

Күн бұрын

Пікірлер: 91
@digvijaychauhan2000
@digvijaychauhan2000 3 жыл бұрын
No matter how experienced, it's better to be naive and keep relearning. Appreciate your time.
@brianochieng5904
@brianochieng5904 2 жыл бұрын
Thanks Povilas "Cruddy by Design" - Adam Wathan - Laracon US 2017 is the one of the best recommendations you'v shared besides your amazing Knowledge.
@rolanddecasa4438
@rolanddecasa4438 3 жыл бұрын
Finally a video for naming schemes in laravel. thank you for this sir. Big help to us!
@poplach
@poplach 3 жыл бұрын
First I thought this video is reuploaded, since too many deja-vu happened - I've already seen you talking about naming and recommending Adam Wathan's video about CRUDs. But no - you have a new mic on the video so it is new. As to the topic - I believe it is one of the most important stuff to have everything organized, and more videos you make about that - the better it is for everyone following you and watching your videos. Thanks for that link to Adam Wathans video, I've seen it like 5 months ago and his way of seeing things and programming (yes, since then I've done his Test Driven Laravel) it totally changed the way I'm doing stuff now. Like even for simple projects I'm making as many Controllers as needed sticking to CRUD methods only. All that makes my code very clean and readable. Like a huge library where every book has its own shelve and everybody knows where to find it.
@IlPandax
@IlPandax 3 жыл бұрын
Great video that all Laravel developer should watch and remember.
@NiKaabir
@NiKaabir 3 жыл бұрын
One of the most helpful channels for laravel developers.. Plz upload some videos for beginners and cover all the topics from the ground up...
@jijogj
@jijogj 3 жыл бұрын
Thank you. Im a developer from India. Recently started using laravel and lumen. Your videos are very informative.
@prykris
@prykris 3 жыл бұрын
I'm truly amazed how big proportion of his audience originates from south asia, mostly india. Why is that?
@LaravelDaily
@LaravelDaily 3 жыл бұрын
@@prykris Very big country, a lot of developers from there. In comparison, Latvia is a much smaller country. So that proportion is natural, I think :)
@madrise007
@madrise007 2 жыл бұрын
finally found this video, thanks Sir, great video
@jefflroberts
@jefflroberts 3 жыл бұрын
I just wanted to mention that sometimes in a large project, naming your view index.blade.php, show.blade.php, as so on can make it challenging to find files using ctrl-p in vs code. We have a pretty big system with lots of sub-modules and many views within each of those modules. When you press ctrl-p and start typing "show" you get a lot of results and it is not easy to find the show.blade.php view you are looking for. If I were creating this system again I would definitely consider adding the entity as a prefix to the action name of the blade files. I'd be curious to how others have addressed this as well. Thanks for a great video as always Povilas!
@LaravelDaily
@LaravelDaily 3 жыл бұрын
Valid point, but in such case I rarely type "show" in search, more like "article show" which finds exactly what I need.
@jefflroberts
@jefflroberts 3 жыл бұрын
@@LaravelDaily That is true. I may need to just modify my search behavior some. The issue I was reminded of is that we have lots and lots of reports in this system (project) and I named the folder the templates were in the same as the report title and I named the main template for each report "report.blade.php" as well as there are some partials in each folder named something like "footer.blade.php" or "header.blade.php" and it has become somewhat of an issue to manager.
@BishalAdhikarii
@BishalAdhikarii Жыл бұрын
modularize them project!
@SebastianMares
@SebastianMares 3 жыл бұрын
How do you deal with things that are not related to a specific model, such as user registration or login? What about something like adding a PDF download option for a book? Would you do a separate controller just for that with the show method returning the PDF or would you handle it in the same controller as for the books?
@Moles666
@Moles666 3 жыл бұрын
Hi Povilas, Could you please create a video about caching? Memcached and Redis?
@LaravelDaily
@LaravelDaily 3 жыл бұрын
Maybe sometime in the future. Added to the (already huge) to-do list.
@msdeav
@msdeav 3 жыл бұрын
@@LaravelDaily waiting for this...
@TioJobs
@TioJobs 3 жыл бұрын
Awesome video! Thanks Povilas from Brazil.
@ashikmehermobin9926
@ashikmehermobin9926 3 жыл бұрын
All in one place ❤️
@thandohlophe926
@thandohlophe926 3 жыл бұрын
wow!!!! this just elevated my coding logic!!!
@evolveint
@evolveint 2 жыл бұрын
Wonderful, but can you explain your recommendation with news model. I think it's a individual case
@bobbyiliev_
@bobbyiliev_ 3 жыл бұрын
This is awesome! I think that the same video but for Livewire would be very beneficial too!
@tirsolecointere
@tirsolecointere 3 жыл бұрын
Thanks for the video! Is there any convention or recommended way for naming permissions?
@prykris
@prykris 3 жыл бұрын
Hi Povilas, great video however I'm taking the privilege of being one of the first to comment and ask you a question about controllers. What should I do if I have two controllers that revolve around same model, but is under different path designed to be used by selected set of users, say admins. For this example, is following approach good practice - take User model and have UserController under User namespace for user and have new controller with same name under Admin namespace for admins. Love from Latvia!
@LaravelDaily
@LaravelDaily 3 жыл бұрын
I recently asked the same thing to my Twitter audience, read the replies please :) twitter.com/PovilasKorop/status/1361306825187086338 Love back from Lithuania!
@nlangerdev
@nlangerdev 3 жыл бұрын
Personally I use plural for controllers and singular for models. That way when I read something like new Order it makes more sense to me than new Orders. So OrdersController & Order Model
@808567640220
@808567640220 2 жыл бұрын
Thank you
@BelFaRo2008
@BelFaRo2008 3 жыл бұрын
It's even more complicated... plural of "Buch" is "Bücher" As you mentioned: Never use any other language than english in your code ;)
@LaravelDaily
@LaravelDaily 3 жыл бұрын
Oh right, irregular noun, my German from high school is dying from no practice since then :)
@ricko13
@ricko13 3 жыл бұрын
Such a helpful video! thank you
@mackynyxz
@mackynyxz 3 жыл бұрын
Thanks for this. this is helpful!
@codewithtee
@codewithtee 3 жыл бұрын
Watching this gives me pleasure
@alila3883
@alila3883 3 жыл бұрын
I have a problem with table naming that has two words Ex. order_items In my case, I have a Product model and an Order model so I want to name the right practice name : is it order_items or item_orders? Thank Mr. Povilas
@LaravelDaily
@LaravelDaily 3 жыл бұрын
Personal preference, whatever is more clear for yourself.
@konakonaxiong7621
@konakonaxiong7621 2 жыл бұрын
你问了一个很有哲理现象的问题。不过这里简单一点就好,根据上级关系定义先后顺序就好。我比较推荐你用order_items。
@gamehubby
@gamehubby 3 жыл бұрын
Nice vid as always. Do you have a video snippet how to make a proper testing approach with laravel specially with just API testing also how to run the testing faster.
@LaravelDaily
@LaravelDaily 3 жыл бұрын
Nothing specifically about that. Run testing faster needs debugging, where exactly it's slow for you - database migrations, API requests, etc. Can be many reasons.
@gamehubby
@gamehubby 3 жыл бұрын
@@LaravelDaily it's slow in migration
@LaravelDaily
@LaravelDaily 3 жыл бұрын
@@gamehubby Maybe try schema dump? laravel.com/docs/8.x/migrations#squashing-migrations
@FranChen1984
@FranChen1984 3 жыл бұрын
I have the same confuse recently !
@devendergupta_official
@devendergupta_official 3 жыл бұрын
For creating migration with existing tables you can do, php artisan make: migration AddUserIdToCompanies
@dndhndn
@dndhndn 3 жыл бұрын
how about the URLs prefix for a resource? is it using plural or singular?
@omartarek6441
@omartarek6441 3 жыл бұрын
Thank you for the video!
@debjit21
@debjit21 3 жыл бұрын
As always very good content.
@antt0023
@antt0023 3 жыл бұрын
Helpful thanks.
@meetdave7659
@meetdave7659 3 жыл бұрын
Please help me find out the Best Formattor for Laravel Development in VS Code in 2021.
@mcflybigfoot4972
@mcflybigfoot4972 3 жыл бұрын
Migration table names are guessed by: TableGuesser (\Illuminate\Database\Console\Migrations\TableGuesser) It defines the patterns for for this behaviors: const CREATE_PATTERNS = [ '/^create_(\w+)_table$/', '/^create_(\w+)$/', ]; const CHANGE_PATTERNS = [ '/_(to|from|in)_(\w+)_table$/', '/_(to|from|in)_(\w+)$/', ]; The table names come from the "(\w+)" match.
@Akosiyawin
@Akosiyawin 3 жыл бұрын
This is what I'm looking for
@kennedymwenda3357
@kennedymwenda3357 3 жыл бұрын
Say something about "SingleActionController" Dries Vints create of blade-ui-kit prefers that over Resources controllers. Reason: Easy code reading & maintainability
@LaravelDaily
@LaravelDaily 3 жыл бұрын
I'm not a big fan of them, but that's personal reference. I don't like 100 Controllers in my code base, I prefer 10-20.
@CodingBirdsOnline
@CodingBirdsOnline 3 жыл бұрын
Loved This ❤️
@nikitasmirnovs6113
@nikitasmirnovs6113 3 жыл бұрын
What about suffixes for Interfaces?
@Skylence_
@Skylence_ 3 жыл бұрын
In a company how can it best be applied? I'd assume you can set up a wiki with best practices and what will be accepted and not as commits? And everybody is kind of required to set up linters on their ide's or you make a general company linter configuration for one or more ide's, everybody should uses the same ide? Magento code is tough with naming conventions and best practices, especially with xml tags, some tag names matter, others not at all but then you name it anyway so now it looks like it matters.
@LaravelDaily
@LaravelDaily 3 жыл бұрын
1. Identical IDE configs 2. Some Code checking of every commit, on a staging server or before deployment, with tools like CodeSniffer, etc 3. Code reviews from the team Not sure about Magento, thought, haven't worked with it.
@marczello8162
@marczello8162 3 жыл бұрын
Laravel is some strange with this. In example in /App/Http/ Laravel create folders Controllers, Requests, Rules (plural) etc, but we also have folder Middleware (singular)
@masahiroyasuda8608
@masahiroyasuda8608 3 жыл бұрын
Nice video👍
@Akosiyawin
@Akosiyawin 3 жыл бұрын
Should I use resource file even if I'm using only two methods on it
@madrise007
@madrise007 2 жыл бұрын
sir, how to name route URL ? is it good if it contains a capital case (ex : laravel.test/UserDashboard), or should it use "-" (ex : laravel.test/user-dashboard) to separate long slug names? Thanks
@LaravelDaily
@LaravelDaily 2 жыл бұрын
It's your personal preference
@madrise007
@madrise007 2 жыл бұрын
@@LaravelDaily How about your preference sir? Do you use hyphens or capital cases? Thanks
@LaravelDaily
@LaravelDaily 2 жыл бұрын
Hyphens.
@madrise007
@madrise007 2 жыл бұрын
@@LaravelDaily Thank you so much Sir
@Skylence_
@Skylence_ 3 жыл бұрын
I wonder how far you could actually go with emoji's in programming from a fresh laravel installation 😅 just for fun. Would i be able to use 🐇 as controller and model? 🐇Controller 🐰 = Model
@LaravelDaily
@LaravelDaily 3 жыл бұрын
Sure! github.com/spatie/emoji
@Skylence_
@Skylence_ 3 жыл бұрын
@@LaravelDaily i mean can the controller or model actually use the classname "😄🐰🐇". Would MySQL also accept table names as emoji's too? I assume not.
@LaravelDaily
@LaravelDaily 3 жыл бұрын
@@Skylence_ Nah, unfortunately MySQL doesn't have that level of sense of humor.
@Skylence_
@Skylence_ 3 жыл бұрын
@@LaravelDaily i'm gonna try in the weekend with laravel and vue as SPA 😄 i bet Javascript should be capable to deal with emoji's. Like not in values but actually function names and perhaps vue routes. 🤔
@computer23able
@computer23able 3 жыл бұрын
my teacher told : BooksController plural - singular model usermodel - db plural : users
@Tomas-js4wt
@Tomas-js4wt 3 жыл бұрын
I noticed you are not using "declare (strict_types = 1);". Don’t you need it or don’t like it for any reason? Isn’t that necessary when working with Laravel at all?
@MrL22
@MrL22 3 жыл бұрын
I do find it quite annoying at times as you get Models like "Country" but the table is assumed to be "countys" unless you set $table = 'countries'.
@cutiex7357
@cutiex7357 3 жыл бұрын
DAMN you have the most useful videos EVERRRRR
@Fazz321
@Fazz321 3 жыл бұрын
I was taught to make all names for db entities singular in university, I'll stick to that.
@nikitasmirnovs6113
@nikitasmirnovs6113 3 жыл бұрын
you set $table property in every model manually?
@Fazz321
@Fazz321 3 жыл бұрын
@@nikitasmirnovs6113 well, yep, but this is the only downside, and it's not like I can miss it.
@ritomukherjee8389
@ritomukherjee8389 3 жыл бұрын
Hi, expert I have a laravel project for one of my client, in 5.4.36,& I want to upgrade it to at least laravel 7.x. Please help me out, on how can it be done the most esiet but scalable way. FYI it is an e-commerce project
@LaravelDaily
@LaravelDaily 3 жыл бұрын
Try laravelshift.com and then you would have to do manual work on top. There's no *easy* way.
@ritomukherjee8389
@ritomukherjee8389 3 жыл бұрын
@@LaravelDaily ok thanks a ton
@bewildstudio
@bewildstudio 3 жыл бұрын
But what about naming tests?))
@LaravelDaily
@LaravelDaily 3 жыл бұрын
With tests, the rule is this: name them however you want, as soon as you write them at all :)
@Shez-dc3fn
@Shez-dc3fn 3 жыл бұрын
can we not just use one case everywhere? that way you wont hae to think. for ex. model, controller, resources, seeders, factories etc
@JeremyStreich
@JeremyStreich 3 жыл бұрын
Book is a bad example, because for other nouns the controller is plural when created by "php artisan make:model Thing -c"
@khuongnguyen8864
@khuongnguyen8864 3 жыл бұрын
Please save me about websocket laravel php thanks very much
@konakonaxiong7621
@konakonaxiong7621 2 жыл бұрын
If the table name is books, then the table of its reviews should be books_ Reviews or book_ What about reviews? Which is more reasonable?
@LaravelDaily
@LaravelDaily 2 жыл бұрын
Your personal preference
@konakonaxiong7621
@konakonaxiong7621 2 жыл бұрын
@@LaravelDaily I think I prefer book_reviews
@JohnnyBigodes
@JohnnyBigodes 3 жыл бұрын
Plural for Buch is Bücher... NEVER EVER WRITE SOURCE CODE IN ANOTHER LANGUAGE THAN ENGLISH... Thanks
@shaungbhone8368
@shaungbhone8368 3 жыл бұрын
Are you German?
@LaravelDaily
@LaravelDaily 3 жыл бұрын
No, Lithuanian
@nejuspesnejsi
@nejuspesnejsi 3 жыл бұрын
Cool videos. Thanks!!! Just cut the crap. It took you 58 seconds to start saying anything. Unless you're one of these people who are aiming for 10 minutes videos no matter what. Then .... .
9 Tips for Shorter Laravel Code
10:16
Laravel Daily
Рет қаралды 62 М.
Junior Code Review: Better Routes, CRUDs and Validation
17:58
Laravel Daily
Рет қаралды 60 М.
amazing#devil #lilith #funny #shorts
00:15
Devil Lilith
Рет қаралды 18 МЛН
Osman Kalyoncu Sonu Üzücü Saddest Videos Dream Engine 275 #shorts
00:29
How to Learn to Code FAST (Do This or Keep Struggling)
11:00
Andy Sterkowitz
Рет қаралды 715 М.
Solving one of PostgreSQL's biggest weaknesses.
17:12
Dreams of Code
Рет қаралды 212 М.
Junior Code Review: Laravel Routes, Middleware, Validation and more
19:57
Laravel Pivot Tables: Simple to Advanced Many-to-Many
12:24
Laravel Daily
Рет қаралды 121 М.
Laravel Migrations: 12 Useful Tips in 12 Minutes
12:06
Laravel Daily
Рет қаралды 80 М.
Laravel: Create Public API with Cache and Rate Limits
12:18
Laravel Daily
Рет қаралды 46 М.
Coding Shorts 111: Was I Wrong About Blazor?
16:35
Shawn Wildermuth
Рет қаралды 17 М.
4 Packages You Need in ANY Laravel Project
8:14
Laravel Daily
Рет қаралды 62 М.
All Rust string types explained
22:13
Let's Get Rusty
Рет қаралды 181 М.