<?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: Anton Musatov</title>
    <description>The latest articles on DEV Community by Anton Musatov (@ayacaste).</description>
    <link>https://dev.to/ayacaste</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%2F1166822%2Fc6b5a968-3c08-40f1-8800-e27ea6dee514.jpeg</url>
      <title>DEV Community: Anton Musatov</title>
      <link>https://dev.to/ayacaste</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ayacaste"/>
    <language>en</language>
    <item>
      <title>My Job Search Experience in 2023</title>
      <dc:creator>Anton Musatov</dc:creator>
      <pubDate>Sun, 08 Oct 2023 18:48:37 +0000</pubDate>
      <link>https://dev.to/ayacaste/my-job-search-experience-in-2023-3g68</link>
      <guid>https://dev.to/ayacaste/my-job-search-experience-in-2023-3g68</guid>
      <description>&lt;p&gt;I started working at my current company just three months ago, and I'd like to share some insights and statistics from my job search in 2023.&lt;/p&gt;

&lt;h2&gt;
  
  
  About Me
&lt;/h2&gt;

&lt;p&gt;I am a seasoned Software Engineer with 13 years of experience and a Master's degree in Computer Science. For the past 11 years, I worked on a large, complex, high-load domestic B2B e-marketplace. I began my career there as a Junior Developer and gradually rose to the Principal Software Engineer of a developer department consisting of 19 individuals, including one frontend team and three backend teams.&lt;/p&gt;

&lt;h2&gt;
  
  
  Job Criteria
&lt;/h2&gt;

&lt;p&gt;Driven by a strong desire for continuous growth and development in my career, I believed that the most promising path for me was to enter the international market. Consequently, my primary criterion was to find an &lt;strong&gt;international company&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;I understood that the processes in an international company may be different from my experience, which is why I mostly applied for &lt;strong&gt;Senior Engineer positions&lt;/strong&gt;. This role would allow me to use my diverse set of technical and interpersonal skills immediately and also grow organically and efficiently within the company.&lt;/p&gt;

&lt;p&gt;Over the last four years, I've worked fully remotely and successfully set up my work processes to ensure optimal efficiency. I value this freedom, so a &lt;strong&gt;remote position&lt;/strong&gt; was my third essential criterion.&lt;/p&gt;

&lt;p&gt;Having worked in the B2B sector with large corporations, I've encountered extended adoption periods for new processes, resulting in slower feedback loops than I'd prefer. Hence, I sought &lt;strong&gt;dynamic product companies that create real impacts for their customers&lt;/strong&gt;. Ideally, I wanted a company whose product resonated with my interests.&lt;/p&gt;

&lt;p&gt;These were my fundamental criteria for the job search.&lt;/p&gt;

&lt;h2&gt;
  
  
  Duration
&lt;/h2&gt;

&lt;p&gt;I initiated my job search in &lt;strong&gt;January 2023&lt;/strong&gt; and accepted an offer in &lt;strong&gt;July 2023&lt;/strong&gt;. The entire process took &lt;strong&gt;6 months&lt;/strong&gt;, primarily conducted during weekends alongside my regular job.&lt;/p&gt;

&lt;h2&gt;
  
  
  Job Search Statistics
&lt;/h2&gt;

&lt;p&gt;During this period, I:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;applied for &lt;strong&gt;~200&lt;/strong&gt; job vacancies.&lt;/li&gt;
&lt;li&gt;received rejections from &lt;strong&gt;~48%&lt;/strong&gt; of the companies.&lt;/li&gt;
&lt;li&gt;did not receive responses from &lt;strong&gt;~46%&lt;/strong&gt; of the companies.&lt;/li&gt;
&lt;li&gt;participated in interviews with &lt;strong&gt;13&lt;/strong&gt; companies.&lt;/li&gt;
&lt;li&gt;received &lt;strong&gt;4&lt;/strong&gt; job offers.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Finally, I found a company and position that aligned perfectly with all my criteria, and I am still very happy about it.&lt;/p&gt;

&lt;p&gt;While my case is unique, I hope you find these statistics valuable in your own job search endeavors.&lt;/p&gt;

</description>
      <category>career</category>
      <category>motivation</category>
      <category>programming</category>
      <category>php</category>
    </item>
    <item>
      <title>Effective Team Practices</title>
      <dc:creator>Anton Musatov</dc:creator>
      <pubDate>Sat, 30 Sep 2023 17:14:40 +0000</pubDate>
      <link>https://dev.to/ayacaste/effective-team-practices-34eb</link>
      <guid>https://dev.to/ayacaste/effective-team-practices-34eb</guid>
      <description>&lt;p&gt;In the current article, I want to briefly describe team practices that I have used in my work.&lt;/p&gt;

&lt;h4&gt;
  
  
  Design Review Meetings
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Who:&lt;/strong&gt; Designer, one front-end product senior developer, one back-end product senior developer.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;When:&lt;/strong&gt; When we have just a draft of the task and design.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Why:&lt;/strong&gt; To identify potential problems as soon as possible that we could encounter during implementation.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Refinement Meetings
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Who:&lt;/strong&gt; Product managers, all product front-end developers, all product back-end developers, product QA.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;When:&lt;/strong&gt; When the design and description are ready for development; can be one meeting for several tasks.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Why:&lt;/strong&gt; To synchronize all tech team members about future tasks, receive feedback and basic evaluation, and share knowledge about the product.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Requesting Tasks Through Common Channel
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Who:&lt;/strong&gt; Developer.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;When:&lt;/strong&gt; When a developer needs a new task.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Why:&lt;/strong&gt; To maintain transparency regarding who is working on what task and to prevent task accumulation in developers' backlogs.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Task Planning Meetings
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Who:&lt;/strong&gt; Front-end developer, back-end developer.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;When:&lt;/strong&gt; After task assignment.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Why:&lt;/strong&gt; To synchronize particular developers about specific tasks and create a technical plan for the task.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Task Plan Approval
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Who:&lt;/strong&gt; Front-end developer, back-end developer.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;When:&lt;/strong&gt; Asynchronous, after task planning meetings.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Why:&lt;/strong&gt; For big, complex tasks, to align expectations before starting.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Short Daily Required Sync Meetings
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Who:&lt;/strong&gt; All product front-end developers, all product back-end developers.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;When:&lt;/strong&gt; Daily.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Why:&lt;/strong&gt; To synchronize the status of tasks; important to be short, focusing only on status and problems, with a maximum duration of 30 minutes.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Short Leads Required Sync Meetings
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Who:&lt;/strong&gt; Team leads from front-end, team leads from back-end.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;When:&lt;/strong&gt; Daily.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Why:&lt;/strong&gt; If there are a lot of people in commands, we can synchronize separately and then sync only at the leads' level.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Tech Retro
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Who:&lt;/strong&gt; Front-end developer/back-end developer.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;When:&lt;/strong&gt; On-demand.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Why:&lt;/strong&gt; To share knowledge about complex technical tasks/solutions.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Demo Retro
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Who:&lt;/strong&gt; Front-end developer/back-end developer (optional).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;When:&lt;/strong&gt; After each middle/big size feature.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Why:&lt;/strong&gt; To share knowledge.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Socialization Meeting
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Who:&lt;/strong&gt; Front-end developer/back-end developer (optional).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;When:&lt;/strong&gt; Weekly, maximum 1 hour.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Why:&lt;/strong&gt; Just for socialization, to discuss work or personal matters.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Research Day
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Who:&lt;/strong&gt; Front-end developer/back-end developer (optional).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;When:&lt;/strong&gt; Monthly.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Why:&lt;/strong&gt; To maintain expertise and provide suitable solutions for complex tasks.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  One-on-One Meetings
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Who:&lt;/strong&gt; Developer, team lead.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;When:&lt;/strong&gt; Monthly.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Why:&lt;/strong&gt; To provide feedback and address problems and achievements.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I have provided a brief description, and not all practices may apply in every company and project structure. However, I believe they can be useful to know about.&lt;/p&gt;

</description>
      <category>programming</category>
      <category>agile</category>
      <category>productivity</category>
      <category>management</category>
    </item>
    <item>
      <title>Different Ways to Use Laravel Actions</title>
      <dc:creator>Anton Musatov</dc:creator>
      <pubDate>Sat, 23 Sep 2023 12:12:49 +0000</pubDate>
      <link>https://dev.to/ayacaste/different-ways-to-use-laravel-actions-138k</link>
      <guid>https://dev.to/ayacaste/different-ways-to-use-laravel-actions-138k</guid>
      <description>&lt;p&gt;You can find more information about Laravel actions &lt;a href="https://laravel-beyond-crud.com" rel="noopener noreferrer"&gt;here&lt;/a&gt; and &lt;a href="https://stitcher.io/blog/laravel-beyond-crud-03-actions" rel="noopener noreferrer"&gt;here&lt;/a&gt;. In this article, I aim to demonstrate two different approaches to using these actions, along with their respective pros and cons.&lt;/p&gt;

&lt;p&gt;Let's consider a scenario where we have an &lt;code&gt;Order&lt;/code&gt; model and a related &lt;code&gt;OrderLine&lt;/code&gt; model, and we need to add an API endpoint to create an order.&lt;/p&gt;

&lt;p&gt;The first classic approach may look like this:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;OrderPolicy&lt;/code&gt; class with a create method where we perform security checks.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="k"&gt;final&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;OrderPolicy&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;HandlesAuthorization&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;store&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;User&lt;/span&gt; &lt;span class="nv"&gt;$user&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;OrderStoreRequest&lt;/span&gt; &lt;span class="nv"&gt;$request&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="c1"&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;ul&gt;
&lt;li&gt;
&lt;code&gt;OrderStoreRequest&lt;/code&gt; class, responsible for invoking the policy and containing validation rules for input data.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="k"&gt;final&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;OrderStoreRequest&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nc"&gt;FormRequest&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;authorize&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="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;user&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;can&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'store'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
            &lt;span class="nc"&gt;Order&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;class&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="nv"&gt;$this&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;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;rules&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt; &lt;span class="kt"&gt;array&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="c1"&gt;//...&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;ul&gt;
&lt;li&gt;
&lt;code&gt;CreateOrderAction&lt;/code&gt; class, where we save the &lt;code&gt;Order&lt;/code&gt; and &lt;code&gt;OrderLine&lt;/code&gt; models in a single transaction.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="k"&gt;final&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;CreateOrderAction&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;__invoke&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;CreateOrderData&lt;/span&gt; &lt;span class="nv"&gt;$createOrderData&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="no"&gt;DB&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;transaction&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="k"&gt;use&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$createOrderData&lt;/span&gt;&lt;span class="p"&gt;)&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="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;OrderController&lt;/code&gt; with a store method that combines all the previous classes.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="k"&gt;final&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;OrderController&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nc"&gt;Controller&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;store&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;OrderStoreRequest&lt;/span&gt; &lt;span class="nv"&gt;$request&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;CreateOrderAction&lt;/span&gt; &lt;span class="nv"&gt;$createOrder&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;$orderId&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$createOrder&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;CreateOrderData&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;fromRequest&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$request&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;

        &lt;span class="k"&gt;return&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;response&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;created&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;content&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="nv"&gt;$orderId&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 approach follows the traditional Laravel methodology and offers its own set of advantages:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You can refer to the Laravel documentation for detailed information.&lt;/li&gt;
&lt;li&gt;Most Laravel developers are familiar with this approach.&lt;/li&gt;
&lt;li&gt;Framework tools facilitate concise and readable code.&lt;/li&gt;
&lt;li&gt;Actions can be reused in other parts of the application.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;However, if you find the need to reuse not only data mutation and saving within a transaction but also security and validation checks, you might encounter some challenges.&lt;/p&gt;

&lt;p&gt;Now, let's explore an alternative approach that may look like this:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;CreateOrderSecurityAction&lt;/code&gt; class, containing all necessary security checks.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="k"&gt;final&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;CreateOrderSecurityAction&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;__invoke&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="nv"&gt;$userId&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;CreateOrderData&lt;/span&gt; &lt;span class="nv"&gt;$createOrderData&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="c1"&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;ul&gt;
&lt;li&gt;
&lt;code&gt;CreateOrderValidationAction&lt;/code&gt; class, responsible for data validation.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="k"&gt;final&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;CreateOrderValidationAction&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;__invoke&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;CreateOrderData&lt;/span&gt; &lt;span class="nv"&gt;$createOrderData&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="kt"&gt;array&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nv"&gt;$errors&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[];&lt;/span&gt;

        &lt;span class="c1"&gt;//...&lt;/span&gt;

        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nv"&gt;$errors&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;ul&gt;
&lt;li&gt;
&lt;code&gt;CreateOrderAction&lt;/code&gt; class, which combines the previous two classes and saves the &lt;code&gt;Order&lt;/code&gt; and &lt;code&gt;OrderLine&lt;/code&gt; models in a single transaction.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="k"&gt;final&lt;/span&gt; &lt;span class="k"&gt;readonly&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;CreateOrderAction&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;__construct&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="kt"&gt;CreateOrderSecurityAction&lt;/span&gt; &lt;span class="nv"&gt;$createOrderSecurity&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="kt"&gt;CreateOrderValidationAction&lt;/span&gt; &lt;span class="nv"&gt;$createOrderValidation&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;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="cd"&gt;/**
     * @throws OrderSecurityException
     * @throws OrderValidationException
     */&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;__invoke&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="nv"&gt;$userId&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;CreateOrderData&lt;/span&gt; &lt;span class="nv"&gt;$createOrderData&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&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="n"&gt;createOrderSecurity&lt;/span&gt;&lt;span class="p"&gt;)(&lt;/span&gt;&lt;span class="nv"&gt;$userId&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$createOrderData&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;OrderSecurityException&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;

        &lt;span class="nv"&gt;$validationErrors&lt;/span&gt; &lt;span class="o"&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="n"&gt;createOrderValidation&lt;/span&gt;&lt;span class="p"&gt;)(&lt;/span&gt;&lt;span class="nv"&gt;$createOrderData&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt; &lt;span class="k"&gt;empty&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$validationErrors&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;OrderValidationException&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$validationErrors&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="no"&gt;DB&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;transaction&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="k"&gt;use&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$createOrderData&lt;/span&gt;&lt;span class="p"&gt;)&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="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;OrderController&lt;/code&gt;, where we simply call the &lt;code&gt;CreateOrderAction&lt;/code&gt;.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="k"&gt;final&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;OrderController&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nc"&gt;ApiController&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;store&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;Request&lt;/span&gt; &lt;span class="nv"&gt;$request&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;CreateOrderAction&lt;/span&gt; &lt;span class="nv"&gt;$createOrder&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="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="nv"&gt;$orderId&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$createOrder&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;auth&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;id&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="nv"&gt;$CreateOrderData&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;fromRequest&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$request&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;catch&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;OrderSecurityException&lt;/span&gt;&lt;span class="p"&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;response&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;errorForbidden&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;catch&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;OrderValidationException&lt;/span&gt; &lt;span class="nv"&gt;$exception&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="nf"&gt;response&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="s1"&gt;'errors'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nv"&gt;$exception&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;getErrors&lt;/span&gt;&lt;span class="p"&gt;()],&lt;/span&gt; &lt;span class="mi"&gt;400&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="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;response&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;created&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;content&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="nv"&gt;$orderId&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;The primary advantage of this approach is the ability to reuse actions in conjunction with all business requirements (security, validation, enforcing entity invariants). However, in this case, it may not be as straightforward to leverage the full power of the Laravel framework to streamline your code writing process.&lt;/p&gt;

&lt;p&gt;Both approaches are valid choices, depending on the project's specific needs. If you don't require the reuse of entire business actions across multiple parts of your project, the classic Laravel approach is a straightforward choice. However, for larger and more complex projects, where you need to call the same entire business action, the second approach may be more suitable.&lt;/p&gt;

&lt;p&gt;Regardless of your choice, having knowledge of both methods is valuable to make informed decisions.&lt;/p&gt;

</description>
      <category>laravel</category>
      <category>php</category>
      <category>ddd</category>
    </item>
  </channel>
</rss>
