kevinbui's avatar

kevinbui was awarded Best Answer+1000 XP

3d ago

How to mock a service class used inside a controller ?

All of your solutions are legit.

Not super important, but to make this feature more SOLID. Maybe we create an interface for TypeService to implement, TypeServiceInterface for example, and bind that interface to TypeService. That will abide to the Dependency Injection principle.

class TypeService implements TypeServiceInterface {}

$app->bind(TypeServiceInterface::class, TypeService::class);

public function index(TypeServiceInterface $typeService) {}

As I understand, mocking interfaces in test cases could be more efficient and faster than actual classes.

Plus, a textbook benefit is the ability to substitute different implementations for the same interface (I don't think this is important anymore).

kevinbui's avatar

kevinbui liked a comment+100 XP

1w ago

Please advise how a beginner should learn to implement filter and search features.

From your question, it might be a good idea to learn the MySql WHERE and ORDER BY clauses as a first step.

kevinbui's avatar

kevinbui wrote a reply+100 XP

2w ago

Where is the best place to log user activity ?

All solutions given by @laryai are legit.

This package by Spatie also looks pretty cool.

kevinbui's avatar

kevinbui wrote a reply+100 XP

2w ago

How to mock a service class used inside a controller ?

All of your solutions are legit.

Not super important, but to make this feature more SOLID. Maybe we create an interface for TypeService to implement, TypeServiceInterface for example, and bind that interface to TypeService. That will abide to the Dependency Injection principle.

class TypeService implements TypeServiceInterface {}

$app->bind(TypeServiceInterface::class, TypeService::class);

public function index(TypeServiceInterface $typeService) {}

As I understand, mocking interfaces in test cases could be more efficient and faster than actual classes.

Plus, a textbook benefit is the ability to substitute different implementations for the same interface (I don't think this is important anymore).

kevinbui's avatar

kevinbui liked a comment+100 XP

2w ago

How to mock a service class used inside a controller ?

Hello,

I have this index function.

public function index()
{
    Gate::authorize('viewAny', Type::class);

    return Inertia::render('Admin/Types/Index', [
        'types' => fn () => (new TypeService)->all()->toResourceCollection(),
    ]);
}

But this way, the TypeService isn't mockable.

Is it a good idea to replace by this code ?

'types' => fn () => app(TypeService::class)->all()->toResourceCollection(),

I can also inject the service in the constructor of the controller, but if this service class isn't used inside all methods, it's not useful to load it inside the constructor.

So perhaps another way is to inject the service class inside the methods where it's used ?

Like this example ?

public function index(TypeService $typeService)

What's the best way to use this service class so that I can test the controller without executing the service class methods ?

Thanks for your help.

V

kevinbui's avatar

kevinbui wrote a reply+100 XP

2w ago

laravel Job

Have you searched for "Laravel" on LinkedIn Jobs?

Have you been to your local PHP/Laravel meetup? They typically find job candidates there.

kevinbui's avatar

kevinbui liked a comment+100 XP

2w ago

laravel Job

Have you tried Larajobs. https://larajobs.com/

kevinbui's avatar

kevinbui wrote a reply+100 XP

2w ago

How to manage different data for a customer

Cool, all the suggestions are spot on.

This thread inspires me to propose a Illuminate\Auth\Events\LoggingOut in this PR.

If the PR is approved, we can do something like this:

use Illuminate\Auth\Events\LoggingOut;

class SaveLastStore
{
    public function handle(LoggingOut $event)
    {
        return $event->user->update(['last_store_id' => session('last_store_id')]);
    }
}

So we don't have to re-update the last_store_id in the above selectStore method.

kevinbui's avatar

kevinbui liked a comment+100 XP

2w ago

How to manage different data for a customer

@yougotnet I’ve worked on plenty of “multi-tenant” applications like this. Just keep things simple by using foreign keys and route parameters.

For example, one of my projects is a multi-tenant CMS (like Wix or Squarespace). When a user logs into the admin panel, if they belong to multiple websites then they can pick which website they want to manage. When they do, they’re then just redirected to the dashboard route (/websites/{website}/admin). The route group looks like this:

Route::group([
    'middleware' => ['auth', 'can:update,website'],
    'prefix' => 'websites/{website:slug}/admin',
], static function (): void {
    Route::get('/', DashboardController::class)->name('website.admin.dashboard');

    // Other website admin routes...
});

Each controller action then gets the current website injected as a parameter, so you can then scope model queries to that website:

namespace App\Http\Controllers\Admin;

class ArticleController extends Controller
{
    public function index(Website $website)
    {
        $articles = $website->articles()->paginate();

        return view('admin.article.index', compact('website', 'articles'));
    }

    public function store(Website $website, StoreArticleRequest $request)
    {
        $article = $website->articles()->create($request->validated());

        return redirect()
            ->route('website.admin.article.index')
            ->with('success', 'Article created.');
    }
}
kevinbui's avatar

kevinbui liked a comment+100 XP

2w ago

How to manage different data for a customer

You can simply add a field to the users table to save the last used store.

kevinbui's avatar

kevinbui liked a comment+100 XP

2w ago

How to manage different data for a customer

Solution:

You can achieve this by leveraging session variables to store the "active store" for the customer and also saving the last active store in the database (in the user's profile, for example) so you can restore it when the user logs back in.

Here's a high-level approach:

1. Update Customer Model

Add a field to your users (or customers) table to store last_store_id.

// migration example
Schema::table('users', function (Blueprint $table) {
    $table->unsignedBigInteger('last_store_id')->nullable();
});

2. Store Selected Store in Session

When the user selects a store, update the session and the user's last_store_id:

public function selectStore(Request $request, Store $store)
{
    // Put the store ID in session
    session(['current_store_id' => $store->id]);
    
    // Update user's last_store_id
    Auth::user()->update([
        'last_store_id' => $store->id
    ]);

    return redirect()->back();
}

3. Set Store on Login

When the user logs in, check if last_store_id is set, and put it in the session:

public function authenticated(Request $request, $user)
{
    if ($user->last_store_id) {
        session(['current_store_id' => $user->last_store_id]);
    }
}

Register this method in your LoginController. In Laravel, you can use the authenticated method for this:

// app/Http/Controllers/Auth/LoginController.php
protected function authenticated(Request $request, $user)
{
    if ($user->last_store_id) {
        session(['current_store_id' => $user->last_store_id]);
    }
}

4. Retrieve Data Based on Selected Store

Whenever you need to fetch store-specific data, use session('current_store_id'):

public function someControllerMethod()
{
    $storeId = session('current_store_id');
    $store = Store::findOrFail($storeId);

    // Fetch data related to this store
    $products = $store->products;
    // ...
}

5. Optional: Middleware for Store Context

If you want, you can create a middleware to ensure the session always has a store, redirecting the user to select one if not:

public function handle($request, Closure $next)
{
    if (!session('current_store_id')) {
        return redirect()->route('select.store');
    }
    return $next($request);
}

Apply this middleware to any routes that require a store context.


Summary:

  • Use a session variable to store the active store.
  • Save the last active store in the user/customer table.
  • Restore this when the user logs in.
  • Always fetch data using the store from the session.

This approach will make sure the app always serves up data for the selected store, and that the user's last-used store is remembered on re-login.

kevinbui's avatar

kevinbui wrote a reply+100 XP

2w ago

Pest Featured test tutorial with latest version any suggestions?

For something that specific, I believe you have no problems figuring out to do so yourself.

kevinbui's avatar

kevinbui wrote a reply+100 XP

2w ago

Laravel, React , Typescript ,Inertia Course

What's wrong with with taking a separate course for each?

kevinbui's avatar

kevinbui liked a comment+100 XP

2w ago

Laravel without Composer?

I suggest troubleshoot the problem, fix it and correctly use composer.

kevinbui's avatar

kevinbui was awarded Best Answer+1000 XP

3w ago

How to mark one of my questions as Solved?

You probably know by now that it is the top right corner of a post.

This confusion makes me realise that some items in this dark mode could be super blurry for new members.

kevinbui's avatar

kevinbui wrote a reply+100 XP

3w ago

How to mark one of my questions as Solved?

You probably know by now that it is the top right corner of a post.

This confusion makes me realise that some items in this dark mode could be super blurry for new members.

kevinbui's avatar

kevinbui wrote a reply+100 XP

3w ago

Paid Laracasts Subscription

I highly recommend the paid subscription. The content quality if superb, help me get hired a decade ago and stay up-to-date today.

Quality content production and maintaining this website are very time-consuming. I believe they mostly don't have time to answer your questions directly.

But that should not be a problem, you can always ask AI or post your question in this forum. There are like 50 Laravel veterans always happy to help.

kevinbui's avatar

kevinbui wrote a comment+100 XP

1mo ago

The Many Misconceptions of Laravel : Ep 6, Is the Service Container Too Much?

I have been working with Laravel for more than a decade, but I still learn something new in every video in this series. Great work!

kevinbui's avatar

kevinbui liked a comment+100 XP

1mo ago

New book on how Laravel works under the hood. Looking for volunteer reviewers 🙏

Hi everyone,

I've been working on something for a few months, and I'm finally excited to share it here. I wrote a book about how Laravel actually works internally; the idea is that you build a mini Laravel from scratch, piece by piece: the service container, service providers, facades, the request lifecycle, the router, middleware, and the query builder to Eloquent.

Right now it's in the final review stage with me. Before I wrap it up, I'd love to get more eyes on it from people who really know the framework.

So I'm looking for a few volunteers who'd be up for reviewing it. It's completely volunteer-based; if you enjoy digging into Laravel's internals and want to help make the book better, I'd genuinely appreciate it.

If you're interested, you can inform me via the official website book: https://laravelinternals.com/

Thanks so much, and happy to share details more via email.

kevinbui's avatar

kevinbui wrote a reply+100 XP

1mo ago

Eloquent inside a migration ?

If you are playing around, not a problem. But pls don't do this a real project. Eventually it will slow down CI/CD drastically.

kevinbui's avatar

kevinbui liked a comment+100 XP

1mo ago

Eloquent inside a migration ?

Oh it was so silly ... I had refreshed all the database and the database is seed after the migrations, so while he migrations are run, there is no data.

kevinbui's avatar

kevinbui wrote a reply+100 XP

1mo ago

Eloquent Performance Patterns Course Needs an Update for Laravel 12/13

This is one of my favourite course in Laracasts. I actually bought the course from Jonathan Reinink for around $100 a year before it was released on Laracasts.

My answer is nah. No, that course does not need updating. Eloquent got quite a few updates since then but most of the examples are still working. Maybe the use of hasOne gotta be more up-to-date but people will figure that out.

Plus, the point of that course is not really about Eloquent. It is about constructing about the underlying DB queries that will be a lot more performant. Eloquent could be evolving, but DB queries will mostly stay the same.

kevinbui's avatar

kevinbui liked a comment+100 XP

1mo ago

How to review AI-generated code

@phpmick You should be in control of any and all code making its way into your codebase, whether that’s written by you, a colleague, or an LLM. Here are some tips and guidelines I follow when doing AI-assisted development:

  • Give agents very discreet tasks to complete.
  • When you’re prompting the agent, ask it to ask you about anything it’s unsure of instead of guessing. You’ll find you’ll get something far more in line with what you had in mind and were expecting, instead of giving an agent a loose description, and it making assumptions and making something that’s maybe 60% of what you wanted.
  • Give agents way to verify the work they’re producing. There should be a goal, as well as instructions on how to run any tool such as linting and testing tools. If linting/tests fail, the agent should go back and fix what’s broken before asking for your attention.
  • Agents should also be given guardrails to avoid getting stuck in a loop and burning tokens.
  • You should only be merging code you actually understand. If you don’t, review the agent output log. If you’re still unsure, then ask the agent to explain what it’s produced. As with human-produced code, less code is easier to grok than lots of code. Don’t have your agent spew out 50,000 lines of code and then review.
kevinbui's avatar

kevinbui wrote a reply+100 XP

3mos ago

Reverting from PEST to PHPUnit

This Youtube video presents exactly what you need: https://www.youtube.com/watch?v=lPX-BCkkoO0

kevinbui's avatar

kevinbui started a new conversation+100 XP

4mos ago

Save My Video Speed Preferences

Hi @JeffreyWay.

I typically watch the videos at 1.2x or 1.5x speed. But any time I move on to a new video, my video speed is back to 1.0x.

Can we preserve the preferences for our video speeds? We had this feature before, and have been losing it for quite while.

Cheers,

kevinbui's avatar

kevinbui wrote a comment+100 XP

4mos ago

Supercharged Search with Typesense: Ep 12, Instant Search From Scratch

That trick to substitute debouncing is pretty sick!

kevinbui's avatar

kevinbui wrote a reply+100 XP

4mos ago

Is it worth it to learn all the courses and coding when AI can make the production level application

As of today, I believe it is still worthwhile to learn coding yourself. We still have to understand, review and request changes or refactoring to works done by AI.

There are still a lot of concerns regarding security and code quality with AI.

kevinbui's avatar

kevinbui liked a comment+100 XP

4mos ago

Is it worth it to learn all the courses and coding when AI can make the production level application

Wait I am not taking about like AI would solve a code problem or fix it. I am talking according to business, If I code an application humanly, Its gonna take too much time, When a non coder who mabe barely knows coding but he Understands how the application works, He make the whole production level application without coding a single line.

So here is my question, Is it worth it to put my all valuable time learning vuejs components structure, Laravel MVC structure, how the code should refactor etc etc? Is it worth it put my value learning all these core stuff where now AI is handling 90% of the these stuff, We just need to tell the feature name or proper prompt.

OK Here is my another analyzation, Suppose I have built Production grade with Just Claude or copilot or mabe Lovable AI prompt, I know I dont know any of code inside what's happening, But the AI generated application is serving my goals perfectly, I mean the features I needed are working perfectly, So why do we need a developer to refactor the code or understand for human ? Because the application is already serving my 95% of the goal. If I need any customization AI is also doing that for that application.

So my whole point is, Is it really worth it to learn the core stuffs? Should I put valuable time on learning these core stuffs? Or should I migrate my self to learning making application with prompt or AI.

I dont know if I am thinking in right way or not, But these questions are in my head like AI already knows why should we learn core stuffs instead I can directly make applications with AI, Ok I understand I can't control the whole codebase but my application would be ready and with AI I can make customization or scale them.

Is it really worth it to learn Core Stuff or Coding? According current situation on earth?

The recent news oracle removed 30000 employee, and investing on AI.

kevinbui's avatar

kevinbui liked a comment+100 XP

4mos ago

Is it worth it to learn all the courses and coding when AI can make the production level application

Certainly, this is a very topical and thoughtful question! Here’s a nuanced answer:


It’s true that AI can generate functional code and even entire applications from prompts. For many scenarios, this is already a huge productivity boost and enables non-coders to prototype and even ship apps quickly.

But here’s why it’s still very much worth learning core coding fundamentals, structures, and patterns:

1. Understanding and Control

  • Debugging and Maintenance: AI can generate "working" code, but when things go wrong — and they will, especially at scale — you need to understand how things work under the hood to fix, debug, or even understand issues.
  • Customization: What if the AI generates code that almost works but isn’t quite what you want, or introduces subtle bugs, security issues, or performance problems? Deep knowledge lets you adapt and truly own your app.
  • AI Limitations: AI often generates code by pattern-matching, not real reasoning. It might miss context, overlook edge cases, or accidentally introduce hard-to-find bugs.

2. Best Practices, Security, and Large Scale

  • Scalability and Security: A human developer who understands best practices will be better positioned to make an app robust, secure, and able to scale — things AI can only do reliably if you can guide and review its decisions.
  • Refactoring: As your app grows, codebases get messy. You’ll need to refactor and optimize. Even with AI, knowing what and why to refactor is a core developer skill.

3. Job Market and Value

  • AI is a Tool, Not a Replacement (Yet): Companies are laying off in some places due to AI, but they are also hiring engineers who know how to use AI productively and oversee software quality.
  • Prompting requires understanding: Prompt engineering is easier when you understand what you’re asking AI to do. The best AI users are often those with deep context and technical understanding.

4. Business Risk

  • Black Box Risk: If you don’t know what’s happening in your codebase, you’re taking a business and legal risk. You may expose yourself to security vulnerabilities or technical debt that AI can’t explain, and if AI tools disappear, your knowledge base is gone too.

5. Learning is Never Wasted

  • Long-Term Flexibility: Technology changes rapidly. A solid foundation will make you adaptable to new frameworks, programming languages, and even future AI tools themselves.

A Balanced Approach

It’s smart to leverage AI for speed and help, but combine it with ongoing learning of core principles. Use AI to accelerate rote tasks and prototyping, and dedicate time to understanding the architecture, design patterns, and debugging.

Practical suggestion:

  • Use AI to help you learn! Let it give examples, ask it to refactor your code, or explain concepts.
  • But don’t skip the step of hands-on understanding and code reading.

Summary

Yes, it’s absolutely still worth learning the core stuff. AI will make you more productive, but foundational knowledge is what will truly make you a capable, valuable developer — whether you’re building with or without AI.


Example Scenario:

Suppose AI generates a Laravel API endpoint, but you encounter strange performance issues as your app scales. If you understand Laravel's request lifecycle, Eloquent, and how to profile code, you can identify and fix the bottlenecks or even teach the AI how to do it better next time. Otherwise, you're stuck, no matter how smart the AI appears!

In summary: Think of AI as a superpower, not a replacement for understanding. Combine both, and you'll have a massive edge in the new era.

kevinbui's avatar

kevinbui wrote a comment+100 XP

5mos ago

Supercharged Search with Typesense: Ep 6, Facets

Awesome lesson! And super clear explanation for newbies!

kevinbui's avatar

kevinbui wrote a reply+100 XP

5mos ago

project ideas

If it is simply to practise what you have learn, you don't need to come up with ground breaking ideas. Just try to re-create the applications that you see everyday:

  • A forum, like this forum.
  • A social network, such as Facebook, Instagram,....
  • A Q&A platform, such as Quora.
  • Something related to your hobbies. For example, I like reading, so I create a library app.

And you don't have to finish any of those, spin up as many projects as you like.

kevinbui's avatar

kevinbui liked a comment+100 XP

5mos ago

Inertia 2 Unleashed: Ep 3, Deferred Props

I just started using this feature, and it’s absolutely fantastic. The ability to defer props until they’re needed not only improves performance but also makes the code cleaner and more efficient.

Big thanks to the Inertia team for this amazing addition and to Jeffrey Way for always keeping us ahead of the curve with top-notch tutorials and insights

kevinbui's avatar

kevinbui liked a comment+100 XP

5mos ago

kevinbui's avatar

kevinbui wrote a reply+100 XP

5mos ago

Help With Eloquent Relationship Issue — Not Returning Expected

Weird. I have never had this problem before.

Can you share with us the structure of the users and profiles table? Is there a user_id field in the profiles table?

setting eager loading aside, pls run the following statement:

dd($user->profile);

Is the profile correctly loaded?

kevinbui's avatar

kevinbui liked a comment+100 XP

5mos ago

Best place to put a Laravel into production.

The "best" place to deploy a Laravel application depends on your budget, technical expertise, and preference for control vs. convenience. Here are your main options, each with pros and cons:

1. Managed Laravel Hosting (Easiest)

  • Services like Laravel Forge, Ploi.io, or Vapor are designed for Laravel and handle provisioning, deployments, SSL, etc.
  • They typically provision servers on AWS, DigitalOcean, Linode, or other providers for you.
  • Pros: Great developer experience, quick to set up, less DevOps overhead.
  • Cons: Monthly fee plus underlying server cost.

2. VPS Providers (Most Control)

  • DigitalOcean, Linode, Vultr offer VPSs (Virtual Private Servers) at low cost.
  • With a 2–4GB RAM server (starting ~$10/month) you can comfortably serve 200 peak users if code and DB are efficient.
  • You can use Forge/Ploi to help manage these, or do it manually (requires more Linux/server knowledge).
  • Pros: Good performance/price, full control.
  • Cons: Server management and security is your responsibility.

3. AWS/GCP/Azure (Enterprise Grade)

  • AWS EC2, RDS (for DB), S3 (file storage), and other services provide full flexibility and scalability.
  • Pros: Extremely scalable and reliable, many managed services.
  • Cons: Can be expensive and complex to configure/manage for small-to-medium projects.

4. Laravel Vapor (Serverless, Scalable)

  • Laravel Vapor is a serverless platform for Laravel, built on AWS Lambda.
  • Pros: Seamless scaling, no server management.
  • Cons: Higher monthly cost (+ you pay AWS), cold start delays can affect some workloads, more suited for stateless apps and APIs.

Recommendation for Your Use Case (200 Users/Peaks)

  • Comfortable with DevOps? Use a VPS (DigitalOcean, Linode) and manage yourself or with Forge/Ploi. 2GB+ RAM, managed DB if possible.
  • Minimal server management? Use Forge or Ploi to deploy to DigitalOcean, Linode, or AWS.
  • Want full "no server" scaling? Consider Laravel Vapor—but only if you expect unpredictable surges and can justify higher cost/complexity.

AWS is great but can get pricey and complex unless you need their scale. For 200 max users, a single $10–$20/month VPS plus managed DB is typically enough. Use Forge/Ploi for easier deployments.

Example: Deploying with Forge to DigitalOcean

  1. Sign up for Laravel Forge and connect a DigitalOcean account.
  2. Create a new server (2–4GB RAM).
  3. Deploy your Laravel app (GitHub/Bitbucket/GitLab).
  4. Set up SSL, Nginx, queue workers, etc. via Forge dashboard.
  5. Optionally, use managed databases (offered by DigitalOcean).

Summary Table:

Option Cost Ease Scaling Recommended For
Forge+VPS (DO/Linode) $10-30/mo Easy Limited Most small/med projects
AWS (EC2/RDS) $30+/mo Hard Highly Enterprise needs
Laravel Vapor $39+/mo Easy Highly High scale, serverless

Bottom Line:
For ~200 active users and good performance/cost, Forge or Ploi with a DigitalOcean/Linode server is ideal. Start there, and you can always scale up or migrate to AWS/Vapor if needed.

If you need deployment scripts or have more questions about the stack, let me know!

kevinbui's avatar

kevinbui liked a comment+100 XP

5mos ago

I've been unemployed for 6 months

Absolutely, breaking into the international developer market can be challenging, but there are steps you can take to improve your chances and stand out:

1. Tailor Your Portfolio & GitHub

  • Continuously update your portfolio (https://filipelab.com) with real-world projects. For each, write a concise description, your responsibilities, and technical challenges you solved.
  • Make your projects open-source on GitHub when possible. Recruiters love to see actual code. Add clear READMEs.
  • If you specialize in Laravel, consider including a “Case Studies” section for your best projects, explaining your design/development choices.

2. Demonstrate English Communication

  • Add a short video introducing yourself in English. This helps recruiters gauge your communication skills and boosts confidence in hiring you globally.
  • Write your documentation and READMEs in clear, error-free English.

3. Optimize LinkedIn for Recruiters

  • Use keywords in your title and summary (e.g., Laravel, PHP, REST APIs, AWS, Vue.js).
  • Ask previous colleagues to provide recommendations on LinkedIn.
  • Specify that you are seeking remote, international roles in your summary.

4. Prepare for Modern Interviews

  • Many interviews outside Brazil put more emphasis on coding challenges (e.g., on HackerRank, Codility) and system design questions. Practice these regularly.
  • Example platforms to practice:
    https://leetcode.com/
    https://exercism.org/tracks/php
    https://www.frontendmentor.io/
    
  • Also, be ready to discuss past projects, why you made certain decisions, and how you solve problems when things break.

5. Get Involved in Developer Communities

  • Answer questions on Stack Overflow, Laracasts, Reddit, etc. This can get you noticed.
  • Post articles or short technical write-ups (on your blog or Medium), tuned to the audiences you want to reach.

6. Apply Strategically

  • Focus on remote-friendly companies. Popular job boards include:
    https://weworkremotely.com/
    https://remoteok.com/
    https://larajobs.com/
    
  • Each application should have a tailored cover letter showing you understand their business and why you are a good fit.

7. Keep Practicing English

  • Join English speaking meetups, or pair-program via Zoom with international devs.
  • Tools like Grammarly can help, or consider short online courses for business English.

Summary Example (for LinkedIn/About page):

I’m a passionate Laravel/PHP developer with over 6 years of experience, specializing in building scalable web applications. I am seeking international remote opportunities, and I’m committed to clear communication and producing well-tested, maintainable code. Check out my portfolio at https://filipelab.com.

Final Tip: Persistence is key. Keep learning, keep applying, and keep iterating on your approach. Best of luck!

kevinbui's avatar

kevinbui wrote a reply+100 XP

5mos ago

Video playback speeds in Laracasts

@jeffreyway still, bringing back 0.5x and 0.75x is still a good idea, if that is not too much a burden.

kevinbui's avatar

kevinbui wrote a reply+100 XP

5mos ago

Debugging

I am mostly a backend developer, I don't know about debugging Javascript.

I believe this latest course is the only one about debugging PHP in Laracasts: https://laracasts.com/series/debugging-real-world-production-nightmares

In my day job, I gotta debug regularly, just like everyone else. We log a lot to AWS Cloudwatch, and we mostly gotta look at the logs to find out what happen. Context has been wildly helpful, we put the request id, order id and session id to the context to see the whole customer journey.

Tools like Datadog, NewRelic and Laravel Nightwatch are also popular.

kevinbui's avatar

kevinbui liked a comment+100 XP

5mos ago

Livewire 3 vulnerability found. Update now!

A vulnerability has been discovered that affects Livewire 3 versions up to and including 3.6.3 (https://nvd.nist.gov/vuln/detail/CVE-2025-54068). If you’re running a vulnerable version, you’re advised to upgrade immediately. This includes if you’re using a package (such as Filament) that relies on affected versions.

kevinbui's avatar

kevinbui wrote a reply+100 XP

5mos ago

inRandomOrder() is stupid naming

inRandomOrder() is grammatically correct and sounds perfectly find to me.

orderByRandom() sounds a bit off, I don't random is a noun.

This is a trivial matter. If you don't like the original method name, you can add a macro to Illuminate\Database\Query\Builder that refers to the original one.

kevinbui's avatar

kevinbui wrote a reply+100 XP

5mos ago

Not receiving Laracast emails

Nah, I receive every email from the threads that I follow. That still works perfectly for me.

Have you changed anything in https://laracasts.com/settings/notifications ?

kevinbui's avatar

kevinbui wrote a comment+100 XP

5mos ago

Debugging Real-World Production Nightmares: Ep 4, Atomic or Die (Or At Least Oversell)

Nice reminder about handling race conditions.

Just a small suggestion regarding this statement:

$product = Product::where('id', $item->product_id)
    ->lockForUpdate()
	->first();

That can be a bit simpler with whereKey:

$product = Product::whereKey($item->product_id)
    ->lockForUpdate()
	->first();
kevinbui's avatar

kevinbui wrote a reply+100 XP

5mos ago

How to push the failed job from the custom table to the queue?

What do you mean by customising the failed_jobs table? I believe it already got everything you need.

By the way, if you want to query the failed_jobs table, this will also work:

resolve('queue.failer')
    ->getTable()
    // ->where(...)
    ->paginate();
kevinbui's avatar

kevinbui liked a comment+100 XP

5mos ago

How to push the failed job from the custom table to the queue?

This functionality is already implemented by php artisan queue:retry <job id> command. You can see how this command is implemented and do the same: vendor/laravel/framework/src/Illuminate/Queue/Console/RetryCommand.php

But I'm sure recreating Laravel queue system from scratch is not what your senior wants you to do.

kevinbui's avatar

kevinbui liked a comment+100 XP

5mos ago

How to push the failed job from the custom table to the queue?

Yes, I think he just was a list of all failed jobs in the ui listing and from there it self he could have an option to trigger all failed jobs or a particular without using the terminal. Everytime we don't have system with us may be for that thing.

kevinbui's avatar

kevinbui wrote a reply+100 XP

5mos ago

Is it good having approximately 900 lines of a function?

Why isn't @laryai going crazy on this matter lol?

kevinbui's avatar

kevinbui liked a comment+100 XP

5mos ago

How to push the failed job from the custom table to the queue?

Yes, I think he just was a list of all failed jobs in the ui listing

@shivamyadav Your senior is literally re-inventing the wheel.

You could have just used Horizon for Redis-based queues. If you’re not using Redis, you still don’t need to push jobs to an entirely new table. You could have just queried Laravel’s native failed_jobs table. I’ve done it myself; including with a button to re-try failed jobs; no custom table needed.

Given the questions you’ve asked in such a short span of time, I don’t feel this “senior” is really someone you want to be learning habits from, as they seem to be senior in name only.