3,470 experience to go until the next level!
In case you were wondering, you earn Laracasts experience when you:
Earned once you have completed your first Laracasts lesson.
Earned once you have earned your first 1000 experience points.
Earned when you have been with Laracasts for 1 year.
Earned when you have been with Laracasts for 2 years.
Earned when you have been with Laracasts for 3 years.
Earned when you have been with Laracasts for 4 years.
Earned when you have been with Laracasts for 5 years.
Earned when at least one Laracasts series has been fully completed.
Earned after your first post on the Laracasts forum.
Earned once 100 Laracasts lessons have been completed.
Earned once you receive your first "Best Reply" award on the Laracasts forum.
Earned if you are a paying Laracasts subscriber.
Earned if you have a lifetime subscription to Laracasts.
Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.
Earned once you have achieved 500 forum replies.
Earned once your experience points passes 100,000.
Earned once your experience points hits 10,000.
Earned once 1000 Laracasts lessons have been completed.
Earned once your "Best Reply" award count is 100 or more.
Earned once your experience points passes 1 million.
Earned once your experience points ranks in the top 50 of all Laracasts users.
Earned once your experience points ranks in the top 10 of all Laracasts users.
Replied to Laravel Nova: How To Create A Custom Field And Its Crud Methods?
This excellent package already exists:
Replied to Can I Simply Write To Laravel.log In My Script?
Yeah, you can do Log::debug()
which will write to your log file. However, there are better options:
Replied to Composer Remove
Another package is relying on that dependency most likely then. Remove all dependencies that depend on that package if you really want to get rid of it.
Run this command to get more information:
composer why {package} {version}
Replied to Strips Out Password Field
Without showing us any code, nobody can help you. Why would Eloquent remove fields from the result set unless you ask it to do so..?
Awarded Best Reply on Are Singleton Bindings In The Service Container Persisted Between Jobs In The Queue?
Yes, you are correct. If the static field is null
initially, you should make sure it is null
again after the job has run.
This is why job idempotence is very important. Static properties are bound to cause headaches in long-running processes. Mohamed Said's book "Laravel Queues in Action" touches on this topic very nicely.
Replied to Are Singleton Bindings In The Service Container Persisted Between Jobs In The Queue?
Yes, you are correct. If the static field is null
initially, you should make sure it is null
again after the job has run.
This is why job idempotence is very important. Static properties are bound to cause headaches in long-running processes. Mohamed Said's book "Laravel Queues in Action" touches on this topic very nicely.
Replied to Are Singleton Bindings In The Service Container Persisted Between Jobs In The Queue?
Application instances are not shared between workers. Each worker has its own app instance. If a singleton binding is resolved in a worker, and that same worker needs access to that same binding later on, then the old binding will be re-used. The answer to your question in the title is "yes".
Reset your application to its initial state and you should be fine. That means, resetting those static properties after the job has either failed or succeeded.
Replied to How To Select Only Specific Attributes With Nested Eager Loading
Order::with(['orderFoodItems:id,order_id,image,name', 'orderFoodItems.price:food_item_id,original_price']);
I don't know how your FKs are called, but they must be included in the selections.
Replied to What's Your Take On This Pkg Development Issue?
For those who might stumble upon this post:
For more details: https://github.com/dive-be/laravel-feature-flags/tree/8856bee84a25978ceea6ba012d05202f31b63121
I created a config where you can change the model being used. The package already provides a translatable counterpart, but it is up to you if you want to use it.
return [
'feature_model' => Dive\FeatureFlags\Models\Feature::class,
];
Added a suggest
in composer.json
"suggest": {
"spatie/laravel-translatable": "Required for defining messages for multiple locales"
},
Bind the correct "concrete" implementation of the model (defined a Feature
contract which both the normal and translatable one implement)
$this->app->singleton(Feature::class, static function (Application $app) {
return new ($app->make('config')->get('feature-flags.feature_model'))();
});
Replied to Class 'League\Flysystem\AwsS3v3\AwsS3Adapter' Not Found
Laravel won't support Flysystem v2 in version 8. You must explicitly require version 1.
Replied to "datatables" Slowness Problem
KardeÅŸ, you are literally fetching all of the records in your database which is not a wise thing to do.
You should be paginating those results server-side as well using the built-in LengthAwarePaginator
.
https://laravel.com/docs/8.x/pagination
If you REALLY need to send the complete table in one go (which I highly doubt), then use the QueryBuilder
directly instead of going through Eloquent
because the hydration of those models is going to waste a lot of CPU cycles which is probably one of the main causes of your issue. Either way, before doing that, consider paginating your result set.
Awarded Best Reply on What's Your Take On This Pkg Development Issue?
@jlrdw That's right, but in this case I really felt like it'd be possible to not force it.
I think I've come up with a solution either way, just needed to get some sleep. As soon as I woke up, the light bulb appeared above my head 😂
Marking as solved. Will post solution once implemented.
Replied to What's Your Take On This Pkg Development Issue?
@jlrdw That's right, but in this case I really felt like it'd be possible to not force it.
I think I've come up with a solution either way, just needed to get some sleep. As soon as I woke up, the light bulb appeared above my head 😂
Marking as solved. Will post solution once implemented.
Started a new Conversation What's Your Take On This Pkg Development Issue?
So, I'm currently developing this package to enable/disable features thoughout an app.
(Please don't suggest other packages, I examined other alternatives and concluded that none of them fit my exact needs or were total overkill with too many features [pun intended]).
I ran into an interesting problem for which I don't really have a clear answer, so valuable suggestions are welcome:
Currently, the package includes spatie/laravel-translatable for the Feature
model's message field. This way, if the app is served with multiple localizations, the multilocale aspect of it is automatically covered. However, what I also realized is the fact that not every app is using multiple locales (obviously). So, this package will force an additional dependency down your throat even if you don't want to use it. It will keep working without a hiccup, but you'll have to live with that unsolicited dependency.
Somehow, I'd like to make this opt-in, but at the same provide first-class support without making the consuming app adjust the published migration and extend the Eloquent model and manually use the trait. I kinda feel like there must be a proper solution to this, but then again I don't really know how you'd want to tackle such a thing (properly).
Replied to Change Php Versions Using Valet
This is a must-have if using Valet:
https://github.com/nicoverbruggen/phpmon
Makes switching PHP versions so easy.
Awarded Best Reply on Target Class [translator] Does Not Exist.
You are extending the wrong TestCase
which doesn't do any application bootstrapping. Extend the one in your root "tests" folder, not PHPUnit.
Replied to Target Class [translator] Does Not Exist.
You are extending the wrong TestCase
which doesn't do any application bootstrapping. Extend the one in your root "tests" folder, not PHPUnit.
Replied to Using 'Auth' For Multiple Models
You're reaching for the wrong tool here, tbh. What you need is Multi-Table Inheritance. You can read the README of this repo and if you have more questions, feel free to ask.
Replied to My Defined Facade Does Not Work
You don't get how facades work behind the scenes. Can you show your service's class signature?
Awarded Best Reply on Passing Conditional Classes To Anonymous Components
If you are on the latest Laravel version (or are able to upgrade):
<input {{ $attributes
->class(['default-classes', 'border-red-500' => $errors->has($attributes->get('name'))])
->merge(['disabled' => false])
}} />
Notice I also got rid of @props
. disabled
is a native HTML attribute, so no need to exclude it from the default bag.
(Didn't test, but should work like this)
Replied to List Ticket Types Foreach Logic Issue
Uhmm, where are you initializing the $ticketTypes
public property? I think you are expecting too much magic from Livewire. Livewire can't just read your mind and know what exactly you'd like to do.
Replied to Passing Conditional Classes To Anonymous Components
In case you cannot upgrade:
https://twitter.com/pascalbaljet/status/1356874363212070912/photo/2
Replied to Some Help Here With An Array Conversion Thanks
You don't show how you're calling that method in your code. Cannot help until you provide more info.
Replied to Passing Conditional Classes To Anonymous Components
If you are on the latest Laravel version (or are able to upgrade):
<input {{ $attributes
->class(['default-classes', 'border-red-500' => $errors->has($attributes->get('name'))])
->merge(['disabled' => false])
}} />
Notice I also got rid of @props
. disabled
is a native HTML attribute, so no need to exclude it from the default bag.
(Didn't test, but should work like this)
Replied to My Redis Queues Gets Slower Over Time. I Have To Restart Services To Speed It Up, Why?
@hillcow There is a high probability of a memory leak somewhere in your jobs. You can restart the workers every x hours to temporarily mitigate the issue until you've ironed it out.
Awarded Best Reply on Model Factory In Custom Dir
You must override newFactory
in your model as Laravel cannot correctly guess the factory's namespace.
Replied to Model Factory In Custom Dir
You must override newFactory
in your model as Laravel cannot correctly guess the factory's namespace.
Replied to Laravel 7 Php Artisan Optimize Is Not Working
Did you even read the error? It tells exactly what's wrong.
Replied to Problem With Slug Translate
How is it not working with translations? Spatie's Sluggable package has first-class support voor translatable slugs when combined with their laravel-translatable package:
https://github.com/spatie/laravel-sluggable/blob/master/src/HasTranslatableSlug.php
What you are doing here is nothing but hacking.
Replied to Multi Language Validation
This is a solid package to handle multiple locales within your application:
Replied to Is There A Complete Laravel And Dropzone Js Tutorial?
Then I do not know of any other, sorry. You could try Spatie's Media Library Pro.
Replied to CSRF Token Mismatch On Server
Doesn't matter in that case. I'd still prepend a period personally.
Replied to CSRF Token Mismatch On Server
That explains the 419 errors. Set it up and you should be good to go.
If your URL is let's say app.imaginary.com, then the session domain should be .imaginary.com
.
Replied to Get All Products That Belong To A Vendor
I'd recommend this package from staudenmeir for such deep relationships: https://github.com/staudenmeir/eloquent-has-many-deep
Awarded Best Reply on Livewire Not Updating Database As Expected
Are those values available in the fillable
property of your User
model?
Replied to How To Use Multiple Arrow When Calling A Class Methods
Your current class design will not allow that no. The phrase you are looking for is "Fluent API" BTW.
I don't really know what your intentions are with this class, but judging by its cover the static properties can probably become instance properties. Then, setParams
can function as a named constructor allowing the call chaining you'd like to carry out.
Replied to Laravel Get Id Before Store
Have you tried my suggestion? Yours is going to blow up 100%. insert
by itself returns a bool
.
What you want in that case is this:
$post = Post::create([
'title'=> $title,
'category'=> $category,
]);
Photo::create([
'post_id'=> $post->getKey(),
'photo'=> $photo,
]);
Replied to Laravel With Liveware Or Vuejs Or Reactjs
There is no definitive answer.
Replied to Laravel Get Id Before Store
$post = Post::insertGetId([
'title'=> $title,
'category'=> $category,
]);
Photo::insert([
'post_id'=> $post,
'photo'=> $photo,
]);
Replied to Livewire Not Updating Database As Expected
Are those values available in the fillable
property of your User
model?
Replied to Larastan / ORM
Calling query
yourself first does not make it more complex. Under the hood, when you directly call where
, newQuery
is called anyways so I don't see a problem there.
If it really bothers you however, you can ignore it https://phpstan.org/user-guide/ignoring-errors#ignoring-in-configuration-file
Replied to Larastan / ORM
Flight::where
has to go through 2 or 3 magic methods before actually calling where
on the QueryBuilder
. That's why it has a hard time in that case. We can help Larastan by explicitly instantiating a new QueryBuilder
instance.
Flight::query()->where('active', true); // ::query() tells we have a QueryBuilder at our disposal