jasonomarion

Member Since 2 Years Ago

Experience Points
100
Total
Experience

4,900 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
0
Lessons
Completed
Best Reply Awards
0
Best Reply
Awards
  • start your 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-in-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 Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • evangelist 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.

  • Community Pillar

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

Level 1
100 XP
May
21
3 weeks ago
Activity icon

Replied to Storage New Folder Default Owner Is ROOT?

After playing with setfacl, chmod g+s and chmod u+s the problem solved. Now new directories and files has nginx:nginx.

Activity icon

Replied to OFFSET Clauses Can Be Very Slow When Used With High Offsets

The helpfull statement to optimize queries is EXPLAIN. https://dev.mysql.com/doc/refman/8.0/en/using-explain.html

It will show your how many rows are filtered and which indexes are used.

I won't ask you for the third time to show output of this query to help you:

EXPLAIN select * from `posts` where `status` = 6 and exists (select * from `categories` inner join `post_category` on `categories`.`id` = `post_category`.`category_id` where `posts`.`id` = `post_category`.`post_id` and `key` = 'fun') order by `count_views` desc limit 24 offset 8304;

But if you decide to try the query above - you will understand which indexes do you need to reduce query execution time.

Activity icon

Replied to OFFSET Clauses Can Be Very Slow When Used With High Offsets

I need to have psychic abilities to solve your problem without output of this query:

explain select * from `posts` where `status` = 6 and exists (select * from `categories` inner join `post_category` on `categories`.`id` = `post_category`.`category_id` where `posts`.`id` = `post_category`.`post_id` and `key` = 'fun') order by `count_views` desc limit 24 offset 8304;

You are going in right way by adding indexes, but why composite status+count_views and another similarcount_views?

Anyway the output of query above will help to fix your problem.

Activity icon

Replied to OFFSET Clauses Can Be Very Slow When Used With High Offsets

Show your output of next query:

explain select * from `posts` where `status` = 6 and exists (select * from `categories` inner join `post_category` on `categories`.`id` = `post_category`.`category_id` where `posts`.`id` = `post_category`.`post_id` and `key` = 'fun') order by `count_views` desc limit 24 offset 8304

probably composite index of status and count_views doesn't help.

Activity icon

Started a new Conversation Storage New Folder Default Owner Is ROOT?

I'm using "dedicated folder for each user" structure. When somebody uploads file to my app, it will be stored in special folder, then it will be converted by FFMpeg library to required format and will be returned to user.

For example:

// validations ...
$path = Storage::disk('tmp')->putFileAs('toConvert/'.auth()->id(),$request->file,$name);
// convert to required format with FFMpeg and return to user

Everything works well, but not for new users.

For example: New registered user has id 5000. When he will try to upload something, Laravel fails in attempt to put file in new folder 5000: ./storage/temp/toConvert/5000/EXAMPLE.ogg with error .ERROR: fopen(/var/www/myCoolApp/storage/tmp/toConvert/5000/EXAMPLE.ogg): failed to open stream: Permission denied.

This because a new generated folder has owner and group: root. Only after chown nginx. /var/www/myCoolApp/storage/tmp/toConvert/5000 command Laravel put files without any errors.

I can't always do command above after a new user registration! Why Laravel creates new folder with user:group root:root?

chown nginx. /var/www/myCoolApp/storage /var/www/myCoolApp/bootstrap/cache -fR and chmod 775 /var/www/myCoolApp/storage /var/www/myCoolApp/bootstrap/cache -fR doesn't help. New folders will be created as root by Laravel.

php -i | grep USER output:

USER => root
$_SERVER['USER'] => root

But /etc/php-fpm.d/www.conf has:

user = nginx
group = nginx
listen.owner = nginx
listen.group = nginx
listen.mode = 0660

php artisan:cache clear doesn't help.

ps aux | grep php output:

root      1261  0.0  0.3 404040 14088 ?        Ss   18:42   0:00 php-fpm: master process (/etc/php-fpm.conf)
nginx     1262  0.0  0.7 419192 29712 ?        S    18:42   0:00 php-fpm: pool www
nginx     1263  0.0  0.6 419028 26856 ?        S    18:42   0:00 php-fpm: pool www
nginx     1264  0.0  0.7 417108 27960 ?        S    18:42   0:00 php-fpm: pool www
nginx     1265  0.0  0.7 419156 30192 ?        S    18:42   0:00 php-fpm: pool www
nginx     1266  0.0  0.6 419052 26848 ?        S    18:42   0:00 php-fpm: pool www

config/filesystems.php:

        'tmp' => [
            'driver' => 'local',
            'root' => storage_path('tmp'),
        ],

Laravel version 5.8. Php version 7.2.34.

I have an another app with similar folders structure for avatars (special folder for each user), but it works well. php -i | grep USER command shows root too.

I will be grateful if you point me in the right direction.

May
13
4 weeks ago
Activity icon

Replied to Eloquent Carbon And Displaying Dates In A Users Local Timezone

@robjbrain I did it by getters in Model. For example in Order Model:

    private function localTimezone($value = null)
    {
        return $value ? Carbon::parse($value)->setTimezone(auth()->user()->timezone ?? 'UTC')->toDateTimeString() : null;
    }

    public function getCreatedAtAttribute($value)
    {
        return $this->localTimezone($value);
    }

    public function getUpdatedAtAttribute($value)
    {
        return $this->localTimezone($value);
    }

    public function getBlockedAtAttribute($value)
    {
        return $this->localTimezone($value);
    }

In User model I have a timezone column which fills on user registration. Now when Laravel returns $order or paginated $orders variable it automatically converts dates for authenticated user's timezone. It is very convenient!