Тёмный
No video :(

About/Contact Pages: Structuring Routes in Laravel 

Laravel Daily
Подписаться 143 тыс.
Просмотров 38 тыс.
50% 1

With static pages example, I'm showing a few "tricks" on how to structure routes. We're touching things like:
- Invokable single-action controllers
- Route where parameters:
- Get URL part/segment from the request
- Using translations for meta titles
- - - - -
Try our Laravel QuickAdminPanel: bit.ly/quickad...
Enroll in my Laravel courses: laraveldaily.t...

Опубликовано:

 

28 авг 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 64   
@crazyg74
@crazyg74 3 года назад
Love this! I often use 'auto routing' for basic CRUD, during rapid prototyping of applications, but I was doing it in a much more clunky way in the routes file.
@JamesAutoDude
@JamesAutoDude Год назад
For anyone coming across this later... If you wanna check the database for a slug and give 404 error if non exists, then you leave out the ->where in web.php and just do an if else statement. In the else you just put abort(404);
@Ansari_Zubair
@Ansari_Zubair 4 года назад
One thing I would like to add is instead of using 'Controller@method' use [Controller::class, 'method'] it's IDE friendly and we can open controller just by ctrl+click
@JamesAutoDude
@JamesAutoDude Год назад
It's also basically required in laravel 9 lol
@Ansari_Zubair
@Ansari_Zubair Год назад
@@JamesAutoDude It was recommended back then, but you could use any 😀
@aseemlalfakawma5084
@aseemlalfakawma5084 4 года назад
This is just amazing. Thank you for the video.
@etaion
@etaion 4 года назад
Putting the return view(.....) in a try/catch, and calling abort(404) would be cleaner, Then you don't have to edit the route whenever you add a new static page.
@praadiiit
@praadiiit 4 года назад
I just found this channel and watch some of your new video. I hope i found it long time ago. You really put an awesome content here. Thank you sir
@RuudvanZuidam
@RuudvanZuidam 4 года назад
Great practical short course Thanks Povilas
@FredericoMoura
@FredericoMoura 4 года назад
Amazing! Thanks for sharing !i was looking for how to do this for a long time!
@QiroLab
@QiroLab 4 года назад
Very useful, you have simplified the routing. 👏👏👏
@davidmucioca6423
@davidmucioca6423 4 года назад
Liked it. Thank you Povilus for the good job you are doing.
@abhishekpakhare7682
@abhishekpakhare7682 4 года назад
Very good optimization of code learned a new thing invoke method thank for this tutorial. Huge respect 🙌🙌
@mohssinesbai1964
@mohssinesbai1964 4 года назад
You have an amazing way of simplifying things thank u so much
@singlapanther1374
@singlapanther1374 Год назад
Sir you good teacher
@Alex-fg4mh
@Alex-fg4mh 4 года назад
Such a good idea to use translations. I'd further move the config reference in the blade template to be the default instead of setting null when no translation is found?
@PovilasKorop
@PovilasKorop 4 года назад
Yes, you can do that, too, good idea.
@arnabroy832
@arnabroy832 4 года назад
Thank you very much
@mackynyxz
@mackynyxz 2 года назад
Nice! thanks for this
@davidmucioca6423
@davidmucioca6423 4 года назад
Very useful
@anmolkaithwas
@anmolkaithwas 2 года назад
Great thank you...
@alila3883
@alila3883 3 года назад
always you presents a unique content Thanks
@Ehsankhan0577
@Ehsankhan0577 3 года назад
you are awesome
@goodfellow4353
@goodfellow4353 9 месяцев назад
hellow, ty for your work. can i pass entity in the controller in this case?
@DanielŚmigiela
@DanielŚmigiela 3 года назад
You're the Best!
@arifdevcoding
@arifdevcoding 2 года назад
No, i still think the Route::view() is better than this. Your idea is making it more complex
@arifdevcoding
@arifdevcoding 2 года назад
Also in future you might need to add data processing for the terms or contact, which has to be in the controller.
@taiwoolatmi3594
@taiwoolatmi3594 4 года назад
This is awesome code trick, I appreciate you sir, My overview on the metaTitile is that, Cant we use @yield('title', ' | Project3') in our template layout, and on the about Page. we say @section('title', 'About us') this will give us About us | Project3 as the title, That s what i resorted to, because my Laravel 5.8 showing syntax error when I ship in that Json approcach to my on going project, I need your clarification on it sir
@PovilasKorop
@PovilasKorop 4 года назад
Yes, @yield is another perfectly valid way of doing it.
@ExpDev69
@ExpDev69 4 года назад
Same, I also use yields and sections so i can define the SEO metadata right in my blade views :P
@lordgodgiven
@lordgodgiven 3 года назад
Hello, Happy New year and my wishes. My question is about how to redirect user on a specific tab after an save or update action. Thanks
@BRO-sp8ld
@BRO-sp8ld 3 года назад
Is it work with new routing convention in laravel 8.*? Trying to use this, but getting error about function name parameter.
@kranot87
@kranot87 2 года назад
What happens when you have 10 or more static pages under the same group? Is there any way to avoid writing all the different pages?
@ahmedfathy3720
@ahmedfathy3720 4 года назад
awesome as usual
@raj-kal
@raj-kal 3 года назад
amazing trick. thanks :)
@kondekinoe9337
@kondekinoe9337 3 года назад
Can i use this in laravel 8.0?
@omarzain3946
@omarzain3946 4 года назад
You are awesome ^^ Thank you for your efforts , waiting more ^_^
@Hello-mu1et
@Hello-mu1et 3 года назад
Would it be okey to write many routes in one page controller where each page have their own data? Or better to create controller for them instead?
@LaravelDaily
@LaravelDaily 3 года назад
It's a personal preference.
@Hello-mu1et
@Hello-mu1et 3 года назад
@@LaravelDaily Thanks Because I have dashboard and user panels and trying to write as clean code as possible
@sultanahmad9152
@sultanahmad9152 2 года назад
I would like to learn React in Laravel, Do you have any course or video on that?
@LaravelDaily
@LaravelDaily 2 года назад
No sorry I don't have anything on React yet
@codekilla81818
@codekilla81818 4 года назад
Great video thanks! Could you please advice a table grid with filters and pagination for Laravel7?
@PovilasKorop
@PovilasKorop 4 года назад
I suggest this package - github.com/yajra/laravel-datatables - along with Datatables.net This is what we're using in our Laravel adminpanel generator - try it at www.quickadminpanel.com
@codekilla81818
@codekilla81818 4 года назад
@@PovilasKorop Many Thanks!
@codekilla81818
@codekilla81818 4 года назад
Guru @@PovilasKorop one more question please :) , when we use such libs as Yajra, do we need to wrap them into our custom classes, to be save if this lib stop working or become payable?
@PovilasKorop
@PovilasKorop 4 года назад
@@codekilla81818 You don't need to wrap the packages, and you shouldn't be worried when lib stop working (or when it's payable - maybe it's worth to contribute to author?). You just choose the packages from authors you can trust. See my very old video: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-7Q6DiGK8qa8.html
@codekilla81818
@codekilla81818 4 года назад
@@PovilasKorop Humble respect to you! Thanks again!
@taslimsuman
@taslimsuman 4 года назад
This is what I do.
@seppdaniel
@seppdaniel 3 года назад
You should actually catch the Exception instead of defining a where. :)
@user-ue9kh7of1l
@user-ue9kh7of1l 4 года назад
good
@janisbarons2304
@janisbarons2304 4 года назад
It only "works" when client does not want to have dynamically created content pages..
@PovilasKorop
@PovilasKorop 4 года назад
For dynamically created pages it's a totally different logic, because then you need to save pages in the database. Or, for CMS-like projects where users would work with content a lot, I always recommend WordPress over Laravel.
@mikeglobal9084
@mikeglobal9084 2 года назад
Invoke as a controller doesn't work in LARAVEL 8+
@phread6691
@phread6691 4 года назад
Wowwwwwwwwww
@Vlad73125
@Vlad73125 4 года назад
That's a bad practice. But thanks anyway for this trick
@user-uq6tn5nd7c
@user-uq6tn5nd7c 4 года назад
Sir i learn laravel from 4 month but I can not improve my level or actually I don't know the way to bacome advance can you help me? ❤️
@PovilasKorop
@PovilasKorop 4 года назад
laraveldaily.com/advanced-laravel-20-topics-and-links-to-learn-them/
@user-uq6tn5nd7c
@user-uq6tn5nd7c 4 года назад
@@PovilasKorop thx very much sir 🖤
@haroldpepete
@haroldpepete 3 года назад
with all respect that you deserve, something like that is not well, for a project like you show, with any logic and just to prove that something like that can works, it's fine, but with real code and real logic, what happen with the principle of method or function with one concern,you imagine a new developer and he sees that code, easy code is easier to mantain, sorry but this video is wrong
@silvioney
@silvioney 4 года назад
How to resume 3 rows in 30
@PovilasKorop
@PovilasKorop 4 года назад
Sorry didn't understand the question
@deejayerick
@deejayerick 4 года назад
Very useful
Далее
PHP: Make If-Else More Readable and Shorter
7:25
Просмотров 46 тыс.
Laravel Eloquent: Deeper Relationships with One Query
10:37
Cache Eloquent Query Results to Load Pages Instantly
5:43
Laravel: Change Two Symbols to Boost Eloquent Speed
6:34
Laravel Migrations: 12 Useful Tips in 12 Minutes
12:06
8 Design Patterns | Prime Reacts
22:10
Просмотров 406 тыс.
Object Oriented Programming vs Functional Programming
18:55
Laravel: Create Public API with Cache and Rate Limits
12:18
Optimizing Eloquent: Running Out Of Memory?
6:11
Просмотров 42 тыс.
Visualizing memory layout of Rust's data types
39:39
Просмотров 14 тыс.