kevinbui wrote a reply+100 XP
6d ago
This Youtube video presents exactly what you need: https://www.youtube.com/watch?v=lPX-BCkkoO0
kevinbui started a new conversation+100 XP
2w ago
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 wrote a comment+100 XP
2w ago
kevinbui wrote a reply+100 XP
2w ago
kevinbui liked a comment+100 XP
2w ago
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 liked a comment+100 XP
2w ago
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 wrote a comment+100 XP
2mos ago
kevinbui wrote a reply+100 XP
2mos ago
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 liked a comment+100 XP
2mos ago
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 liked a comment+100 XP
2mos ago
kevinbui wrote a reply+100 XP
2mos ago
kevinbui liked a comment+100 XP
2mos ago
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
- Sign up for Laravel Forge and connect a DigitalOcean account.
- Create a new server (2–4GB RAM).
- Deploy your Laravel app (GitHub/Bitbucket/GitLab).
- Set up SSL, Nginx, queue workers, etc. via Forge dashboard.
- 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 liked a comment+100 XP
2mos ago
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 wrote a reply+100 XP
2mos ago
@jeffreyway still, bringing back 0.5x and 0.75x is still a good idea, if that is not too much a burden.
kevinbui wrote a reply+100 XP
2mos ago
You have the answer in this thread: https://laracasts.com/discuss/channels/site-improvements/playback-speed
kevinbui wrote a reply+100 XP
2mos ago
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 liked a comment+100 XP
2mos ago
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 wrote a reply+100 XP
2mos ago
kevinbui wrote a reply+100 XP
2mos ago
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 wrote a comment+100 XP
2mos ago
kevinbui wrote a reply+100 XP
2mos ago
kevinbui liked a comment+100 XP
2mos ago
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 liked a comment+100 XP
2mos ago
kevinbui liked a comment+100 XP
2mos ago
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.
kevinbui liked a comment+100 XP
2mos ago
kevinbui liked a comment+100 XP
2mos ago
Yes, it will likely slow down the import.
You should only have as many indexes as you need, and as few as you can get away with.
Quote from Aaron Francis.
Think of an index as a alphabetically sorted box of cards, and the box is then divided into section A - Z. So every time you need to insert something into the index, you need to first find the section, and then the exact place for it within the section. Now imagine doing that 28 times for each card.
If you are then using MySQL or MariaDB then each time you insert something and the index is refreshed, the table is locked, so you can't insert into it until all indexes are up to date. This will be fairly fast per index, but 28 is a lot, and the indexes will likely cause deadlocks between each other.
Indexes should basically only be used on column that you use in WHERE, ORDER BY, and foreign keys.
kevinbui wrote a reply+100 XP
2mos ago
900 lines are way too much for a function and that should be refactored to tiny ones.
According to the most comprehensive resource on clean Code, the book Clean Code by Uncle Bob Martin. Each function should only contain 3-4 lines, at the same level of abstraction.
"The first rule of functions is that they should be small. The second rule of functions is that they should be smaller than that."
Robert C. Martin
I must admit 3-4 lines per function is a bit hard to achieve. We can aim for at most 10 lines per function for the most part.
Small functions are crucial to clean code and readability. Looking at the Laravel source code, thousands of people can grasp and contribute. Monster functions and chunks of code are only maintainable to whoever wrote them in the first place.
The unfortunate reality is, the majority of developers don't care much about clean code or small functions. Still, I always strive for them.
kevinbui liked a comment+100 XP
3mos ago
I've created a reusable composable for this, considering pagination, etc...
It's been used in Modular and you can find the mentioned Composable here.
In this example instead of Lodash, I'm using "useDebounceFn" from Vue Use.
Hope it helps.
kevinbui liked a comment+100 XP
3mos ago
Hello,
By default a notification is attached to a specific user.
What could be the solution if I need that a notification is available for several users (for example the managers can see the notifications) and once a manager has handled the notification, it is destroyed from the database, so that other managers don't see it anymore.
Is it a solution by using the standard Laravel notifications ?
Thanks for your help.
V
kevinbui liked a comment+100 XP
3mos ago
kevinbui liked a comment+100 XP
3mos ago
Certainly! Here’s some advice for tackling the "Laravel From Scratch 2026" course:
-
Is there a simpler level than this?
The "Laravel From Scratch" course is intended as a beginner-level resource, but if you're finding it challenging, you might benefit from learning some prerequisites first:- PHP Basics: Make sure you're comfortable with PHP, as Laravel is a PHP framework. If not, consider completing a foundational PHP course before diving into Laravel.
- HTML & Basic Web Development: Understanding HTML, basic CSS, and how the web works is essential.
-
Best way to study the course:
- Go Slowly: Pause frequently, and never rush. It's perfectly normal to re-watch videos multiple times.
- Practice Actively: Don't just watch—type out every example from scratch. Experiment with the code to reinforce learning.
- Read the Documentation: The Laravel documentation is very beginner-friendly.
- Join the Community: If you get stuck, search or ask on Laracasts forums or Laracasts Discord. Others have often had the same questions.
- Take Notes: Write down key concepts in your own words.
- Build Small Projects: Try isolating what you learn into simple apps or features apart from the course project.
-
If you’re still stuck:
Perhaps try an even gentler introduction:- There are free resources like Laravel’s own getting started page
- YouTube also has beginner tutorials with a slower pace; search “Laravel for absolute beginners”.
Example Learning Plan:
1. PHP basics (variables, control flow, functions, classes)
2. Composer & basic command-line usage
3. Laravel basic installation and file structure
4. Routing & Controllers
5. Views & Blade Templates
Remember: It’s normal to feel lost at first. Persist, practice, and don’t hesitate to repeat sections or ask for help. You’ll improve with time and hands-on coding. Good luck!
kevinbui liked a comment+100 XP
4mos ago
Generally I did not like the respository pattern. It makes code more complex and writing the more code for just a resuable functions and other stuffs.
That is correct. If you lookup many past post on this question you will find myself and others have suggested staying with regular MVC and using laravel convention is better.
I wouldn't use that pattern.
Actions or controller methods either will produce the same result, that is preference.
kevinbui wrote a reply+100 XP
4mos ago
This is interesting topic.
In general, nah, we should not use Laravel Telescope in production.
But, contemplating a bit more. I think it might not be a bad idea.
As I understand, Laravel Telescope simply hook handlers to events fired by Laravel. And those handlers can be queued, so performance may not be a big deal.
Security is not a problem either. Telescope simply saves app activities to database.
The only problems that I can think of is your database will expand exponentially, considering the amount of data to be recorded. and Telescope provide nothing more that just raw data being recorded.
So, if you have a side project or a low-traffic app, and you are only interested in a handful of criteria, no insights or analysis need, then Telescope is not a bad idea. Just set up a queue, enable only a handful of watchers, and prune data regularly, then I think you will be fine. We can always remove telescope and use more advanced tools later.
kevinbui liked a comment+100 XP
4mos ago
kevinbui liked a comment+100 XP
4mos ago
The short answer is NO, you shouldn't. You should use a tool like Laravel Nightwatch.
https://nightwatch.laravel.com/
The longer answer is, you can use it, but you just like you say need to handle the security yourself.
kevinbui liked a comment+100 XP
4mos ago
The framework's validator will be more robust; you can bail or stopOnFirstFailure on the first failure on any attribute, you can validate the current_password for a given guard. You can specify your custom error messages, and even return only the first failure if that's what you want (although this is horrible UX in my opinion - if the user makes multiple mistakes, then let them know to fix all of them:
$validator = Validator::make($request->all(), [
'current_password' => ['bail', 'required', 'current_password:foo'],
'new_password' => ['bail', 'required'],
'new_password_verify' => ['bail', 'required'],
], [
'current_password.required' => 'lang.profile.settings.preferences.password.current_password.error.required',
'new_password.required' => 'lang.profile.settings.preferences.password.new_password.error.required',
'new_password_verify.required' => 'lang.profile.settings.preferences.password.new_password_verify.error.required',
]);
if ($validator->stopOnFirstFailure()->fails()) {
return back()
->withInput()
->withErrors()
->with('hasLinkBack', true);
}
// Update password
auth('foo')->user()->update(['password' => Hash::make($request->new_password)]);
return redirect()
->route('my.profile.settings.preferences.password.edit')
->with('success', 'lang.profile.settings.preferences.password.updated_successfully');
kevinbui liked a comment+100 XP
4mos ago
Certainly! Here are some options and recommendations for adding a ticketing/feedback system to your Laravel (Inertia + Vue) dashboard:
1. Building a Simple Custom Ticketing System
Since your current need is quite basic (messages/feedback), you might want to start small and iterate. Here’s a simple approach you can expand on later:
a) Migration Example
// database/migrations/xxxx_xx_xx_create_tickets_table.php
Schema::create('tickets', function (Blueprint $table) {
$table->id();
$table->foreignId('user_id')->constrained()->onDelete('cascade');
$table->string('type')->default('message'); // message, bug, feature, support, etc.
$table->string('subject');
$table->text('message');
$table->timestamps();
});
b) Eloquent Model
class Ticket extends Model
{
protected $fillable = ['user_id', 'type', 'subject', 'message'];
public function user()
{
return $this->belongsTo(User::class);
}
}
c) Basic Controller (for Inertia/Vue)
class TicketController extends Controller
{
public function index()
{
return Inertia::render('Tickets/Index', [
'tickets' => Ticket::where('user_id', auth()->id())->get(),
]);
}
public function store(Request $request)
{
$data = $request->validate([
'type' => 'required|string',
'subject' => 'required|string|max:255',
'message' => 'required|string',
]);
auth()->user()->tickets()->create($data);
return redirect()->back()->with('success', 'Feedback submitted!');
}
}
d) Vue Component Example
A simple form for submitting feedback/tickets:
<template>
<form @submit.prevent="submit">
<select v-model="form.type">
<option value="message">Message</option>
<option value="bug">Bug Report</option>
<option value="feature">Feature Request</option>
<option value="support">Support</option>
</select>
<input v-model="form.subject" placeholder="Subject" required />
<textarea v-model="form.message" placeholder="Your message" required />
<button type="submit">Send</button>
</form>
</template>
<script setup>
import { reactive } from 'vue'
import { useForm } from '@inertiajs/vue3'
const form = useForm({
type: 'message',
subject: '',
message: '',
})
function submit() {
form.post('/tickets')
}
</script>
2. Using Existing Packages
- coderflexx/laravel-ticket: While it’s not very recently updated, it might still work, especially with basic needs. If you use it, test carefully and consider forking/updating for your Laravel version.
- Spatie and Other Vendors: As of now, there isn’t a big, widely-used open-source ticket system package for Laravel. Most robust solutions are SaaS or standalone apps.
3. External/SaaS Integrations (For Future Needs)
If you need something more advanced or want to avoid maintenance:
- Use SaaS like: Zendesk, Freshdesk, HelpScout
- Generic Contact Form SaaS, embedding or webhooks.
- These can often be embedded, or you can use their API from Laravel to sync tickets or provide a feedback widget.
Recommendation:
Start with a lightweight internal system as sketched above. This keeps user feedback easy to manage and gives flexibility. Later, you can either evolve this or migrate to an external system once your needs outgrow it.
Let me know if you need full code examples or more advanced workflow (such as replies, admin dashboard, etc)!
kevinbui wrote a reply+100 XP
4mos ago
kevinbui wrote a reply+100 XP
4mos ago
This is a 9-year-old thread. I happen to have a couple of side projects related books, music, movies and video games so I can suggest a few tips.
Yes, Laravel can achieve this, then and now, and it is even more fun now.
When we work movies, video games, books and music, there are heaps of external APIs to obtain data from, such as https://www.omdbapi.com/. We don't want to rely too much on those external APIs, and you said you want to sort by duration. So it is probably a good idea to just call the API once, save the response to our database, and not having to run it again:
use App\Models\Movie;
use Http;
class MoviesController extends Controller
{
public function get(Movie $movie)
{
if (! $movie->duration || ! $movie->release_year)
{
$response = Http::get("http://img.omdbapi.com/?apikey=my_api_key&{$movie->imdb_id}");
$movie->update([
'duration' => $response['duration'],
'release_year' => $response['release_year']
]);
}
return view('movies.show', compact('movie'));
}
}
kevinbui wrote a reply+100 XP
4mos ago
You are probably right, we aren't able to predefine default attributes for new model instances using that $pendingAttributes property.
But I have just found out that we can do the followings with that attribute:
use App\Models\Movie;
Movie::query()
->withAttributes([
'title' => 'The Godfather',
'imdb_id' => 'tt0068646',
'release_year' => 1972,
])
->make();
These two approaches probably do the same thing, I personally still prefer to use the make method.
kevinbui liked a comment+100 XP
4mos ago
The make method make use of that $pendingAttributes property, so we can configure predefined attributes for a new model instance. The make method is a more superior way to generate models.
That's not what the property is for. It's used by the Eloquent builder. If you want default values, you use the $attributes property. And if you want custom values, you pass them in the constructor like they did.
Calling make() is unnecessary if you just want a model instance. So I agree with Larastan.
kevinbui wrote a reply+100 XP
4mos ago
kevinbui liked a comment+100 XP
4mos ago
How many databases do you have on production servers? Maybe a worker is somehow pointed to a wrong database or table?
What is the value of default and connections.database values in config/queue.php file?
Go to php artisan tinker on production server and give the output:
> config('queue.default')
> config('queue.connections.database')
kevinbui wrote a reply+100 XP
4mos ago
@gaiustemple @pilat nope, I don't think so. I believe the make method is a more advanced way to create a new model instance and should be the recommended way.
Looking at the source code:
// Illuminate\Database\Eloquent\Builder
public $pendingAttributes = [];
public function make(array $attributes = [])
{
return $this->newModelInstance($attributes);
}
public function newModelInstance($attributes = [])
{
$attributes = array_merge($this->pendingAttributes, $attributes);
return $this->model->newInstance($attributes)->setConnection(
$this->query->getConnection()->getName()
);
}
The make method make use of that $pendingAttributes property, so we can configure predefined attributes for a new model instance. The make method is a more superior way to generate models.
I also don't agree with that Larastan's statement.
kevinbui wrote a reply+100 XP
5mos ago
kevinbui wrote a reply+100 XP
5mos ago
I have read the source code a bit, the Notification::swap() method and the Illuminate\Support\Facades\Facade class.
All the mentioned solutions might work, but I believe this is the correct way to to get a real instance again:
use Illuminate\Support\Facades\Notification;
use Illuminate\Notifications\ChannelManager;
if (Notification::isFake()) {
$name = ChannelManager::class;
Notification::clearResolvedInstance($name);
Notification::getFacadeApplication()?->forgetInstance($name);
}
Ideally this should be a method of the Illuminate\Support\Facades\Facade class. I am thinking about contributing a real method to Laravel that do the same.
namespace Illuminate\Support\Facades\Facade;
abstract class Facade
{
public static function real(): void
{
if (static::isFake()) {
$name = static::getFacadeAccessor();
static::clearResolvedInstance($name);
static::$app?->forgetInstance($name);
}
}
}
kevinbui liked a comment+100 XP
5mos ago
The solution suggested by @orest worked for me in the case of Notifications, but I tried it for reverting Http::fake() (using \Illuminate\Http\Client\Factory::class instead of ChannelManager::class) and it didn't seem to work. But I found this solution which worked for both.
Notification::swap(null);
Http::swap(null);
kevinbui liked a comment+100 XP
5mos ago
kevinbui liked a comment+100 XP
5mos ago
In the majority of my tests in Dusk, I want to run Notification:fake() and in order to avoid writing it in every test file, I moved it to DuskTestCase
abstract class DuskTestCase extends BaseTestCase
{
use CreatesApplication;
public function setUp(): void
{
parent::setUp();
Notification::fake();
}
}
However, there are few tests that I actually need to send real notifications.
Is there a way to swap the fake notification with the real ?