hondnl

hondnl

Member Since 3 Years Ago

Experience Points
18,500
Total
Experience

1,500 experience to go until the next level!

In case you were wondering, you earn Laracasts experience when you:

  • Complete a lesson — 100pts
  • Create a forum thread — 50pts
  • Reply to a thread — 10pts
  • Leave a reply that is liked — 50pts
  • Receive a "Best Reply" award — 500pts
Lessons Completed
153
Lessons
Completed
Best Reply Awards
4
Best Reply
Awards
  • start-engines Created with Sketch.

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • first-thousand Created with Sketch.

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • 1-year Created with Sketch.

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • 2-years Created with Sketch.

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • 3-years Created with Sketch.

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • 4-years Created with Sketch.

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • 5-years Created with Sketch.

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • school-session Created with Sketch.

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • welcome-newcomer Created with Sketch.

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • full-time-student Created with Sketch.

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • pay-it-forward Created with Sketch.

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • subscriber-token Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer-token Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • lara-evanghelist Created with Sketch.

    Laracasts Evangelist

    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.

  • chatty-cathy Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

Level 4
18,500 XP
Oct
31
2 weeks ago
Activity icon

Awarded Best Reply on Increasing Max Execution Time In Production Not Working

echo phpinfo(); can you see the right execution time ? If so then the problem is not from the ini file. Since your dev is working correctly, there must be a setting in your production that is causing this.

Go through all possible timeout settings in nginx ( look it up) . Google your specific setup ( OS,caching anything else running) and timeout problems. There must be some setting wrong if it is not php.

Good luck!

Oct
30
2 weeks ago
Activity icon

Replied to Increasing Max Execution Time In Production Not Working

echo phpinfo(); can you see the right execution time ? If so then the problem is not from the ini file. Since your dev is working correctly, there must be a setting in your production that is causing this.

Go through all possible timeout settings in nginx ( look it up) . Google your specific setup ( OS,caching anything else running) and timeout problems. There must be some setting wrong if it is not php.

Good luck!

Oct
29
2 weeks ago
Activity icon

Replied to Laravel Query Run Twice

hmm that is a lot of Exists in one query... Try to rewrite this query with (left) joins , see if that improves the performance. I don;t have a lot of time atm ... but will take a look later if you don't figure it out yourself.

Good luck!

Activity icon

Replied to Laravel Query Run Twice

btw add into your AppServiceProvider in the boot :

   DB::listen(function ($query) {
            if(!preg_match('/(information_schema|migrations|drop table|create table|alter table)/i',$query->sql)) {
                echo '<pre>';
                print_r([
                    $query->sql,
                    $query->bindings,
                    $query->time
                ]);
                echo '<pre>';
            }
        });

Will give you the whole query... A lot easier to debug big queries and see where you could improve. For more complicated queries I generally start in mysql (phpadmin or any othe gui) and once I am satisfied with the performance of it I convert it back to Eloquent.

Activity icon

Replied to Laravel Query Run Twice

If you are paginating laravel needs to know the total amount of accommodations , hence the first query. The second he actually grabs the first 10 rows.

5 sec ! I hope it is indeed 5ms ... or there is something very wrong with your database ;)

Activity icon

Replied to Increasing Max Execution Time In Production Not Working

Take a look at :

/etc/php/7.2/fpm/php-fpm.conf and /etc/php/7.2/fpm/pool.d/www.conf

see if request_terminate_timeout is uncommented....

Also in your nginx.conf take a look if there is fastcgi_read_timeout enabled.

Are you behind a load balancer ? The timeout may come from somewhere else then your php execution time.

Oct
28
2 weeks ago
Activity icon

Replied to Laravel Price Range Search From Multiple Columns

That is what I am asking , give us the query of products. We want to see what is happening there.

Activity icon

Replied to Laravel Price Range Search From Multiple Columns

Please give us the whole query ( including $product) or we cannot see what is going wrong here.

Activity icon

Replied to Increasing Max Execution Time In Production Not Working

Your answer might be found here ... It is clearly not loading the right ini file.

https://askubuntu.com/questions/356968/find-the-correct-php-ini-file

Activity icon

Replied to Service Worker Wont Load

Php artisan serve is just for testing quickly on your localhost. Take a look at things like homestead or laragon if you want more options. But I might be wrong here...

Activity icon

Replied to Please Help To Fetch Certain Data

You could use a derived table.

https://stackoverflow.com/a/54389589/260402

Or you can create a third column feature_value_id : where the input would be something like : 8_1 , where feature_id =8 and value_id =1 But then you would need to update this column every time you update any of those values.

Activity icon

Awarded Best Reply on How To Sort A Merged Object In Laravel

Maybe something like this ... But if you are getting your data from a database , maybe you could join and order the query instead..

$data = $city->merge($accommodation)->sortByDesc('name');

Activity icon

Replied to Scout + Elastic Search Query Always Return Null

What does your Accomodation model looks like?

Activity icon

Replied to 'q' Is Displayed On Every Page

Check your bootstrap/app , your serviceproviders and your config files.

Activity icon

Replied to How To Sort A Merged Object In Laravel

Maybe something like this ... But if you are getting your data from a database , maybe you could join and order the query instead..

$data = $city->merge($accommodation)->sortByDesc('name');

Oct
22
3 weeks ago
Activity icon

Commented on Widget Workshop

Is using the ReflectionClass for each widget on a page with a lot of them not costly , performance wise ?

Aug
29
2 months ago
Activity icon

Started a new Conversation Laravel Collection To Object

Is it possible to return an object from a laravel collection ?


$originalArr =[
    'foo' =>'bar',
   'foo2' => 'bar2'
    
]

$coll=collect($originalArr)->reject(function($item){

    // do something
});


$arr = $coll->toArray();

// array
dump($arr)

// but what if I want to have an object ?
$object  = (object) $arr;

dump ($object) 


//So you can access the attributes like  $object->foo.

But this seems fairly stupid... First make a collection , then convert to an array and then once again convert to an object.

Is there a more efficient way?

Jun
01
5 months ago
Activity icon

Replied to Magento 2: Can I Ask Question About Magento 2.x ?

@SNAPEY - haha I came to the same conclusion. I once had to do a project based on magento. It was the most hellish couple of months in my career. Most of it was to hack yourself around the code and try to optimize the slowness of the framework.

Activity icon

Replied to PHP Storm

I agree, would be nice to have an update. Pretty sure I am still not using all the nifty tricks phpstorm has to offer.

May
30
5 months ago
Activity icon

Replied to Map Array Values To Collection Of Items

Final edit and solution :

This below will make sure only the values from the basemap are returned and if they are not aligned in order with the items it will still return the right results. And it is all with collections.

$baseMap = collect($baseMap)->sortKeys();

$result = $items->map(function ($item) use ($baseMap) {

            return $baseMap->values()
                ->combine(
                    collect($item)->sortKeys()->intersectByKeys($baseMap)
                )
                ->all();
        });

May
29
5 months ago
Activity icon

Replied to Map Array Values To Collection Of Items

Update for the users interested :

Dirty , but collections only , must be a cleaner way to do this!

$baseMap = collect($baseMap);

$results = $items->map(function ($item) use ($baseMap) {

            return collect($item)
                ->only($baseMap->flip())
                ->mapWithKeys(function ($value, $key) use ($baseMap) {


                    return [$baseMap->get($key) => $value];


                })
                ->all();

        })->all();

Or just plain php :


$result = $items->map(function($item) use ($baseMap) {
    $array = [];

    foreach($baseMap as $oldKey => $newKey){
        if(isset($item[$oldKey])){
            $array[$newKey] = $item[$oldKey];
        }
    }

    return $array;
})->all();

Activity icon

Replied to Map Array Values To Collection Of Items

Thanks for replying. But baseMap will be dynamic. As a class property for example.

 protected $baseMap =[
        'name' => 'new_name',
        'year' => 'new_year',
        'same' => 'same'
    ];


// In another class for example

public function map(Collection $items,$baseMap){

         
        /// the magic needs to happen here...



}
Activity icon

Started a new Conversation Map Array Values To Collection Of Items

How would one do the following elegantly with laravel collections ?

Map the values of the $baseMap as keys to the collection.

The baseMap :

    $baseMap = [
                'name' => 'new_name',
                'year' => 'new_year',
            ];

The collection :

     $items = collect([
                [
                    'name' => 'name1',
                    'year' => '1000',
                    'not_in_basemap' => 'foo'
                ],
                [
                    'name' => 'name2',
                    'year' => '2000',
                    'not_in_basemap' => 'foo'
                ],
                //...
            ]);

The end result :

    $result =[
                [
                    'new_name' => 'name1',
                    'new_year' => '1000',
                 
                ],
                [
                    'new_name'=> 'name2',
                    'new_year' => '2000',
                 
                ],
            ];

I know how to do it in plain php , just wondering what a nice collection version would be. Thanks!