hello guys around a month ago on my channel I started kind of a new tradition so if you scroll down we see this tips and tricks May edition that was May edition for one month compiled tips from Twitter about larvo so I decided to continue this tradition because that video was pretty popular so today I have June version of 18 or so Random tips on laral from Twitter my own and from the community so in no particular order let's go rapid fire random Lal tips tip number one from me did you know that you can redirect with fragment and that fragment is whatever you have after the hash symbol in the URL which may automatically push your browser down below to the specific anchor on your page so the user would continue on that part of the page tip number two comes from Osama here you can cach headers on the fly so in the Middle where I actually Zoom that in you can have cach header and then list whatever you want like public max age e or whatever you need simple not much to add to this tweet tip number three comes from laral backpack official Twitter handle which is recently pretty active did you know that you can run Artisan commands not only from terminal from your command line but also call them directly from other functions in your larl project again I will Zoom that in this is how it looks like you just do Artisan call and whatever you want with parameters the next tip comes from myself it's about redirect to specific route or or route name in this case since LEL 9 you have a shorter helper not just redirect route but there's two route helper which makes your code just a little bit shorter this is one more way how larl has helpers to achieve the same thing in a bit different way and some developers outside of laral community actually hate this part about larl so many options to do the same things and we will actually get back to this thought this idea by the end of this video but this is a short tip to Route helper the next tip or actually kind of more Global reminder idea comes from Json creator of larel shift he's voting for using array functions in PHP instead of collections in larl sometimes it's a personal preference but his example is for example array column function in PHP instead of collection plug in larl and I talked about that quite a lot in my course I have a course called PHP for larl developers I know it's a funny name but I've seen many people starting with laral Without Really knowing PHP fundamentals oop and stuff like that so one of the lessons in this course is about popular array functions with open source examples so here's function is array count array merage array filter array push and others so in many cases you don't need to convert to collections in laral perform operations phpr functions are still powerful still alive and I will link this lesson with examples in the description below the next tip is kind of a counterargument to Json tweet we get back to collection C so ponal is showcasing us new methods in LEL 11 release and let's Zoom that in again so you can have before and after if you have a collection in Lille not much to add here just a few new helper methods in collections the next tip comes from Muhammad which is not that much about laral or even PHP it's about architecture you can create a special method in your model for example or whatever class to hide the implementation of that method if you have a few conditions and you May repeat that in multiple places for example call that from controller from blade from Artisan command or whatever and this is partially about don't repeat yourself Dr principle but also it's more readable for example if you have this condition in controller it's not that clear what it actually means but if you have method name that contains the meaning of that condition so is content unlocked is much more readable for any new developer or even yourself in the future instead of having this condition which isn't clear what that schedule date means in real life scenario so sometimes even if you have one condition here and even if it's not that much repeated in the code base a method with a better name is a better solution for readability again sometimes again it's your personal preference and I'm planning to shoot a separate video expanding on that tell don't ask principle in coding architecture the next tip comes from me again by the way I still post those tips almost every day on Twitter so you can follow me there and and the tip is about DD so instead of having DD on a new line did you know that in eloquent you can DD the collection on the same line or if that line gets too long of course you can split different parts like get on the new line DD on a new line and whatever else you have as conditions the next tip comes from Osama formatting to percentages number class was released from what I remember in laravel 10 some minor version of larl 10 and I have a separate video about that and I will link that in the description below so one of those methods of that number class is percentage so if you have any number from your database for example you can format that with Precision or with Max Precision or even down to local to format that with comma for example in this case for German language the next tip comes from anicat and I've never had a case of using the controller in this way but it's pretty interesting for example if you want to have some of the methods of the controller public like index and show While others would be private under metalware o so this would be a potential code the same route resource used twice but with only and except specifying the methods personally I'm not sure I would use it this way I would probably separate them into separate controllers like name space of user event controller and admin event controller or something like that or public versus user but this is an interesting code example that you can divide the controller with only and accept and provide different group different middle or other parameters to that route group the next tip comes from Steve or it's not actually even a tweet it's a full Artisan command of how to handle invoice sending for example and showing the live update progress bar in your terminal so it's based on two things bus badge and then create progress bar and then setting the progress based on the badge processed jobs so you should try something like that yourself this code snippet changed for your project and see how that progress bar actually looks like I do have a video showcasing something like that and I will link that in the description below as well the next tip comes from Martin who is talking about service classes in laral or in PHP so for a lot of newcomer developers I know it's confusing to have service classes what they are how to use them and what should be inside of the service class in larl and Martin kind of simplifies that showcasing the example and how to use it in a thread I will not read the full thread for you will instead link that in the description below but basically the idea is that service class is any PHP class that you would reuse elsewhere the next tip is not about laral it's about PHP and it comes from Pascal did you know I didn't know that that match can work with two values so you can match a pair of values and then based on that perform some operation so this would help you avoid a lot of if statements if this then that and then if something else this is much more readable the next tip again about PHP comes from punal here and it's about PHP 8.4 the upcoming version we will have more methods with array getting back to the topic we already talked about earlier in this video so you can see the example array find array find key array any and array all should be pretty good additions to PHP syntax the next tip comes from Liam and it is for preventing n plus1 query problem in your larel projects by preventing lazy loading in your app service provider this comes from App service provider file but Liam suggests one step further so if app is in production prevent lazy loading should not throw an exception but instead you can overwrite how it is doing the prevention with the method handle lazy loading violation using a long name but it does exactly what it says and you can for example log something somewhere or send some notification to someone that's your personal choice but basically no exception the query still goes through but you can inform someone the last tip for this video comes from myself and this is where I told you we would get back to the topic of many options in Lille to do the same thing to be honest I tweet this from time to time every few months or so as a reminder that there are multiple ways how to call the view from the controller and how to pass the data you can pass an array you can pass an array as a variable or you can use compact function and each time I tweet about it there are around 100 likes or 200 likes with a lot of replies of which option is preferred so a lot of discussions around the same topic of many options in laravel and this is exactly where I want to end this video with the last not tip but link on Twitter I've posted an article from Reddit where someone is switching from larl to rails this is a very interesting discussion and what that person pointed out as one of the downsides of laravel is exactly that instability and no one clear way one clear best practice to do the same thing including the fact that some new helpers arrive new ways to do the same thing which kind of loses the consistency of the framework personally I see that as a feature of laral not a bug maybe even kind of a trademark laral feature showcasing the flexibility of the framework but in this case the opinion of that person is downside so I will link the tweet and Reddit thread in the description below this is a very good write up of downsides of LEL but in a very polite way in a very non- negative way pretty interesting read and the final final thing in this video if you want to follow people on Twitter for larl tips in laral daily menu resources there's people to follow where I link to a lot of people from Lille Community who tweet about Lille or used to tweet about Lille including Taylor and others so you can find someone to follow on Twitter in this list I will also link that in the Des description below what do you think about this format of monthly rapid fire Twitter tips should I continue with the next episode in the next month let me know in the comments below that's it for this time and see you guys in other videos