Hey Laravel Developers 👩💻
Do you know about the withoutDelay() method in Laravel Queues?
Laravel Queues allow us to execute some code (Jobs) in the background while quickly responding to user requests.
To dispatch these Jobs to the queue, we use the dispatch() method on the corresponding Job class.
Sometimes, your Jobs might have a default delay configured, for example, by overriding the delay() method.
If you need to dispatch the Job immediately in a particular scenario, you can chain the withoutDelay() method to the dispatch() method call, and the Job will be dispatched without any delay.
#laravel #php
Hey Laravel Developers 👩💻,
Do you know about the rescue() helper function available in Laravel?
The rescue() function takes a function as a parameter, which executes immediately but won't throw an exception if one occurs.
Hence the name rescue(), as the request continues, and is "rescued" from the exception. Cool thought there!
However, if an exception occurs, it is still reported to the log files.
Here is an example of the difference between the rescue() function and a try-catch block...
#laravel #php
Laravel devs, filter collections by type with this gem! 💎
Use whereInstanceOf() to keep only items of a specific class. Perfect for processing mixed-type collections or cleaning up polymorphic relations.
Pro tip: Great for handling heterogeneous data structures.
#Laravel
Hey Laravel Developers 👩💻
Laravel allows us to configure the strength of a password by chaining different methods on the Password class, such as min(), symbols(), etc.
But, we also have the uncompromised() method, which makes an API call to the Have I Been Pwned API service to check whether the password has been compromised earlier. (i.e) leaked online through some other application
Here is a sample code of how the Password validation looks along with the uncompromised() method.
#laravel #php
𝗛𝗼𝘄 𝗰𝗮𝗻 𝘆𝗼𝘂 𝗯𝗲𝗰𝗼𝗺𝗲 𝗮 𝗴𝗿𝗲𝗮𝘁 𝗹𝗲𝗮𝗱𝗲𝗿 𝗯𝘆 𝗯𝗲𝗶𝗻𝗴 𝗳𝗹𝗲𝘅𝗶𝗯𝗹𝗲?
According to Daniel Goleman, a psychologist best known for his work on emotional intelligence, "𝘉𝘦𝘪𝘯𝘨 𝘢 𝘨𝘳𝘦𝘢𝘵 𝘭𝘦𝘢𝘥𝘦𝘳 𝘮𝘦𝘢𝘯𝘴 𝘳𝘦𝘤𝘰𝘨𝘯𝘪𝘻𝘪𝘯𝘨 𝘵𝘩𝘢𝘵 𝘥𝘪𝘧𝘧𝘦𝘳𝘦𝘯𝘵 𝘤𝘪𝘳𝘤𝘶𝘮𝘴𝘵𝘢𝘯𝘤𝘦𝘴 𝘮𝘢𝘺 𝘤𝘢𝘭𝘭 𝘧𝘰𝘳 𝘥𝘪𝘧𝘧𝘦𝘳𝘦𝘯𝘵 𝘢𝘱𝘱𝘳𝘰𝘢𝘤𝘩𝘦𝘴." The best leaders understand and empathize with the needs of their team members and situations, adapting their style accordingly. This is the core principle behind 𝘀𝗶𝘁𝘂𝗮𝘁𝗶𝗼𝗻𝗮𝗹 𝗹𝗲𝗮𝗱𝗲𝗿𝘀𝗵𝗶𝗽, a model that Paul Hersey and Ken Blanchard developed, fostering a sense of value and understanding in the team.
People in any team or organization have varying levels of competence and commitment to a given task or goal. An experienced team member working on a project they've done many times before has very different needs than a new hire who is just learning the job. The situational leadership model empowers leaders to analyze each person's competence level and commitment and then adapt their supervision style to assist best and motivate that individual, giving them a sense of control and capability.
In this model, there are four core leadership styles:
𝟭. 𝗗𝗶𝗿𝗲𝗰𝘁𝗶𝗻𝗴 - This style involves giving clear instructions and direction (not micromanaging). It is best used for people of low competence who need supervision to build skills. The usual case is when we have a new employee, so we must tell them what they have to do and how or in crises.
𝟮. 𝗖𝗼𝗮𝗰𝗵𝗶𝗻𝗴 - With this style, the leader provides more hands-on coaching, feedback, and support while providing directives. Here, we ask questions such as: "How can I help you?" and "What do you want to achieve next?". Now, people already developed some competence, so constant direction is optional. It works well for people of modest competence who commit to improving and building their skills. You support your people's motivation and sense of worth by genuinely caring about their professional growth.
𝟯. 𝗦𝘂𝗽𝗽𝗼𝗿𝘁𝗶𝗻𝗴 — Here, the leader is supportive, facilitating and "cheering on" the team members rather than closely directing them. It's ideal for competent people who work independently (say, seniors). Here, we as leaders want to oversee the process and be involved in some decisions, mainly by setting goals and providing growth opportunities.
𝟰. 𝗗𝗲𝗹𝗲𝗴𝗮𝘁𝗶𝗻𝗴 — The best approach for highly competent and committed team members is to delegate responsibilities and allow them autonomy while monitoring progress. Here, we leaders want to periodically check progress and be included in essential decisions.
#leadership
⚡You can do some pretty cool stuff with enums in PHP and Laravel. In this thread, I’ve collected some of the useful stuff, such as:
- Backed enums
- Using enums as factories
- Validation
- Enum route binding
- Model attribute casts
🧵Keep Reading