<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Luigi Laezza</title>
    <description>The latest articles on DEV Community by Luigi Laezza (@luigi_laezza_22b5ba44fdcd).</description>
    <link>https://dev.to/luigi_laezza_22b5ba44fdcd</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2130386%2F69141841-c5bf-4964-a969-adcb27ca56c0.jpg</url>
      <title>DEV Community: Luigi Laezza</title>
      <link>https://dev.to/luigi_laezza_22b5ba44fdcd</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/luigi_laezza_22b5ba44fdcd"/>
    <language>en</language>
    <item>
      <title>Laravel 11.30: A Leap Forward in Testing, Model IDs, and Authorization</title>
      <dc:creator>Luigi Laezza</dc:creator>
      <pubDate>Mon, 13 Jan 2025 14:55:57 +0000</pubDate>
      <link>https://dev.to/luigi_laezza_22b5ba44fdcd/laravel-1130-a-leap-forward-in-testing-model-ids-and-authorization-2e7j</link>
      <guid>https://dev.to/luigi_laezza_22b5ba44fdcd/laravel-1130-a-leap-forward-in-testing-model-ids-and-authorization-2e7j</guid>
      <description>&lt;p&gt;Laravel, the popular PHP web application framework, has recently unveiled its latest release, version 11.30. This update brings a host of new features and improvements that enhance developer productivity and code flexibility. Let's dive into the key highlights of this release.&lt;/p&gt;

&lt;h1&gt;
  
  
  New Testing Helpers: &lt;code&gt;withDefer()&lt;/code&gt; and &lt;code&gt;withoutDefer()&lt;/code&gt;
&lt;/h1&gt;

&lt;p&gt;One of the standout features in Laravel 11.30 is the introduction of new testing helpers, &lt;code&gt;withDefer()&lt;/code&gt; and &lt;code&gt;withoutDefer()&lt;/code&gt;, contributed by Tim MacDonald. These helpers are particularly useful when working with tests that use defer, but you need to disable it to assert the outcome of a deferred call.&lt;/p&gt;

&lt;p&gt;Here's an example of how to use the new &lt;code&gt;withoutDefer()&lt;/code&gt; helper:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="c1"&gt;// This will not work&lt;/span&gt;
&lt;span class="nc"&gt;User&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;create&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="cm"&gt;/* ... */&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;assertAgainstSomeDeferredOutcome&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="c1"&gt;// This will work&lt;/span&gt;
&lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;withoutDefer&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="nc"&gt;User&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;create&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="cm"&gt;/* ... */&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;assertAgainstSomeDeferredOutcome&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These helpers provide developers with more control over deferred operations during testing, allowing for more precise assertions and improved test reliability.&lt;/p&gt;

&lt;h2&gt;
  
  
  Custom Unique String IDs with &lt;code&gt;HasUniqueStringIds&lt;/code&gt; Trait
&lt;/h2&gt;

&lt;p&gt;Luke Kuzmish has introduced the &lt;code&gt;HasUniqueStringIds&lt;/code&gt; trait, which allows developers to use custom unique string IDs as route keys without overriding the &lt;code&gt;resolveRouteBindingQuery()&lt;/code&gt; method. This update builds upon the existing &lt;code&gt;HasUuids&lt;/code&gt; and &lt;code&gt;HasUlid&lt;/code&gt; eloquent traits, providing more flexibility in ID generation.&lt;/p&gt;

&lt;p&gt;Here's an example of how to implement custom unique string IDs:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="kd"&gt;trait&lt;/span&gt; &lt;span class="nc"&gt;HasTwrnsTrait&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kn"&gt;use&lt;/span&gt; &lt;span class="nc"&gt;HasUniqueStringIds&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;newUniqueId&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;string&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nc"&gt;Twrn&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;protected&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;isValidKey&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$value&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="kt"&gt;bool&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nc"&gt;Twrn&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;isValid&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$value&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This feature allows for greater customization of model identifiers while maintaining compatibility with existing Laravel conventions.&lt;/p&gt;

&lt;h2&gt;
  
  
  Enhanced Authorization with Enum Support
&lt;/h2&gt;

&lt;p&gt;Johan van Helden has updated the &lt;code&gt;AuthorizesRequests&lt;/code&gt; trait to accept backed enums directly. This change aligns with Laravel's recent updates to support direct use of Enums in various parts of the framework.&lt;/p&gt;

&lt;p&gt;Here's how you can now use an Enum with the &lt;code&gt;authorize()&lt;/code&gt; method:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="n"&gt;enum&lt;/span&gt; &lt;span class="nc"&gt;DashboardPermission&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;string&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="no"&gt;VIEW&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'dashboard.view'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// Before&lt;/span&gt;
&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;index&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt; &lt;span class="kt"&gt;Response&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;authorize&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;DashboardPermission&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="no"&gt;VIEW&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="c1"&gt;// ...&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// After&lt;/span&gt;
&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;index&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt; &lt;span class="kt"&gt;Response&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;authorize&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;DashboardPermission&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="no"&gt;VIEW&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="c1"&gt;// ...&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This enhancement simplifies authorization code and improves type safety when working with permission enums.&lt;/p&gt;

&lt;h2&gt;
  
  
  Other Notable Improvements
&lt;/h2&gt;

&lt;p&gt;Laravel 11.30 also includes several other enhancements:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Added a &lt;code&gt;$bind&lt;/code&gt; parameter to &lt;code&gt;Blade::directive&lt;/code&gt; for improved blade directive functionality.&lt;/li&gt;
&lt;li&gt;Fixed &lt;code&gt;trans_choice()&lt;/code&gt; when translation replacements include the &lt;code&gt;|&lt;/code&gt; separator.&lt;/li&gt;
&lt;li&gt;Improved performance by using &lt;code&gt;exists()&lt;/code&gt; instead of &lt;code&gt;count()&lt;/code&gt; in certain operations.&lt;/li&gt;
&lt;li&gt;Added support for custom Postgres operators.&lt;/li&gt;
&lt;li&gt;Introduced optional dimensions for the &lt;code&gt;vector&lt;/code&gt; column type.&lt;/li&gt;
&lt;li&gt;Provided an error message for &lt;code&gt;PostTooLargeException&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Fixed an integrity constraint violation on &lt;code&gt;failed_jobs_uuid_unique&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Laravel 11.30 demonstrates the framework's commitment to continuous improvement and developer-friendly features. With enhanced testing capabilities, more flexible model ID options, and streamlined authorization using Enums, this release offers developers new tools to write cleaner, more efficient code. As Laravel continues to evolve, it remains a top choice for PHP developers seeking a robust and feature-rich web application framework.&lt;/p&gt;

&lt;p&gt;Interested on how I can help you elevate your business with Laravel? &lt;/p&gt;

&lt;p&gt;&lt;a href="https://soiposervices.com/contact-us" rel="noopener noreferrer"&gt;Get in touch with me.&lt;/a&gt;&lt;/p&gt;

</description>
      <category>laravel</category>
      <category>webdev</category>
      <category>releases</category>
      <category>php</category>
    </item>
    <item>
      <title>Enlightening article about diffusion models in machine learning! 🧠</title>
      <dc:creator>Luigi Laezza</dc:creator>
      <pubDate>Mon, 13 Jan 2025 14:48:23 +0000</pubDate>
      <link>https://dev.to/luigi_laezza_22b5ba44fdcd/enlightening-article-about-diffusion-models-in-machine-learning-4g6h</link>
      <guid>https://dev.to/luigi_laezza_22b5ba44fdcd/enlightening-article-about-diffusion-models-in-machine-learning-4g6h</guid>
      <description>&lt;p&gt;💻 The piece, courtesy of Polo Club’s Diffusion Explainer, simplifies these robust models in a captivating and understandable manner. 🔍📊&lt;/p&gt;

&lt;p&gt;Key highlights:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Explains the inner workings of diffusion models 🛠️&lt;/li&gt;
&lt;li&gt;Showcases their remarkable applications 🖼️🗣️&lt;/li&gt;
&lt;li&gt;Demonstrates their potential to transform AI 🔮&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Whether you're new to AI or an expert, this article provides valuable insights into the future of machine learning. 🌟&lt;/p&gt;

&lt;p&gt;What are your thoughts on diffusion models and how do you envision their impact on the future of AI? Share your perspectives in the comments! 💬👇&lt;/p&gt;

&lt;p&gt;Read more: &lt;a href="https://poloclub.github.io/diffusion-explainer/" rel="noopener noreferrer"&gt;https://poloclub.github.io/diffusion-explainer/&lt;/a&gt;&lt;/p&gt;

</description>
      <category>machinelearning</category>
      <category>diffusionmodels</category>
      <category>ai</category>
      <category>techinnovation</category>
    </item>
  </channel>
</rss>
