bugsysha

bugsysha

Member Since 4 Years Ago

Experience Points
236,165
Total
Experience

3,835 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
1611
Lessons
Completed
Best Reply Awards
102
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 48
236,165 XP
Jan
21
2 hours ago
Activity icon

Replied to Using A Queue With --once On Forge

@spresnac

Not really from the Forge UI. Maybe you can write some custom logic for it. How many of those jobs do you process per minute?

Activity icon

Awarded Best Reply on How To Run Seed With 1 Million User ?

If chunking does not solve the problem then all you can really do is do it multiple times or increase memory limit.

Can you show what you've tried cause it will be easier to spot what is wrong?

Activity icon

Replied to How To Run Seed With 1 Million User ?

If chunking does not solve the problem then all you can really do is do it multiple times or increase memory limit.

Can you show what you've tried cause it will be easier to spot what is wrong?

Activity icon

Replied to How Does Method Injection Works In A Method That Is Expecting Other Parameters?

Is there a way to inject OrderItemService into the add method? I don't want to do it globally (in the constructor).

No, you have to use constructor.

Activity icon

Replied to Best Way To Version Control Data?

I prefer JSON.

Activity icon

Replied to Database Performance Improvement: Searching Through 500,000+ Rows

@felixinx

If whereIn is not what you need then I would suggest to pull in Laravel Debugbar and enable models in configuration so you can see how many queries and hydrated models does your code generate.

Use this video https://reinink.ca/articles/viewing-model-counts-in-the-laravel-debugbar

Activity icon

Replied to [Concept] Laravel Docs Would Be Much Easier To Navigate With A Sticky Index Sidebar

@mrkarma4ya I get your point, but that Algolia powered search is quite insane. I never scrolled too much through docs. Just look for what I know is there or what I expect to be there or what google pointed me to.

Activity icon

Replied to Querying On Relation Column Within A Relationship

@vkronlein ofc that throws an error try this

return $this->hasMany(SupplierThread::class)->has('statuses', function($query) {
        $query->where('status', '!=', 'closed');
    });

Notice != instead of initial !== typo.

Jan
20
1 day ago
Activity icon

Replied to Database Performance Improvement: Searching Through 500,000+ Rows

Can confirm that is a great video.

Activity icon

Replied to IsLocal Check Not Working Correctly In Production...

Yeah, everyone is fighting that battle.

Activity icon

Replied to Database Performance Improvement: Searching Through 500,000+ Rows

Try to use whereIn for trip_id and then key results by that trip_id or something that makes sense in order to get an easy match with the remaining data.

Activity icon

Replied to Laravel Automagic For Beginners?

Do you think that going through and reading the documentation has value for someone at my stage of learning, or should it be used mainly as a reference for specific issues?

I've never learned anything from documentation. Docs are important to understand but not a source for learning at least for me.

Easiest way for me to learn Laravel was to start using it. Either rewrite some web app with Laravel or something that you wanted to build for a long time. Also following some video guide might come in handy. All of those approaches are like jumping into fire. So like Nike says "Just Do It" 🤞🏻

Activity icon

Replied to IsLocal Check Not Working Correctly In Production...

You are very welcome. Just remember that Laravel is so widely used that it is almost impossible for glitches like in this topic to stay alive for a long period without being fixed or at least noticed by the community. When ever I've blamed Laravel it turned out that I was wrong and my code had mistakes.

Activity icon

Awarded Best Reply on IsLocal Check Not Working Correctly In Production...

If you look at following

class Container implements ArrayAccess, ContainerContract

You will see how it is obtained.

Just wondering what $this['env'] references in that file if it is not APP_ENV

It does references APP_ENV in .env file but you probably have run php artisan config:cache before changing .env value for APP_ENV.

Clear the cache or recache again and see the results.

@fylzero

Activity icon

Replied to Laravel Automagic For Beginners?

Every model extends Illuminate\Database\Eloquent\Model which has a trait Illuminate\Database\Eloquent\Concerns\HasRelationships which contains hasMany method.

Maybe using IDE like PhpStorm can help you get up to speed with Laravel and it's magic.

There are only few cases important in the beginning like in this case

  • if you call $model->tasks() you will be able to chain on method calls to specify more constraints on your query
  • if you call $model->tasks you will receive a collection of results for your query
  • if you have scopeBest() method on your model you can call it like $model->best()

That will get you far from where you are now. When you get past that you can ask for more info on Laravel magic.

Activity icon

Replied to Querying On Relation Column Within A Relationship

Maybe this?

return $this->hasMany(SupplierThread::class)->has('statuses', function($query) {
        $query->where('status', '!==', 'closed');
    });
Activity icon

Replied to IsLocal Check Not Working Correctly In Production...

If you look at following

class Container implements ArrayAccess, ContainerContract

You will see how it is obtained.

Just wondering what $this['env'] references in that file if it is not APP_ENV

It does references APP_ENV in .env file but you probably have run php artisan config:cache before changing .env value for APP_ENV.

Clear the cache or recache again and see the results.

@fylzero

Activity icon

Replied to Launching Non Laravel HTML Pages

Have you used

php artisan storage:link

After that you will be able to use it. Just find a way to replace the paths to those JS/CSS files. That can be tricky if you do not force users when they upload files to use some predefined values or who knows what.

Activity icon

Replied to Launching Non Laravel HTML Pages

Just rename that index.html to something like index.blade.php. Also move main.js to /public/js/ same for css and reference them in index.blade.php like src="js/main.js".

Activity icon

Replied to TypeError: Null Is Not An Object

this.booking = e.booking; // Is this a modification?

Yes.

Activity icon

Replied to Permanent Redirect

Never used it but have you tried just adding slashes?

Route::permanentRedirect ('/catalog', '/gallery');

Also try this

Route::permanentRedirect ('/catalog/{any}', 'gallery')->where('any', '.*');
Activity icon

Replied to TypeError: Null Is Not An Object

Doing anything to that object like

this.booking.something = 123;
Activity icon

Replied to TypeError: Null Is Not An Object

On your booking component you have a prop called booking. Stop modifying that prop!!! 🤞🏻

Activity icon

Replied to Override Created_at Value From Eloquent Models, Without Disabling Timestamps

Why don't you use timezone info from the browser? Then you can use something like middleware to change default for Carbon. It should be "scalable".

Activity icon

Replied to TypeError: Null Is Not An Object

You are saying that something like this does not work?

Broadcast::channel('bookings.all', function () {
    return true;
});
Activity icon

Replied to IsLocal Check Not Working Correctly In Production...

I think instructions from documentation worked for me last time I've installed Telescope.

Activity icon

Replied to TypeError: Null Is Not An Object

Not sure I understand.

Activity icon

Replied to Carbon Localization Through App Locale

This should work

<?php

namespace App\Providers;

use Illuminate\Support\ServiceProvider;

class AppServiceProvider extends ServiceProvider
{
    public function register()
    {
        // ...
    }


    public function boot()
    {
        // ...
        \Illuminate\Support\Carbon::setLocale($locale);
    }
}

but it is better to get user from middleware if it depends on authenticated user. So go with middleware approach in previous post.

Activity icon

Replied to Carbon Localization Through App Locale

Try replacing

    public function handle($request, Closure $next)
    {
        $user = Auth::user();
        if ($user) {
            if ($user->locale != null) {
                $locale = $user->locale;
                \App::setLocale($locale);
                \Illuminate\Support\Carbon::setLocale($locale);
            } else {
                \App::setLocale('en');
                \Illuminate\Support\Carbon::setLocale('en');
            }
        } else {
            \App::setLocale('en');
            \Illuminate\Support\Carbon::setLocale('en');
        }

        return $next($request);
    }
Activity icon

Replied to TypeError: Null Is Not An Object

Shouldn't it be something like

Broadcast::channel('bookings.{bookingId}', function (User $user, int $bookingId) {
    return $user->id === Booking::findOrFail($bookingId)->user_id;
});
Activity icon

Replied to TypeError: Null Is Not An Object

This method should live on Bookings component.

         getBookings() {
             axios.post("/getBookings").then(res => {
                this.booking = res.data; // not sure what you are doing here since the route implies that you are fetching all bookings but you are assigning it to a single booking instance variable. also no need to assign it if you passed it as a prop
            });
         }, 

Do I need to import the BookingComponent to the first one?

If you did not register it as a global component then you have to import it. If you did register it as a global component do you do not need to import it.

Activity icon

Awarded Best Reply on Best Place To Put Some SQL To Run On Project Install

Either put it on a migration as you suggester or put it in a command. Just ensure that the command will check if everything was installed before installing it again.

Activity icon

Replied to TypeError: Null Is Not An Object

And after refresh it will be sorted within the bookings loop?

Yes if you do not make some mistake.

Activity icon

Replied to TypeError: Null Is Not An Object

Yeah, a nested component which will just display that booking.

Activity icon

Replied to Best Place To Put Some SQL To Run On Project Install

Either put it on a migration as you suggester or put it in a command. Just ensure that the command will check if everything was installed before installing it again.

Activity icon

Replied to TypeError: Null Is Not An Object

Then extract a booking component and put that Echo logic back in created method.

Activity icon

Replied to Carbon Localization Through App Locale

Try with following

    public function handle($request, Closure $next)
    {
        $user = Auth::user();
        if ($user) {
            if ($user->locale != null) {
                $locale = $user->locale;
                \App::setLocale($locale);
                setlocale(LC_TIME, config($locale));
            } else {
                \App::setLocale('en');
                setlocale(LC_TIME, config('en'));
            }
        } else {
            \App::setLocale('en');
            setlocale(LC_TIME, config('en'));
        }

        return $next($request);
    }
Activity icon

Replied to Carbon Localization Through App Locale

Show here changed code.

Activity icon

Replied to TypeError: Null Is Not An Object

Move from created

       window.Echo.private(`Bookings.${this.booking.id}`)
       .listen("BookingEvent", (e) => {
          this.booking = e.booking; 
          this.pushToBookings(this.booking);

       });

to watcher

watch: {
  booking() {
    window.Echo.private(`Bookings.${this.booking.id}`)
       .listen("BookingEvent", (e) => {
          this.booking = e.booking; 
          this.pushToBookings(this.booking);
    });
  }
}
Activity icon

Replied to Carbon Localization Through App Locale

Add this

setlocale(LC_TIME, config('en'));
// or
setlocale(LC_TIME, config('app.locale'));
Activity icon

Awarded Best Reply on Htmlspecialchars() Expects Parameter 1 To Be String, Object Given

Maybe this?

<booking :bookings="{{ $bookings->toJson() }}"></booking>
Activity icon

Replied to Order Paths By Date And Time, In Component

This will get back to 1,2,3.

Should work, but like I said who cares.

also sorry about the other thread, would have loved to give you the ba

No problem. For me my suggestion was a cleaner and more expressive approach.

Activity icon

Replied to Htmlspecialchars() Expects Parameter 1 To Be String, Object Given

Maybe this?

<booking :bookings="{{ $bookings->toJson() }}"></booking>
Activity icon

Replied to Order Paths By Date And Time, In Component

Since you are so nice here you go

return [...this.paths].sort((a, b) => (new Date(`${a.date} ${a.time}`)) - (new Date(`${b.date} ${b.time}`)));
Activity icon

Replied to Order Paths By Date And Time, In Component

You can shorten it, but who cares 🤣

Activity icon

Awarded Best Reply on Order Paths By Date And Time, In Component

return [...this.paths].sort((a, b) => {
  const aDateTime = `${a.date} ${a.time}`;
  const bDateTime = `${b.date} ${b.time}`;
  if (aDateTime > bDateTime) {
    return 1;
  }
  if (bDateTime > aDateTime) {
    return -1;
  }

  return 0;
});
Activity icon

Replied to Order Paths By Date And Time, In Component

return [...this.paths].sort((a, b) => {
  const aDateTime = `${a.date} ${a.time}`;
  const bDateTime = `${b.date} ${b.time}`;
  if (aDateTime > bDateTime) {
    return 1;
  }
  if (bDateTime > aDateTime) {
    return -1;
  }

  return 0;
});
Activity icon

Replied to [Concept] Laravel Docs Would Be Much Easier To Navigate With A Sticky Index Sidebar

Just press / on your keyboard and it will give you search and then navigate where ever you like.

Activity icon

Replied to Vapor For Everything?

I would go with Vapor for everything.