<?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: AbdlrahmanSaber</title>
    <description>The latest articles on DEV Community by AbdlrahmanSaber (@abdlrahmansaberabdo).</description>
    <link>https://dev.to/abdlrahmansaberabdo</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%2F717307%2F1b739a07-f166-4358-ac35-5ce27235dd92.jpeg</url>
      <title>DEV Community: AbdlrahmanSaber</title>
      <link>https://dev.to/abdlrahmansaberabdo</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/abdlrahmansaberabdo"/>
    <language>en</language>
    <item>
      <title>Convert enum to string literal union type in TS</title>
      <dc:creator>AbdlrahmanSaber</dc:creator>
      <pubDate>Sat, 29 Oct 2022 14:40:44 +0000</pubDate>
      <link>https://dev.to/abdlrahmansaberabdo/convert-enum-to-string-literal-union-type-from-enum-in-ts-4ne6</link>
      <guid>https://dev.to/abdlrahmansaberabdo/convert-enum-to-string-literal-union-type-from-enum-in-ts-4ne6</guid>
      <description>&lt;p&gt;Hello everyone, this is a quick tutorial, In my work, I wanted to avoid duplicating code as I can and abstract things for example if I use an &lt;strong&gt;enum&lt;/strong&gt; named Weekdays and it contains the following data:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;enum Weekdays = {
    MONDAY = 'mon',
    TUESDAY = 'tue',
    WEDNESDAY = 'wed'
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let's say you want to create a type called WeekdayType which should contain 'mon' | 'Tue' | 'Wed', how we can do this? Starting from version 4.1 you can do a tricky thing to do it in a single line of code, let's see it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;type WeekdayType = `${Weekdays}`;
// WeekdayType = 'mon' | 'Tue' | 'Wed'|
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Congratulations, you did it! Awesome, right?&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Take me back, please!</title>
      <dc:creator>AbdlrahmanSaber</dc:creator>
      <pubDate>Sun, 24 Apr 2022 16:28:46 +0000</pubDate>
      <link>https://dev.to/abdlrahmansaberabdo/take-me-back-please-2lb2</link>
      <guid>https://dev.to/abdlrahmansaberabdo/take-me-back-please-2lb2</guid>
      <description>&lt;p&gt;Not your best day. You made changes you shouldn’t have and now everything is broken… Is there a way to undo those commits?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Git keeps track of updates to the tip of branches using a mechanism called reference&lt;/strong&gt; &lt;code&gt;logs&lt;/code&gt;, or&lt;code&gt;reflogs&lt;/code&gt;Many Git commands accept a parameter for specifying a reference or “ref”, which is a pointer to a commit. Common examples include &lt;code&gt;git checkout&lt;/code&gt;or &lt;code&gt;git reset&lt;/code&gt;.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git reflog
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;you can get the record of all the commits done in Git.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--HOc4is9y--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pbxx2y41mj7gdtr2l4yd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--HOc4is9y--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pbxx2y41mj7gdtr2l4yd.png" alt="Image description" width="880" height="746"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now you just need to find the commit prior to the one that caused all the hassle. &lt;code&gt;HEAD@{index}&lt;/code&gt; represents the specified commit, so just replace the index with the correct number and run:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git reset HEAD@{index}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;The default action for git reset is &lt;code&gt;git reset --mixed&lt;/code&gt;. It means that the changes in your working directory will be preserved but not staged (since the index was modified to match the chosen commit, the changes are not in the index anymore).&lt;/p&gt;

&lt;p&gt;Other options are:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Doesn’t modify the index or the working tree, leaving your changes staged for commit.
git reset --soft

# Use with caution, as it resets both the index and working tree. Uncommitted changes and all commits after will be removed.

git reset --hard

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And now, you can start over from the point when everything in your repository worked like a charm. Remember to use it only locally, as modifying a shared repository is considered a serious crime.&lt;/p&gt;

&lt;p&gt;If you found this post useful please share it with your friends 😍&lt;/p&gt;

&lt;p&gt;Let’s connect on &lt;a href="https://www.linkedin.com/in/abdlrahmansaber/"&gt;LinkedIn&lt;/a&gt;, &lt;a href="https://twitter.com/Abdlrahmansabe4"&gt;Twitter&lt;/a&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>github</category>
      <category>git</category>
      <category>programming</category>
    </item>
    <item>
      <title>How view branches sorted by date in specific format and order</title>
      <dc:creator>AbdlrahmanSaber</dc:creator>
      <pubDate>Thu, 21 Apr 2022 03:13:20 +0000</pubDate>
      <link>https://dev.to/abdlrahmansaberabdo/how-view-branches-sorted-by-date-in-specific-format-and-order-34g7</link>
      <guid>https://dev.to/abdlrahmansaberabdo/how-view-branches-sorted-by-date-in-specific-format-and-order-34g7</guid>
      <description>&lt;p&gt;&lt;strong&gt;This a short tutorial from a git tricks series&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Let's know how we can list all branches sorted by date.&lt;/p&gt;

&lt;h3&gt;
  
  
  View branch sorted by date
&lt;/h3&gt;

&lt;p&gt;display a list of all local branches and sort them based on the date of their last commit.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# sort desc (-committerdate)
git branch --sort=-committerdate

# sort asc (committerdate)
git branch --sort=-committerdate
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;If you’d like to make a custom format you can use &lt;code&gt;for-each-ref&lt;/code&gt; with &lt;code&gt;--sort&lt;/code&gt; option and &lt;code&gt;--format&lt;/code&gt; option to write your format.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git for-each-ref --sort='-committerdate' --format='%(refname)%09%(committerdate)' refs/heads
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;In the above command, I print the refname first then commitdate in --format option the output will be like this&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;refs/heads/branch_name commitdate
refs/heads/branch_name2 commitdate

# real output
refs/heads/new_design   Wed Apr 20 12:24:21 2022 +0200

refs/heads/design_assets        Wed Apr 20 11:30:30 2022 +0200
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;If you want to print the &lt;code&gt;date&lt;/code&gt; first then &lt;code&gt;refname&lt;/code&gt;, the option format will be like this &lt;code&gt;--format='%(committerdate)%09%(refname)%'&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Let’s say you don’t want to print refs/heads and want print just the &lt;strong&gt;branch&lt;/strong&gt; name each time, how we can do this? by using &lt;code&gt;sed&lt;/code&gt;.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git for-each-ref --sort='-committerdate' --format='%(refname)%09%(committerdate)' refs/heads | sed 's-refs/heads/--'

#output
branch_name commitdate
branch_name2 commitdate

#real output
new_design      Wed Apr 20 12:24:21 2022 +0200

design_assets   Wed Apr 20 11:30:30 2022 +0200
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;I find these commands incredibly helpful when returning to work from a weekend or just jumping from project to project. Hopefully, you can use these commands too!&lt;/p&gt;

&lt;p&gt;If you found this post useful please share it with your friends 😍&lt;/p&gt;

&lt;p&gt;Let’s connect on &lt;a href="https://www.linkedin.com/in/abdlrahmansaber/"&gt;LinkedIn&lt;/a&gt;, &lt;a href="https://twitter.com/Abdlrahmansabe4"&gt;Twitter&lt;/a&gt;&lt;/p&gt;

</description>
      <category>git</category>
      <category>github</category>
      <category>webdev</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Is it possible to create a commit with a different date?</title>
      <dc:creator>AbdlrahmanSaber</dc:creator>
      <pubDate>Wed, 20 Apr 2022 04:02:32 +0000</pubDate>
      <link>https://dev.to/abdlrahmansaberabdo/is-it-possible-to-create-a-commit-with-a-different-date-c32</link>
      <guid>https://dev.to/abdlrahmansaberabdo/is-it-possible-to-create-a-commit-with-a-different-date-c32</guid>
      <description>&lt;p&gt;&lt;strong&gt;This a first short tutorial from a Git Tricks series&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Sometimes, you might run into a situation where you need to create a commit with a different date than the current one. Luckily, you can handle this using following timestamp in git&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;GIT_AUTHOR_DATE&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;GIT_COMMITTER_DATE&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;you might be now you're wondering what's actually the difference between &lt;code&gt;Author&lt;/code&gt; and &lt;code&gt;Committer&lt;/code&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Let's Understanding dates in Git: author date vs. committer date &amp;amp; ‘approxidate
&lt;/h4&gt;

&lt;p&gt; &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The author is the person who originally wrote the work, whereas the committer is the person who last applied the work.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;So if, for instance, you send in a patch to a project, the author date will be when you made the original commit but the committer date will be when the patch was applied. Another common scenario is rebasing: rebasing will alter the commit date, but not the author date.&lt;/p&gt;

&lt;h4&gt;
  
  
  The Command
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
GIT_AUTHOR_DATE='Mon May 18 19:32:11 2022 -0400' \
  GIT_COMMITTER_DATE='Mon May 18 19:32:11 2022 -0400'\
  git commit -m 'Commit from the past'

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As shown in the example above, you can set both values to any date you like and your code will be committed on that date.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;&lt;br&gt;
you can also use other formats&lt;/p&gt;

&lt;h4&gt;
  
  
  Date formats
&lt;/h4&gt;

&lt;p&gt;RFC &lt;code&gt;2822 Mon, 18 May 2022 19:32:11 -0400&lt;/code&gt;&lt;br&gt;
ISO &lt;code&gt;8601 2022-05-18 19:32:11 -0400&lt;/code&gt;&lt;br&gt;
local &lt;code&gt;Mon May 18 19:32:11 2022&lt;/code&gt;&lt;br&gt;
short &lt;code&gt;2022-05-18&lt;/code&gt;&lt;br&gt;
relative &lt;code&gt;5.seconds.ago&lt;/code&gt;, &lt;code&gt;2.years.3.months.ago&lt;/code&gt;, &lt;code&gt;6am yesterday&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Let’s connect on &lt;a href="https://www.linkedin.com/in/abdlrahmansaber/"&gt;LinkedIn&lt;/a&gt;, &lt;a href="https://twitter.com/Abdlrahmansabe4"&gt;Twitter&lt;/a&gt;&lt;/p&gt;

</description>
      <category>git</category>
      <category>webdev</category>
      <category>tutorial</category>
      <category>github</category>
    </item>
    <item>
      <title>How organize big projects in Laravel?</title>
      <dc:creator>AbdlrahmanSaber</dc:creator>
      <pubDate>Tue, 19 Apr 2022 08:20:41 +0000</pubDate>
      <link>https://dev.to/abdlrahmansaberabdo/how-organize-big-projects-in-laravel-5394</link>
      <guid>https://dev.to/abdlrahmansaberabdo/how-organize-big-projects-in-laravel-5394</guid>
      <description>&lt;h2&gt;
  
  
  Agenda
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Introduction&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;What’s HMVC?&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Advantages of using HMVC?&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;What’s wrong with the MVC pattern?&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Let’s know how we can use the HMVC pattern in Laravel!&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Pros&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Cons&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Best Packages that generate modules and implement that approach&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Conclusion&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt; &lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Introduction&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Everyone when beginning a new project starts to ask himself/herself the following question?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;How can I make organized the project well to be easy for me or for any other developer easy to understand for example if you’re looking for a file in a big project, you want to be easy to find that file, right?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We have many approaches and design patterns that make the project clean but in this article, I will talk about &lt;strong&gt;HMVC&lt;/strong&gt; (the Hierarchical-model-view-controller) pattern which makes your application modular.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;What’s HMVC?&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;The &lt;strong&gt;HMVC&lt;/strong&gt; pattern extends the &lt;strong&gt;MVC&lt;/strong&gt; pattern and is a solution to overcome scalability problems apparent within large MVC applications.&lt;/p&gt;

&lt;p&gt;An &lt;strong&gt;HMVC&lt;/strong&gt; application operates using a collection of MVC entities where each MVC entity can execute without the presence of any other. Ideally, each entity should never load models or libraries of other entities.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Advantages of using HMVC?&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;HMVC supports the reuse of code&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;HMVC allows easy distribution of MVC entities stored in a single directory.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;HMVC reduces dependencies and allows to easily extend applications while retaining ease of maintenance.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Testing is easier because the system is divided to a large extend into independent parts.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt; &lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;What’s wrong with the MVC pattern?&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;The Model-View-Controller (MVC) paradigm remains one of the more enduring patterns. However, the traditional MVC scope falls short when it comes to the control of GUI elements (widgets). MVC does not handle the complexities of data management, event management, and application flows.&lt;/p&gt;

&lt;p&gt;HMVC provides a powerful yet easy-to-understand layered design methodology for developing a complete presentation layer.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Let’s know how we can use the HMVC pattern in Laravel!&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Let’s assume we have an accounting project that has (Banking — Sale— Transaction), the question now is how we can organize the project using HMVC! let’s divide these three parts into MVC components so you can have each of them separately developed but used as one!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example from a real accounting project&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--gWIsuiBH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2000/1%2ARwt1xel_eY15l-qwdsvOYw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--gWIsuiBH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2000/1%2ARwt1xel_eY15l-qwdsvOYw.png" alt="laravel project example" width="540" height="859"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Each module has its own (routes - middleware - controllers- etc..), and it’s help you to make your project more organized.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Pros&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Modularization: reduction of dependencies between the disparate parts of the application.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;More organized: having a folder for each of the relevant triads makes for a lighter workload.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Reusability: by the nature of the design it is easy to reuse nearly every piece of code.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Extendibility: this makes the application more extensible without sacrificing ease of maintenance.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt; &lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Cons&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Create More Folders But the solution of it in my opinion that we will remove unused folders.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Best Packages that generate modules and implement that approach&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;we have many packages with Laravel that generate modules but I will share in this article my own package (Laragine) and other packages that I used in many projects.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Laravel Modules&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Is a Laravel package that was created to manage your large Laravel app using modules.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;This package just structures your project (Modules) and doesn’t provide any implementation.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Laragine&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;is a Laravel package that was created to manage your large Laravel app using modules also but here’s a difference, this package implements all API CRUD operations with unit tests, the package generates (Controller — Model — Factories — Migrations — unit tests — etc..), all you need to do to just add your API route in your route folder and everything (APIs CRUD operations) will work magically sounds interesting, right!&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;check this &lt;a href="https://www.youtube.com/watch?v=5klckaSiM6g"&gt;video &lt;/a&gt;to know more.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;I wrote a series of blogs about it you can check it from here &lt;a href="https://dev.to/abdlrahmansaberabdo/series/14891"&gt;https://dev.to/abdlrahmansaberabdo/series/14891&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Check the &lt;a href="https://yepwoo.com/products/laragine/docs/v2/introduction"&gt;documentation&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt; &lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Conclusion&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Basically, the HMVC pattern is just an extension of MVC. An HMVC application includes one or more MVC sub-applications. so anything MVC can do, HMVC can do too. Now, it depends on whether you need the flexibility and scalability that HMVC offers.&lt;/p&gt;

&lt;p&gt;Let’s connect on &lt;a href="https://www.linkedin.com/in/abdlrahmansaber/"&gt;LinkedIn&lt;/a&gt;, &lt;a href="https://twitter.com/Abdlrahmansabe4"&gt;Twitter&lt;/a&gt;&lt;/p&gt;

</description>
      <category>laravel</category>
      <category>webdev</category>
      <category>php</category>
      <category>microservices</category>
    </item>
    <item>
      <title>Do we have pointers in python like other programming !</title>
      <dc:creator>AbdlrahmanSaber</dc:creator>
      <pubDate>Wed, 16 Feb 2022 09:21:22 +0000</pubDate>
      <link>https://dev.to/abdlrahmansaberabdo/how-to-use-pointers-in-python-5ahp</link>
      <guid>https://dev.to/abdlrahmansaberabdo/how-to-use-pointers-in-python-5ahp</guid>
      <description>&lt;p&gt;Pointer is important to understand for the way you’re going to create data structures.&lt;/p&gt;

&lt;p&gt;I’m going to start with something that is not a pointer and then compare it to something that does use a pointer.&lt;/p&gt;

&lt;p&gt;Let’s say that we have two &lt;strong&gt;variable&lt;/strong&gt;  &lt;code&gt;num1, num2&lt;/code&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;num1 = 11, 
num2 = num1

print("Before: ")
print(num1) #11
print(num2) #11

# then let's change num1

num1 = 22

print("\nAfter\n")
print("num1 =", num1) #22
print("num2 =", num2) #11 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;If you realized &lt;code&gt;num2&lt;/code&gt; is still the same 11, you’re wondering now why &lt;code&gt;num2&lt;/code&gt; still equals the same number, is it should update to 22 because we update num1!&lt;/p&gt;

&lt;p&gt;So when you set &lt;code&gt;num1 = num2&lt;/code&gt;, these are not linked forever, you are just initializing, and that is what happens when you’re working with something that is not using a pointer.&lt;/p&gt;

&lt;p&gt;Now, let’s compare this to something that does use a pointer.&lt;/p&gt;

&lt;p&gt;We’re going to use a dictionary in python, when you have something set equal to a dictionary, it’s a &lt;strong&gt;pointer&lt;/strong&gt; to the dictionary.&lt;br&gt;
Let’s use the same example and see.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;dict1 = {
    'value': 11
}

dict2 = dict1

print("Before: ")

print("num1= ", dict1) # {value: 11}
print("num2= ", dict2) # {value: 11}

dict1['value'] = 22

print("\nAfter\n")

print("num1= ", dict1) # {value: 22}
print("num2= ", dict2) # {value: 22}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;so when you set &lt;code&gt;dict2 = dict1&lt;/code&gt; , you are literally saying &lt;code&gt;dict2&lt;/code&gt; points to the exact same dictionary in memory as &lt;code&gt;dict1&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;There are a &lt;strong&gt;couple of other concepts&lt;/strong&gt; I want to show here.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The first concept is&lt;/strong&gt;, let’s just say we have another dictionary called dict3&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;dict3 = {'value': 57}

dict2 = dict3

print (dict2) # {value: 57}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;The pointer can be redirected like this also, and this idea of having a pointer point to a new place is a concept that you’ll use in a data structure.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The second concept is&lt;/strong&gt;, let’s say now we set &lt;code&gt;dict1 = dict2&lt;/code&gt; now all variables &lt;code&gt;(dict1 — dict2 — dict3)&lt;/code&gt;&lt;br&gt;
are pointing to &lt;code&gt;{'value':57}&lt;/code&gt; so you might ask now, what happens to that dictionary &lt;code&gt;{'value': 22}&lt;/code&gt; which is the old value for &lt;code&gt;dict1&lt;/code&gt; before pointing to &lt;code&gt;dict3&lt;/code&gt;. is not a way to get that pointer again &lt;code&gt;{'value': 22}&lt;/code&gt;? yes no way to get this pointer again, now we should ask &lt;strong&gt;what python does to free this memory up?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Good question, python will run a process called &lt;strong&gt;garbage collection&lt;/strong&gt; to remove this.&lt;/p&gt;

&lt;p&gt;If you like the post leave a comment and tell me if you’d like to make a series of posts about data structure and how we can use pointers in it.&lt;/p&gt;

&lt;p&gt;Let’s connect on &lt;a href="https://www.linkedin.com/in/abdlrahmansaber/"&gt;LinkedIn&lt;/a&gt;&lt;/p&gt;

</description>
      <category>python</category>
      <category>programming</category>
      <category>tutorial</category>
      <category>codenewbie</category>
    </item>
    <item>
      <title>Understand how the views work in Laragine (a package in laravel)</title>
      <dc:creator>AbdlrahmanSaber</dc:creator>
      <pubDate>Wed, 06 Oct 2021 22:29:36 +0000</pubDate>
      <link>https://dev.to/abdlrahmansaberabdo/understand-how-the-views-work-in-laragine-package-in-laravel-4ke</link>
      <guid>https://dev.to/abdlrahmansaberabdo/understand-how-the-views-work-in-laragine-package-in-laravel-4ke</guid>
      <description>&lt;p&gt;In the previous tutorials we created a fully CRUD &lt;code&gt;API&lt;/code&gt; with unit tests, in this tutorial we'll understand how to work with views in &lt;code&gt;Laragine&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;When we installed Laragine in the previous tutorial, it's created under the &lt;code&gt;core&lt;/code&gt; folder as we know, and also it has created a folder called the &lt;code&gt;Base&lt;/code&gt;, we can't discuss everything in the &lt;code&gt;Base&lt;/code&gt; folder in this tutorial, but I'll explain it separately.&lt;/p&gt;

&lt;p&gt;under &lt;code&gt;Base&lt;/code&gt; folder there are two folders called &lt;code&gt;views - unit_template&lt;/code&gt;.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;In the &lt;strong&gt;views&lt;/strong&gt; folder there's a folder called &lt;code&gt;layout&lt;/code&gt;, in &lt;code&gt;layout&lt;/code&gt; folder you should create the base views for your website like &lt;code&gt;navbar sidebar - buttons - etc..&lt;/code&gt;
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Ws5sojGp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/34wb57ou8e3zg2t2os96.png" alt="image"&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  What's &lt;code&gt;unit_template&lt;/code&gt; for, in &lt;code&gt;core\Base&lt;/code&gt;?
&lt;/h3&gt;

&lt;p&gt;let's assume that you'll create a &lt;code&gt;blog&lt;/code&gt;, the &lt;code&gt;blog&lt;/code&gt; has units like &lt;code&gt;post - comment - like&lt;/code&gt;, each &lt;code&gt;unit&lt;/code&gt; will have &lt;code&gt;get - store - update - delete&lt;/code&gt; methods, right?&lt;/p&gt;

&lt;p&gt;So each unit will have a form for creating - update and a page for showing all units - specific unit, so in each unit, you'll create these files and implement it, instead of creating the views each time in the unit you can put the default views that will be in each unit like &lt;code&gt;form - table - show&lt;/code&gt; page and when create a unit you'll just add the non-common other stuff like &lt;code&gt;attributes - titles - etc..&lt;/code&gt; in the &lt;code&gt;form - table - show page - etc..&lt;/code&gt; and make minor changes depends on your project and your way.&lt;/p&gt;

&lt;p&gt;let's go to the &lt;code&gt;unit_template&lt;/code&gt; folder in &lt;code&gt;core\Base&lt;/code&gt; you'll see five files &lt;code&gt;_form - create - edit - index - show&lt;/code&gt; you can remove the current &lt;code&gt;code&lt;/code&gt; &lt;strong&gt;it's just an example&lt;/strong&gt; and put your own &lt;code&gt;code&lt;/code&gt; inside it and make a style for it. you might be thinking now how can I use these files!&lt;/p&gt;

&lt;h2&gt;
  
  
  Note
&lt;/h2&gt;

&lt;p&gt;Please take a look at the blade files inside &lt;code&gt;core/Base/views&lt;/code&gt; and &lt;code&gt;core/Base/unit_template&lt;/code&gt; you will notice that &lt;code&gt;$global&lt;/code&gt; variable is shared across all the views, the &lt;code&gt;$global&lt;/code&gt; variable will help you to load &lt;code&gt;views - route&lt;/code&gt; dynamically.&lt;br&gt;
&lt;strong&gt;I'll make seperated tutorial about the &lt;code&gt;$global&lt;/code&gt; variable&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I'll edit the &lt;code&gt;_form&lt;/code&gt; file as an example in &lt;code&gt;core/Base/unit_template&lt;/code&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--p2t1zEXC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x3n3ejkuo04ylb0j98p7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--p2t1zEXC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x3n3ejkuo04ylb0j98p7.png" alt="image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Let's create a new unit called &lt;code&gt;comment&lt;/code&gt; under &lt;code&gt;blog&lt;/code&gt; module&lt;br&gt;
&lt;strong&gt;Blog module that we created in the previous tutorial&lt;/strong&gt; &lt;br&gt;
&lt;code&gt;php artisan laragine:unit comment --module=blog --init&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;now I'll not discuss what we should do with &lt;code&gt;JSON&lt;/code&gt; file if you don't know please see previous &lt;strong&gt;tutorial number (1)&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Let's run the second part of &lt;code&gt;unit command&lt;/code&gt;&lt;br&gt;
&lt;code&gt;php artisan laragine:unit comment --module=blog&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;let's go to &lt;code&gt;core\Blog\views\comment&lt;/code&gt;&lt;br&gt;
if you remember I have just updated the &lt;code&gt;_form&lt;/code&gt; file in &lt;code&gt;core/Base/unit_template&lt;/code&gt; let's see it in the &lt;code&gt;views&lt;/code&gt; in &lt;code&gt;comment&lt;/code&gt; unit&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--J4ZnvZrA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tgq0rhg8bx2r2fuc84g1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--J4ZnvZrA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tgq0rhg8bx2r2fuc84g1.png" alt="image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;it's the same code that I put in the &lt;code&gt;_form&lt;/code&gt; file in the &lt;code&gt;core/Base/unit_template&lt;/code&gt; folder, right? so we can conclude that each unit will copy the code under the &lt;code&gt;core\Base\unit_template&lt;/code&gt; folder.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What're the benefits?&lt;/strong&gt;&lt;br&gt;
You might be wondering now what're the benefits of doing this, you don't need to write the same code each time in &lt;code&gt;default files&lt;/code&gt; in each &lt;code&gt;unit&lt;/code&gt; like &lt;code&gt;forms - tables - shows&lt;/code&gt; page, you will just put your &lt;code&gt;template&lt;/code&gt; with all &lt;code&gt;style&lt;/code&gt; then the views will be created automatically for you, then you'll just write other stuff like &lt;code&gt;attributes - titles - etc..&lt;/code&gt; inside them.&lt;/p&gt;

&lt;p&gt;*I mean by saying &lt;code&gt;attributes&lt;/code&gt; the name of &lt;code&gt;attributes&lt;/code&gt; in your table let's say when creating a &lt;code&gt;_form&lt;/code&gt; view, you'll need to create new &lt;code&gt;inputs&lt;/code&gt; for each &lt;code&gt;attribute&lt;/code&gt; like &lt;code&gt;title - body - etc..&lt;/code&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Now let's put a route for views
&lt;/h1&gt;

&lt;p&gt;go to &lt;code&gt;core\Blog\routes\web.php&lt;/code&gt; and add &lt;code&gt;Route::resource('comments', 'CommentController')-&amp;gt;except([&lt;br&gt;
   'store', 'update', 'destroy'&lt;br&gt;
]);&lt;br&gt;
&lt;/code&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--4QHY0SPc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8zm99dqs3zwkngy5ukir.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--4QHY0SPc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8zm99dqs3zwkngy5ukir.png" alt="image"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;h1&gt;
  
  
  Testing
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;now let's test the view, you can run &lt;code&gt;php artisan serve&lt;/code&gt; to create &lt;code&gt;http-server&lt;/code&gt; for your project &lt;code&gt;HTTP-server will listen to port 8000&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;let's go to &lt;code&gt;http://localhost:8000/admin/comments&lt;/code&gt;&lt;strong&gt;main domain - route&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--t2n1I0b9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/suzrze6ab7l6kmd5gwfj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--t2n1I0b9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/suzrze6ab7l6kmd5gwfj.png" alt="image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The style is not our main goal in this &lt;code&gt;tutorial&lt;/code&gt; I just want to teach you how to work with &lt;code&gt;views&lt;/code&gt; in &lt;code&gt;Laragine&lt;/code&gt;, you can navigate to any route you want for &lt;code&gt;comments&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;let's go to &lt;code&gt;http://localhost:8000/admin/comments/create&lt;/code&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--aPa5cvWG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4atwiz7alqeip8nkla1m.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--aPa5cvWG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4atwiz7alqeip8nkla1m.png" alt="image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you realized my template appears as I edited in the &lt;code&gt;_form&lt;/code&gt; file which is just &lt;strong&gt;My Form&lt;/strong&gt; text.  &lt;/p&gt;

&lt;p&gt;That's all the basic usage of &lt;code&gt;Views&lt;/code&gt; in &lt;code&gt;Laragine&lt;/code&gt;,&lt;br&gt;
have fun experimenting in &lt;code&gt;Laragine&lt;/code&gt;&lt;/p&gt;

</description>
      <category>laravel</category>
      <category>blade</category>
      <category>php</category>
      <category>webdev</category>
    </item>
    <item>
      <title>How to use Unit tests in Laragine</title>
      <dc:creator>AbdlrahmanSaber</dc:creator>
      <pubDate>Mon, 04 Oct 2021 19:04:20 +0000</pubDate>
      <link>https://dev.to/abdlrahmansaberabdo/how-to-use-unit-tests-in-laragine-1jg8</link>
      <guid>https://dev.to/abdlrahmansaberabdo/how-to-use-unit-tests-in-laragine-1jg8</guid>
      <description>&lt;p&gt;In the previous tutorial, I taught you how to create a &lt;code&gt;fully CRUD API&lt;/code&gt;, let's continue the journey and learn how to use &lt;strong&gt;Laragine&lt;/strong&gt; to test the &lt;code&gt;API&lt;/code&gt; that we created in the previous tutorial.&lt;/p&gt;

&lt;h2&gt;
  
  
  Steps:
&lt;/h2&gt;

&lt;p&gt;We need to do 3 things in &lt;code&gt;phpunit.xml&lt;/code&gt; in the root directory:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Change the value of the &lt;code&gt;bootstrap&lt;/code&gt; attribute to &lt;code&gt;vendor/yepwoo/laragine/src/autoload.php&lt;/code&gt; in &lt;code&gt;PHPUnit&lt;/code&gt; tag (it's the same as &lt;code&gt;vendor/autoload.php&lt;/code&gt; but with needed stuff to run the tests correctly in the generated modules and units).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Add the following to the &lt;code&gt;Unit&lt;/code&gt; test suite:&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;code&gt;&amp;lt;directory suffix=".php"&amp;gt;./core/*/Tests/Feature&amp;lt;/directory&amp;gt;&lt;/code&gt;&lt;br&gt;
&lt;code&gt;&amp;lt;directory suffix=".php"&amp;gt;./plugins/*/Tests/Feature&amp;lt;/directory&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;add the following to &lt;code&gt;Feature&lt;/code&gt; test suite:&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;code&gt;&amp;lt;directory suffix=".php"&amp;gt;./core/*/Tests/Feature&amp;lt;/directory&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&amp;lt;directory suffix=".php"&amp;gt;./plugins/*/Tests/Feature&amp;lt;/directory&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;*&lt;em&gt;Here's the full code snippet: *&lt;/em&gt;&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0s0987u0gmiezp883auf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0s0987u0gmiezp883auf.png" alt="image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Let's go to &lt;code&gt;PostTest.php&lt;/code&gt; in &lt;code&gt;core/Blog/Tests/Feature&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;There're &lt;strong&gt;five&lt;/strong&gt; main &lt;em&gt;functions&lt;/em&gt; in the file: &lt;/li&gt;
&lt;li&gt;
&lt;code&gt;testItShouldGetListingOfTheResource()&lt;/code&gt; 
for testing get the lists of the the resource.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;testItShouldStoreNewlyCreatedResource()&lt;/code&gt; 
for testing create a new resource in the storage. &lt;/li&gt;
&lt;li&gt;
&lt;code&gt;testItShouldGetSpecifiedResource()&lt;/code&gt; 
for testing get a specefied the resource.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;testItShouldUpdateSpecifiedResource()&lt;/code&gt;
for testing update a resource in the storage &lt;/li&gt;
&lt;li&gt;
&lt;code&gt;testItShouldRemoveSpecifiedResource()&lt;/code&gt;
for testing remove a resource from the storage&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Note
&lt;/h2&gt;

&lt;p&gt;you can edit the unit tests function as you want, we just write the main methods for each CRUD.&lt;/p&gt;

&lt;p&gt;Now open your &lt;code&gt;terminal&lt;/code&gt; or &lt;code&gt;git bash&lt;/code&gt; in your project and let's run the test, you can run one of the following commands: &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;code&gt;php artisan test&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;./vendor/bin/phpunit&lt;/code&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F396wngvgv6lskazdg3z1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F396wngvgv6lskazdg3z1.png" alt="image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;I hope you found this article helpful. If you need any help please let me know in the comment section.&lt;/p&gt;

&lt;p&gt;Let's connect on &lt;a href="https://www.linkedin.com/in/abdlrahmansaber/" rel="noopener noreferrer"&gt;LinkedIn&lt;/a&gt;&lt;/p&gt;

</description>
      <category>laravel</category>
      <category>programming</category>
      <category>php</category>
      <category>api</category>
    </item>
    <item>
      <title>How to create a fully crud API without implementing the CRUD functions in laravel!</title>
      <dc:creator>AbdlrahmanSaber</dc:creator>
      <pubDate>Mon, 04 Oct 2021 17:55:37 +0000</pubDate>
      <link>https://dev.to/abdlrahmansaberabdo/how-to-create-a-fully-crud-api-without-implementing-the-crud-functions-in-laravel-4e9d</link>
      <guid>https://dev.to/abdlrahmansaberabdo/how-to-create-a-fully-crud-api-without-implementing-the-crud-functions-in-laravel-4e9d</guid>
      <description>&lt;p&gt;Good day, today we are going to build a fully CRUD system (Web &amp;amp; API). API is a software intermediary that allows two applications to talk to each other. Somethings you might need to create an app that can be run on different languages or frameworks, for example, you can use Laravel to create the backend for your application while the frontend might run on any JavaScript frameworks. API allows two or more programs to communicate with each other.&lt;br&gt;
There are different types of APIs, but today we are going to concentrate on &lt;strong&gt;RESTful APIs. REST&lt;/strong&gt; stands for &lt;strong&gt;Representational State Transfer&lt;/strong&gt;, while &lt;strong&gt;API&lt;/strong&gt; stands for &lt;strong&gt;Application Programming Interface&lt;/strong&gt;. You can read more about API from the internet or other programming material.&lt;/p&gt;

&lt;p&gt;Click on my &lt;a href="https://dev.to/abdlrahmansaberabdo"&gt;profile&lt;/a&gt; to follow me to get more updates.&lt;/p&gt;

&lt;h1&gt;
  
  
  Prerequisites
&lt;/h1&gt;

&lt;p&gt;We'll use a laravel package called &lt;strong&gt;Laragine&lt;/strong&gt;, this package helps us to &lt;strong&gt;create a fully CRUD system&lt;/strong&gt; by &lt;strong&gt;just writing simple commands&lt;/strong&gt; Without saying much, let's dive into it.&lt;/p&gt;

&lt;h1&gt;
  
  
  What is Laragine?
&lt;/h1&gt;

&lt;p&gt;Laragine is a laravel package which was created to manage your large laravel app using modules, let's say that you'll build a &lt;strong&gt;blog&lt;/strong&gt; the blog consist of (post - comment - like), &lt;strong&gt;blog-&amp;gt; is a module&lt;/strong&gt;, &lt;strong&gt;(post - comment - like) -&amp;gt; called units *&lt;em&gt;laragine built the module &amp;amp; units with all CRUD functionalities also built *&lt;/em&gt;(Migrations - factories - tests - controllers - models)&lt;/strong&gt; all you have to do is to just include the link in route files, awesome, right!&lt;/p&gt;

&lt;p&gt;In this tutorial, we'll just create a &lt;strong&gt;post for a blog&lt;/strong&gt; with &lt;strong&gt;fully CRUD functionalities&lt;/strong&gt; so we'll create a &lt;strong&gt;module&lt;/strong&gt; called &lt;strong&gt;blog&lt;/strong&gt; then we'll create a &lt;strong&gt;unit&lt;/strong&gt; called &lt;strong&gt;post&lt;/strong&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  STEP 1: install laravel 8
&lt;/h1&gt;

&lt;p&gt;To install the latest laravel framework, which is laravel 8.0 as of the time of publishing this article, run the command below&lt;br&gt;
&lt;code&gt;composer create-project --prefer-dist laravel/laravel laravel_8&lt;/code&gt;&lt;br&gt;
This will automatically create a laravel 8 app and some couple of things have been set up, we don’t need to copy and rename the env.example file, Laravel 8 does that automatically for us.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbbf9i8ponxtgnobhugse.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbbf9i8ponxtgnobhugse.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Another important thing about Laravel 8, you don’t need to generate APP_KEY, this new version will also generate it for us.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcc64d6ay2nn5d8magvja.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcc64d6ay2nn5d8magvja.png" alt="image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;With that all set up, our app is ready.&lt;/p&gt;

&lt;h1&gt;
  
  
  STEP 2: Database setup
&lt;/h1&gt;

&lt;p&gt;Create an empty database, Open the .env file, and update your database configurations.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Futel0qnxegkkjsifjatk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Futel0qnxegkkjsifjatk.png" alt="image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  STEP 3: Require Laragine package
&lt;/h1&gt;

&lt;p&gt;Let us install Laragine.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;composer require yepwoo/laragine&lt;/code&gt;&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frfww5wnihld1je6e9nyl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frfww5wnihld1je6e9nyl.png" alt="image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  STEP 4: Install the package
&lt;/h1&gt;

&lt;p&gt;After including Laragine, you have to install it by running the following command:&lt;br&gt;
&lt;code&gt;php artisan laragine:install&lt;/code&gt;&lt;br&gt;
it's an initial command for &lt;strong&gt;Laragine&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F54nlvxkwnztiv5vmz7n7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F54nlvxkwnztiv5vmz7n7.png" alt="image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Note
&lt;/h2&gt;

&lt;p&gt;After running the command, the &lt;strong&gt;Laragine&lt;/strong&gt; directory will be in the root directory under &lt;code&gt;core&lt;/code&gt; directory.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8422oqxffrq1i844htcv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8422oqxffrq1i844htcv.png" alt="image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you want to know more information about the package visit the &lt;a href="https://yepwoo.com/products/laragine/docs/v2/introduction" rel="noopener noreferrer"&gt;documentation&lt;/a&gt; &lt;/p&gt;

&lt;h1&gt;
  
  
  STEP 5: Create a blog module
&lt;/h1&gt;

&lt;p&gt;Run the following command and specify the name of the module in our case will be &lt;code&gt;blog&lt;/code&gt;&lt;br&gt;
&lt;code&gt;php artisan laragin:module blog&lt;/code&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Any module will be added under &lt;code&gt;core directory&lt;br&gt;
After running the command, the **blog** directory will be in the&lt;/code&gt;core` directory.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7i4u8zftg43gnt4g7iem.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7i4u8zftg43gnt4g7iem.png" alt="image"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h1&gt;
  
  
  STEP 6: Create unit
&lt;/h1&gt;

&lt;p&gt;After creating our module (&lt;code&gt;blog&lt;/code&gt;) we need to create a &lt;code&gt;post&lt;/code&gt;, right?&lt;br&gt;
The unit command consists of 2 commands&lt;br&gt;
&lt;strong&gt;Init command&lt;/strong&gt;: &lt;br&gt;
Creates all basic files and will create a JSON file that we'll specify the attributes that we want to add it to the database, we should specify the name of the module that we want to add the unit under it, which is &lt;code&gt;blog&lt;/code&gt; in this example.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Second command&lt;/strong&gt;: &lt;br&gt;
it's the same command without &lt;strong&gt;init option&lt;/strong&gt;, the command will automatically create all the following files depending on the data that we specified in the &lt;code&gt;JSON&lt;/code&gt; file.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Migration&lt;/li&gt;
&lt;li&gt;Requests&lt;/li&gt;
&lt;li&gt;Resources&lt;/li&gt;
&lt;li&gt;Factories&lt;/li&gt;
&lt;li&gt;unit tests&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;let's run the commands, we should specify &lt;code&gt;name of the module&lt;/code&gt; that we want to create the unit under it &amp;amp; the &lt;code&gt;name of unit&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;php artisan laragin:unit post --module=blog --init&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;We include &lt;code&gt;--init&lt;/code&gt; because it's the first part of &lt;strong&gt;unit command&lt;/strong&gt;&lt;br&gt;
After running the command it'll generate the basic files &lt;code&gt;Controller (API - web) - Model&lt;/code&gt; &amp;amp; also the &lt;code&gt;JSON&lt;/code&gt; file that we'll write our attributes in it.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fr46qnp8zxccv9o8a03ud.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fr46qnp8zxccv9o8a03ud.png" alt="image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Now we should specify our attributes in the &lt;code&gt;Post.json&lt;/code&gt; file, let's first know what the attributes that we need!
let's start with the basics in this article &lt;strong&gt;I just want to show you how to use the package&lt;/strong&gt;, &lt;strong&gt;you can add any amount of attributes you want&lt;/strong&gt;, any &lt;strong&gt;post&lt;/strong&gt; have &lt;code&gt;title, body, thumbnail&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Note
&lt;/h2&gt;

&lt;p&gt;if we don't put the attribute as &lt;code&gt;nullable&lt;/code&gt; will be &lt;code&gt;required&lt;/code&gt; by default&lt;/p&gt;

&lt;h1&gt;
  
  
  Attributes:
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;title           -&amp;gt; type: &lt;code&gt;string&lt;/code&gt;, definition: &lt;code&gt;unique&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;body         -&amp;gt; type: &lt;code&gt;text&lt;/code&gt;, &lt;/li&gt;
&lt;li&gt;image       -&amp;gt; type: &lt;code&gt;string&lt;/code&gt;, definition: &lt;code&gt;nullable&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now let's go to the JSON file which is in &lt;code&gt;core/blog/data/Post.json&lt;/code&gt; to write our attributes.&lt;/p&gt;

&lt;h1&gt;
  
  
  Note
&lt;/h1&gt;

&lt;p&gt;we should follow &lt;code&gt;rules&lt;/code&gt; when writing any attribute in &lt;code&gt;JSON&lt;/code&gt; file, there are two types of configuration &lt;code&gt;type &amp;amp; definition&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;type: &lt;/code&gt; is the type of attribute you &lt;strong&gt;should&lt;/strong&gt; write it as &lt;code&gt;Laravel&lt;/code&gt; specified in docs you can check all types in Laravel from &lt;a href="https://laravel.com/docs/8.x/migrations#available-column-types" rel="noopener noreferrer"&gt;here&lt;/a&gt; &lt;/li&gt;
&lt;li&gt;
&lt;code&gt;definition: &lt;/code&gt; is for column modifier also you &lt;strong&gt;should&lt;/strong&gt; write it as `Laravel specified in the docs you can check it from &lt;a href="https://laravel.com/docs/8.x/migrations#column-modifiers" rel="noopener noreferrer"&gt;here&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1644342945921%2FHmv98vYaKx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1644342945921%2FHmv98vYaKx.png" alt="image.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;if you realized that I didn't write &lt;code&gt;required&lt;/code&gt; because the package will add it automatically.&lt;/p&gt;

&lt;h2&gt;
  
  
  Let's run the second part of &lt;code&gt;unit command&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;php artisan laragin:unit post --module=blog&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;After running the command it'll generate &lt;code&gt;migrations - requests - resources - factories - unit tests - etc...&lt;/code&gt; files and they are fully implemented.&lt;/p&gt;

&lt;p&gt;let's see the &lt;code&gt;migration&lt;/code&gt; file, you'll see all &lt;code&gt;attributes&lt;/code&gt; are added automatically with the configuration that we specified in &lt;code&gt;JSON&lt;/code&gt; file, magic, right🧐!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1644343098936%2F3rxJ-GLmRV.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1644343098936%2F3rxJ-GLmRV.png" alt="image.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Now let's run &lt;code&gt;migrate command&lt;/code&gt;
&lt;code&gt;php artisan migrate&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  STEP 7: Add API route
&lt;/h2&gt;

&lt;p&gt;add &lt;code&gt;Route::apiResource('posts', 'PostController');&lt;/code&gt; in &lt;code&gt;api.php&lt;/code&gt; in &lt;code&gt;core\Blog\routes\api.php&lt;/code&gt;&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhwc9crekxwghw6qa88id.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhwc9crekxwghw6qa88id.png" alt="image"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;h2&gt;
  
  
  Note
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;we don't need to implement &lt;code&gt;CRUD&lt;/code&gt; methods, it's aleardy implemented in &lt;code&gt;PostController&lt;/code&gt; in &lt;code&gt;core\Blog\Controllers\API\PostController&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  STEP 8: Testing
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;open &lt;code&gt;Postman&lt;/code&gt; or any other software you use to test the &lt;code&gt;API&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;let's first create a new post&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ft8mhlqy3f46jwtfwefpg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ft8mhlqy3f46jwtfwefpg.png" alt="image"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;let's create another post but without including the &lt;code&gt;title&lt;/code&gt; to just test if it'll return &lt;code&gt;error&lt;/code&gt; or not&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1nyegieb62g1uu9tyt8z.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1nyegieb62g1uu9tyt8z.png" alt="image"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Now you're wondering how it gives us that the &lt;code&gt;title&lt;/code&gt; attribute is required, right 🤔? let's see &lt;code&gt;PostRequest&lt;/code&gt; file in &lt;code&gt;core/Blog/Requests&lt;/code&gt;, all attributes that we specefied is in the file with some &lt;code&gt;validation&lt;/code&gt;, &lt;code&gt;Laragine&lt;/code&gt; does this job for us.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  note
&lt;/h1&gt;

&lt;p&gt;you can modify any attribute you want in &lt;code&gt;request file&lt;/code&gt; or in any other file &lt;code&gt;Resources - unit test - etc...&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1644343294725%2FMYi9cmLKm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1644343294725%2FMYi9cmLKm.png" alt="image.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Let's &lt;code&gt;get&lt;/code&gt; all &lt;code&gt;posts&lt;/code&gt;&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4i40ho03145hujebw1uy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4i40ho03145hujebw1uy.png" alt="image"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Let's &lt;code&gt;update&lt;/code&gt; the post&lt;br&gt;
before testing update method, you may want to change the &lt;code&gt;validation&lt;/code&gt; in the update request &lt;strong&gt;(put)&lt;/strong&gt; and you can do this from &lt;code&gt;PostRequest&lt;/code&gt; in &lt;code&gt;core/Blog/Requests&lt;/code&gt; file in &lt;code&gt;put&lt;/code&gt; method&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvx6n0t729k3cg8tsm02w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvx6n0t729k3cg8tsm02w.png" alt="image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Let's &lt;code&gt;delete&lt;/code&gt; the post
&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwsrme8a39707kytnfq5b.png" alt="image"&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;in this article I just showed you &lt;code&gt;one&lt;/code&gt; feature of &lt;strong&gt;Laragine&lt;/strong&gt; package, in the &lt;strong&gt;next tutorial&lt;/strong&gt; I'll teach you how to use&lt;br&gt;
&lt;code&gt;unit tests&lt;/code&gt; by just making a small configuration.&lt;/p&gt;

&lt;p&gt;Let's connect on &lt;a href="https://www.linkedin.com/in/abdlrahmansaber/" rel="noopener noreferrer"&gt;LinkedIn&lt;/a&gt;&lt;/p&gt;

</description>
      <category>laravel</category>
      <category>api</category>
      <category>testing</category>
      <category>php</category>
    </item>
  </channel>
</rss>
