One thing I realized while learning laravel is that eloquent queries return a collection which means we can use collection methods AFTER getting the result from eloquent query. Been using old php way. Also there is the laravel helpers documentation which is a god send.
@sakhaprasna2 жыл бұрын
i like it sir so useful and clear on explaination i was confused in my way solving how to use where like with collection, then i found this video many thanks!!! ❤❤❤
@dadditsdonovskiy31453 жыл бұрын
Thank you very much for such a short and nevertheless clear and comprehensive explanation.
@andresluisvelasquez1747 Жыл бұрын
Gracias por la info
@SowrenSen3 жыл бұрын
Want Tinkerwell features in PhpStorm? Try Laravel Tinker plugin. Super useful one.
@pavelmgn3 жыл бұрын
First example: return array_map(fn($name) => Str::slug($name), self::PROJECT_TYPES);
@mallesbixie3 жыл бұрын
I love collections, but in this case I'd go for the native solution you posted. untested, but I think even `return array_map([Str::class, 'slug'], self::PROJECT_TYPES); ` will work
@1234matthewjohnson3 жыл бұрын
what are your throughts on when to use map() vs each()? they seem to do a very similar thing.
@LaravelDaily3 жыл бұрын
Well, not really, map() returns something and each() is just for performing some operations, it may not return anything.
@shethchaitali80123 жыл бұрын
Hello can you tell me which editor did u use and how can i do when i change code at a same tome output showing on right side?
@LaravelDaily3 жыл бұрын
It's not editor, it's Tinkerwell app, it's not free
@R0b3 Жыл бұрын
What kind of editor are you using, PHPstorm or vscode?
@LaravelDaily Жыл бұрын
Phpstorm
@overLordOrigin3 жыл бұрын
thanks
@bsen22673 жыл бұрын
Hey @Laravel Daily, do you think it's worth learning VIM ?
@GergelyCsermely3 жыл бұрын
Thanks!
@bagusk_awan3 жыл бұрын
i have a question, what's the difference between $collection->mapWithKeys(...) and $collection->transform(...) ?
@thanakornboy11293 жыл бұрын
6:20 I think all Str::contain() run although $query contains in title, right?
@Remls3 жыл бұрын
.
@qudratxojamusayev67853 жыл бұрын
Great video. I just wanted to ask if it is a good practice to filter things with php instead of using database queries
@LaravelDaily3 жыл бұрын
Good catch. Usually, it's a bad practice, in that example of the video it kinda makes sense because filtering is quite complex with lowercase transformation, so for the same to happen in the database queries, you would probably need to use raw MySQL methods.
@ward75763 жыл бұрын
Always better to go with DB filtering. For that you run one query and hydrate models once (ideally). When you return date from DB and filter it on php, you are hydrating a lot of data where a chunk of it will be just thrown away..since filtering. Not as efficient. It would either way be a good practice to learn some more mysql as you go and optimize things ;)
@josuebarros-desenvolvedorw24903 жыл бұрын
How can we paginate a HTTP response data? Example: Requesting to a Real Estate listing and paginate the 500 results in groups of 50
@LaravelDaily3 жыл бұрын
It depends on the structure of how those listings are presented to you. So it's very individual, I can't answer in a comment.
@josuebarros-desenvolvedorw24903 жыл бұрын
@@LaravelDaily it is returning as a collection
@developerdiwakar3 жыл бұрын
Hi Povilas, I have a question. How can we sort collection after concat with pagination? #laravel8
@LaravelDaily3 жыл бұрын
It needs a specific example, I can't answer with just this short description.
@developerdiwakar3 жыл бұрын
@@LaravelDaily Okay. Suppose we have two collections $biddings = Bidding::with('user')->paginate(10); and $evaluations = Evaluation::with('user')->paginate(10); then I do this $offers = $evaluations->setCollection( $evaluations->concat($biddings)->sortByDesc('created_at')->values() ); It sets the pagination as well as concatenation but failed to sort the whole collection by created_at in desc order. I want the sorting here.
@afestacincome22243 жыл бұрын
Do you have a tutorial on how to send post to Twitter
@LaravelDaily3 жыл бұрын
Here are a few examples from my Laravel Examples: laravelexamples.com/tag/twitter
@TahirBhai3 жыл бұрын
Thank you for your regular helpful videos, can we expect a video from your channel about mysql database shards in laravel project. I am looking into this now a days but there is no good practical example over there.
@LaravelDaily3 жыл бұрын
Not in plans, sharding is a niche topic, too niche. I'm focused on broader topics.
@TahirBhai3 жыл бұрын
@@LaravelDaily Thank you :) if you can recommend me some readings or video material about this. Eagerly looking for it.
@cardboarddignity2 жыл бұрын
This collect()->...->toArray() is pretty performance unfriendly and is kinda slow. If you have and array and want the same array at the end, it's better to use php native methods, like array_map and array_filter. These have the same exact purpose, just avoiding the heavy collect() method
@Voltra_3 жыл бұрын
I'd recommend to use cursor instead of get if you plan to use multiple methods afterwards
@renwar3 жыл бұрын
why?
@Voltra_3 жыл бұрын
@@renwar It returns a lazy collection instead which allows for lazy evaluation instead of eager evaluation (one for loop instead of n for loops)
@yuliarahma13003 жыл бұрын
can you gave us tutorial or concept about otp using telegram, and fresh laravel jetstream, thanks.
@LaravelDaily3 жыл бұрын
I don't work with OTP and Telegram.
@yuliarahma13003 жыл бұрын
@@LaravelDaily can you at least give us an example or which file to modify to change two factor auth from email to telegram? is it possible right?
@rishikantsrivastava24443 жыл бұрын
Hi Povilas, Thanks for your wonderful support to Laravel community and people like me. but kindly clear this as well, two cases are there, Case 1: if(statement1||statement2||statement3) { return; } Case 2: if(statement1) { return; } if(statement2) { return; } if(statement3) { return; } Case 1 : everytime, all three statement will be executed, Case 2: Not All conditions will be executed.it might be 1, 1-2, or 1-2-3 So which is better?
@LaravelDaily3 жыл бұрын
In theory, separate if statements are better for performance, you're right, only one would be executed. But if it's just a simple comparison without any DB query or other expensive operation, then performance difference would be 0.0001s and code will be longer for no big reason.
@devKazuto3 жыл бұрын
I don't like chained conditions. Yes, it's shorter but it's less readable. I'd much rather have code that is easier to read than having that requires to think what could happen in that chain, especially if you have chains like "|| ($a && $b) || (!$c || $d)" and so on.
@travholt3 жыл бұрын
I agree. The multiple if statements read almost like English and it makes the logic very easy to understand at a quick glance.