<?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: Mehedi Mansur Rafi</title>
    <description>The latest articles on DEV Community by Mehedi Mansur Rafi (@mehedirafi).</description>
    <link>https://dev.to/mehedirafi</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.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4225276%2F2e9a9458-7202-4b9a-919b-75a5a2d50b09.jpg</url>
      <title>DEV Community: Mehedi Mansur Rafi</title>
      <link>https://dev.to/mehedirafi</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mehedirafi"/>
    <language>en</language>
    <item>
      <title>Build a hosting company homepage in Laravel, with plans and a billing snapshot</title>
      <dc:creator>Mehedi Mansur Rafi</dc:creator>
      <pubDate>Mon, 23 Nov 2026 12:31:33 +0000</pubDate>
      <link>https://dev.to/mehedirafi/build-a-hosting-company-homepage-in-laravel-with-plans-and-a-billing-snapshot-50ad</link>
      <guid>https://dev.to/mehedirafi/build-a-hosting-company-homepage-in-laravel-with-plans-and-a-billing-snapshot-50ad</guid>
      <description>&lt;p&gt;Part 1 of Small Business Sites.&lt;/p&gt;

&lt;p&gt;A hosting company homepage has one job: show the plans clearly enough that a visitor can pick one without opening a support ticket. Most small hosts I see either hard code their prices into the page, so every price change means editing HTML in four places, or they install a billing system built for a company ten times their size before they have ten customers.&lt;/p&gt;

&lt;p&gt;This build sits between those two. The plans live in a database table, so the homepage reads them the way any Laravel page reads data. The price toggle switches between monthly and yearly without a page reload. A billing snapshot panel shows a signed in customer their invoices, due dates, and payment status, read only. Payments themselves stay outside this build, and I say where they would connect at the end.&lt;/p&gt;

&lt;h2&gt;
  
  
  Put the plans in a table first
&lt;/h2&gt;

&lt;p&gt;Three plans are enough for a small host. The table needs the facts a buyer compares: name, disk space, bandwidth, email accounts, and the two prices. Store the monthly and yearly price as separate columns. Working the yearly price out from the monthly one inside the view sounds tidy and breaks the first time you run a yearly offer that is not a round multiple.&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="nc"&gt;Schema&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="s1"&gt;'plans'&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="nc"&gt;Blueprint&lt;/span&gt; &lt;span class="nv"&gt;$table&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nv"&gt;$table&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="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nv"&gt;$table&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'name'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nv"&gt;$table&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;unsignedInteger&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'disk_gb'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nv"&gt;$table&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'bandwidth'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nv"&gt;$table&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;unsignedInteger&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'email_accounts'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nv"&gt;$table&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;decimal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'monthly_price'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nv"&gt;$table&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;decimal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'yearly_price'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nv"&gt;$table&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;boolean&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'featured'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="k"&gt;default&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nv"&gt;$table&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;unsignedInteger&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'sort_order'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="k"&gt;default&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nv"&gt;$table&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;timestamps&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="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;Seed it with your real plans and your real prices. The names and numbers in my screenshots are sample data from my own template work, and yours should be the plans you can actually deliver. A plan card is a promise. If the disk figure on the homepage is larger than the disk you give the account, the page is lying in a way a customer will find in the first week.&lt;/p&gt;

&lt;p&gt;The controller for the homepage stays small:&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="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;home&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="nv"&gt;$plans&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Plan&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;orderBy&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'sort_order'&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;get&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;return&lt;/span&gt; &lt;span class="nf"&gt;view&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'home'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nf"&gt;compact&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'plans'&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That is the whole point of the table. Adding a fourth plan next year is a row in the database, not an afternoon of HTML edits.&lt;/p&gt;

&lt;h2&gt;
  
  
  Draw the plan cards and the toggle
&lt;/h2&gt;

&lt;p&gt;Each plan becomes one card. The card shows the name, the price, and the comparison rows in the same order on every card, so a visitor can read down one column and across the next. Keep the rows identical across cards. A row that appears on one card and not the next reads as a hidden limit, even when it was only a layout slip.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@foreach($plans as $plan)
    &amp;lt;article class="plan-card {{ $plan-&amp;gt;featured ? 'featured' : '' }}"&amp;gt;
        &amp;lt;h3&amp;gt;{{ $plan-&amp;gt;name }}&amp;lt;/h3&amp;gt;
        &amp;lt;p class="price"&amp;gt;
            &amp;lt;span data-monthly="{{ $plan-&amp;gt;monthly_price }}"
                  data-yearly="{{ $plan-&amp;gt;yearly_price }}"&amp;gt;
                ${{ $plan-&amp;gt;monthly_price }}
            &amp;lt;/span&amp;gt;
            &amp;lt;span class="per"&amp;gt;/mo&amp;lt;/span&amp;gt;
        &amp;lt;/p&amp;gt;
        &amp;lt;ul&amp;gt;
            &amp;lt;li&amp;gt;{{ $plan-&amp;gt;disk_gb }} GB disk space&amp;lt;/li&amp;gt;
            &amp;lt;li&amp;gt;{{ $plan-&amp;gt;bandwidth }} bandwidth&amp;lt;/li&amp;gt;
            &amp;lt;li&amp;gt;{{ $plan-&amp;gt;email_accounts }} email accounts&amp;lt;/li&amp;gt;
        &amp;lt;/ul&amp;gt;
    &amp;lt;/article&amp;gt;
@endforeach
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The toggle is two buttons and a few lines of JavaScript. Both prices are already on the page inside the data attributes, so switching needs no request to the server and works even on a slow connection.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;querySelectorAll&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'[data-cycle]'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;forEach&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;button&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;button&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addEventListener&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'click'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kd"&gt;function&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="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;cycle&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;button&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;dataset&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;cycle&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;querySelectorAll&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'[data-monthly]'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;forEach&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;el&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="n"&gt;el&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;textContent&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'$'&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;cycle&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="s1"&gt;'yearly'&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="n"&gt;el&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;dataset&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;yearly&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;el&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;dataset&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;monthly&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="p"&gt;;&lt;/span&gt;
        &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;querySelectorAll&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'.per'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;forEach&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;el&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="n"&gt;el&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;textContent&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;cycle&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="s1"&gt;'yearly'&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="s1"&gt;'/yr'&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'/mo'&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="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="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;Check the cards at phone width before you call this section done. At 390px the cards stack in one column, the price stays on one line, and no card is wider than the screen. A pricing table that needs sideways scrolling on a phone loses the visitors most likely to be comparing plans away from their desk.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F65qq74x3k2ai7kgepfgc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F65qq74x3k2ai7kgepfgc.png" alt="The homepage plan cards on desktop, three cards with the toggle set to monthly" width="800" height="500"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fzi99lvakx07el8yo3srl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fzi99lvakx07el8yo3srl.png" alt="The same plan cards at 390px phone width, stacked in one column" width="390" height="844"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The billing snapshot panel
&lt;/h2&gt;

&lt;p&gt;Once a visitor becomes a customer, the question changes from what does it cost to what do I owe and when. A snapshot panel answers that on one screen: the current plan, the invoices, each due date, and each status. It reads data. It does not take money, and it should not pretend to.&lt;/p&gt;

&lt;p&gt;Invoices need their own small table: the customer, the plan, the amount, an issue date, a due date, and a status field that holds plain words like unpaid, paid, and overdue.&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="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;billing&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="nv"&gt;$invoices&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;auth&lt;/span&gt;&lt;span class="p"&gt;(&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;user&lt;/span&gt;&lt;span class="p"&gt;(&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;invoices&lt;/span&gt;&lt;span class="p"&gt;(&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;orderByDesc&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'due_date'&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;take&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10&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;get&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;return&lt;/span&gt; &lt;span class="nf"&gt;view&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'billing'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nf"&gt;compact&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'invoices'&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the view, show the status as text a person uses, with the due date next to it, and let overdue rows stand out by colour alone. Do not hide an unpaid invoice behind a tab. The panel earns its place the day a customer checks it instead of opening a ticket to ask when their renewal is due. When you later connect a payment gateway, it connects here: the gateway marks the invoice paid, and this panel keeps doing the same read it always did.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fwjio8se0v09kcwucyxz1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fwjio8se0v09kcwucyxz1.png" alt="The billing snapshot panel with sample invoices, due dates, and paid and unpaid status rows" width="800" height="500"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The domain box and the support section, kept small
&lt;/h2&gt;

&lt;p&gt;A domain search box belongs on the homepage, as a front end form. Give it an input, a button, and an answer area. Until a real domain API connects to it, the honest version checks nothing and says so in the small print under the box, or stays off the page. A box that invents availability results is worse than no box.&lt;/p&gt;

&lt;p&gt;The support section needs three things: the hours a person actually answers, a link to open a ticket or a contact page, and a status note the owner can edit by hand when something is wrong. One edited line that says the mail server restart finished at a real time builds more trust than a green all systems normal badge that never changes.&lt;/p&gt;

&lt;h2&gt;
  
  
  Trust sections that do not fake numbers
&lt;/h2&gt;

&lt;p&gt;A new hosting company has no honest big numbers. It has no thousands of customers, no years of uptime record, and no wall of testimonials. Templates often ship with those numbers filled in, and leaving them in is the fastest way to make a real company look fake to anyone who reads closely.&lt;/p&gt;

&lt;p&gt;What a new host can show is smaller and stronger. The exact plan limits, printed on the cards where the buyer compares them. The support hours it really keeps. How to reach a person, with a named page and a working form. The terms, privacy, and refund pages written as plain templates the owner has read. And the status note above, edited by hand. Each of those can be checked by a visitor, and a claim that can be checked is the kind that holds up.&lt;/p&gt;

&lt;p&gt;Add the other numbers later, one at a time, when they are true. A first testimonial with a real customer name on it is worth more than a row of invented ones, and it cannot be taken apart in a comment thread.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fg0aicjym9211r2ahv7kq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fg0aicjym9211r2ahv7kq.png" alt="The support and status section of the homepage, with support hours and the hand edited status note" width="800" height="160"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What stays static and what goes dynamic
&lt;/h2&gt;

&lt;p&gt;Keep the static parts static. The explanation of what shared hosting and VPS mean, the support hours text, the legal pages, and the company story do not change by the week, and plain Blade views with no queries keep them fast and hard to break.&lt;/p&gt;

&lt;p&gt;Make dynamic only what changes or what belongs to a person: the plans and prices, because an offer or a new plan should not need a code edit; the status note, because it changes during an incident; and the billing panel, because it shows one customer's own invoices. That split is most of the maintenance story for a small host. The homepage stays quick, and the parts an owner edits from an admin screen are the parts that were going to change anyway.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where this leaves you
&lt;/h2&gt;

&lt;p&gt;With the plans in a table, the toggle on the cards, and the snapshot panel reading real invoices, a small hosting homepage in Laravel is a weekend of work and a short list of pages. If you would rather start from the finished version, HostNest is this homepage finished as a 10 page template. If you need the whole site and not only the homepage, it is $24 on Gumroad: &lt;a href="https://mehedirafi.gumroad.com/l/hostnest" rel="noopener noreferrer"&gt;https://mehedirafi.gumroad.com/l/hostnest&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;I am Mehedi Mansur Rafi, a freelance Laravel developer (B.Sc. in Computer Science &amp;amp; Engineering). I build hospital, clinic, and small business websites. My full store is at &lt;a href="https://mehedirafi.gumroad.com/" rel="noopener noreferrer"&gt;https://mehedirafi.gumroad.com/&lt;/a&gt; and my site is &lt;a href="https://mehedimansurrafi.online" rel="noopener noreferrer"&gt;https://mehedimansurrafi.online&lt;/a&gt;&lt;/p&gt;

</description>
      <category>html</category>
      <category>css</category>
      <category>webdev</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>I turned my own portfolio into an IDE-style site, and what I would change</title>
      <dc:creator>Mehedi Mansur Rafi</dc:creator>
      <pubDate>Fri, 20 Nov 2026 23:56:04 +0000</pubDate>
      <link>https://dev.to/mehedirafi/i-turned-my-own-portfolio-into-an-ide-style-site-and-what-i-would-change-42b8</link>
      <guid>https://dev.to/mehedirafi/i-turned-my-own-portfolio-into-an-ide-style-site-and-what-i-would-change-42b8</guid>
      <description>&lt;p&gt;My portfolio used to look like every other developer portfolio. A large name at the top, a short line about building websites, a grid of project cards, and a contact form at the bottom. It was accurate and it was forgettable, including to me. I spend most of my working day inside a code editor, so last year I rebuilt the site to look like one. The live version runs at mehedimansurrafi.online, and it is the site I send with every proposal now. This post covers why I chose the layout, what using it has taught me, and what I would change if I started again.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why an IDE layout
&lt;/h2&gt;

&lt;p&gt;An editor window has a shape most developers read without thinking. A file tree on the left lists everything in the project. The main area shows one open file at a time. Tabs along the top show what else is open. A status bar at the bottom carries the small details.&lt;/p&gt;

&lt;p&gt;My portfolio maps onto that shape with no forcing. The file tree became the menu: home, projects, each project as its own file, about, contact, resume. Each page reads like an open file, with the project pages written the way a readme is written, what the thing does first, then the stack, then the links. The status bar carries my location, my availability, and a contact link, so they stay visible on every page without a banner shouting about them.&lt;/p&gt;

&lt;p&gt;The honest reason is simpler than the design argument. The layout says what I do before a visitor reads a word. A clinic owner may not care, and this site is not aimed at clinic owners. It is aimed at developers and at the clients who hire developers and have learned to read a GitHub profile. For that audience, an editor is a familiar room.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fpahcqk7faez0fujepchh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fpahcqk7faez0fujepchh.png" alt="Desktop home page of mehedimansurrafi.online, full window with the file tree and open home file visible" width="800" height="500"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  How visitors use it, against a normal portfolio
&lt;/h2&gt;

&lt;p&gt;I have no analytics story to tell here, and I will not invent one. What I know comes from sharing the link and watching what people open, and from testing the site myself the way a visitor would.&lt;/p&gt;

&lt;p&gt;Two differences stand out against my old layout. The first is that people treat the file tree as a table of contents and click it directly. On the old site, the path was scroll and hope: hero, about, projects somewhere below. Here the whole site is listed on the left from the first second, and a visitor with one question, what has he built, goes straight to the projects folder. The second difference is order. Visitors open the project files before the about page. On a normal portfolio the about section sits high and gets read early. Here the work reads first and the person reads later, which is the order I would choose for them anyway.&lt;/p&gt;

&lt;p&gt;The cost is real too. A visitor who has never used an editor meets a busier first screen than a name and a grid. Some of the editor decoration, the line numbers and the tab shapes, is pure costume for them. I accept that cost because of who the site is for, but it is the first thing I would weigh if the audience changed.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I would keep
&lt;/h2&gt;

&lt;p&gt;The file tree menu stays. It shows the full site at a glance and it never moves, which a top navigation bar on a long page cannot do.&lt;/p&gt;

&lt;p&gt;The project pages stay written like readme files. A fixed shape, problem, build, stack, live link, code link, means a visitor can read the second project faster than the first, because they already know where each fact sits.&lt;/p&gt;

&lt;p&gt;The status bar stays. Contact details that are visible on every page, without a popup or a floating button, are easier to act on than details buried at the end of one long page. Every path through the site ends one click from the contact file, and that was a deliberate choice, not an accident of the layout.&lt;/p&gt;

&lt;p&gt;The theme switch stays. Dark is the default because the editor idea asks for it, and light is one click away, built on one set of CSS variables so both themes are the same layout wearing different colours.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I would change, and what I dropped
&lt;/h2&gt;

&lt;p&gt;I started with too many files in the tree. Every small page got its own entry, and the list read like a directory dump. I merged the small pages and grouped the rest, and the tree got shorter and clearer. If I started again I would plan the tree at six to eight entries from day one.&lt;/p&gt;

&lt;p&gt;I dropped the fake terminal. An early version had a console panel that typed out lines about my skills. It did nothing a paragraph could not do, it slowed the page, and it was the kind of clever touch that makes a visitor watch the site perform instead of reading it. Anything in an editor layout that does not help navigation or reading is costume, and costume has to earn its place. The terminal did not.&lt;/p&gt;

&lt;p&gt;I would also move the resume earlier. It sat low in the tree at first, grouped with the about pages. Recruiters and clients ask for a resume more than they ask for anything else on the site, so it earned a place near the top of the tree. That change came from requests, not from taste.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fryg7u3br9v6tqqrnc23d.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fryg7u3br9v6tqqrnc23d.png" alt="File tree sidebar close up, showing the final short list of entries and the resume position" width="240" height="900"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The mobile problem
&lt;/h2&gt;

&lt;p&gt;An editor is a wide screen tool. Shrink it to a phone and the layout fights you: the tree wants a third of the width, the tabs want a row, and the page gets what is left. My first mobile version squeezed all three in, and the text column was too narrow to read in comfort.&lt;/p&gt;

&lt;p&gt;The fix was to stop treating the phone layout as a smaller editor. On a small screen the sidebar closes into a menu button, the tabs go, and the page becomes a single column that reads like a document. The file names survive as the menu list, so the idea is still there, but nothing competes with the text. I check the site at 390px width, the size I use for every client build, and the rule I follow is plain: if a page needs horizontal scrolling or pinch zoom at that width, the page is not done.&lt;/p&gt;

&lt;p&gt;This is the part of the design I would warn anyone copying it about. The desktop layout is the fun half of the work. The phone layout is where the design either becomes a real site or stays a screenshot.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fhzygjzkd39aigiawayuo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fhzygjzkd39aigiawayuo.png" alt="The live site on a phone width screen, 390px, sidebar closed, single column page" width="390" height="844"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The template decision
&lt;/h2&gt;

&lt;p&gt;Other developers asked how the site was built, and the easiest honest answer was to sell the design as a template. That version is FolioForge. Turning a live Laravel platform into a template meant cutting, not adding. The live site runs on a Laravel app with an admin side, member pages, and settings. A template buyer needs none of that. They need files they can open, edit, and upload anywhere.&lt;/p&gt;

&lt;p&gt;So FolioForge is the static version. Plain HTML and CSS, no database, no admin panel, and a contact form that opens the visitor mail app, because a static site has no server to send mail. It keeps the parts that survived my own edits: the short file tree, the readme shaped project pages, the status bar, and the phone layout that drops the editor furniture. It drops the platform parts that only make sense on my own site.&lt;/p&gt;

&lt;p&gt;FolioForge is this design finished as a template. It has 6 pages, dark and light themes, and a fictional sample persona you replace with your own details. It costs $19 on Gumroad: &lt;a href="https://mehedirafi.gumroad.com/l/folioforge" rel="noopener noreferrer"&gt;https://mehedirafi.gumroad.com/l/folioforge&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;I am Mehedi Mansur Rafi, a freelance Laravel developer (B.Sc. in Computer Science &amp;amp; Engineering). I build hospital, clinic, and small business websites, and I take website work through Fiverr: &lt;a href="https://www.fiverr.com/mehedi__rafi" rel="noopener noreferrer"&gt;https://www.fiverr.com/mehedi__rafi&lt;/a&gt;. My full store is at &lt;a href="https://mehedirafi.gumroad.com/" rel="noopener noreferrer"&gt;https://mehedirafi.gumroad.com/&lt;/a&gt; and my site is &lt;a href="https://mehedimansurrafi.online" rel="noopener noreferrer"&gt;https://mehedimansurrafi.online&lt;/a&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>html</category>
      <category>css</category>
      <category>portfolio</category>
    </item>
    <item>
      <title>Login, roles and permissions in Laravel, the setup I reuse on every project</title>
      <dc:creator>Mehedi Mansur Rafi</dc:creator>
      <pubDate>Tue, 17 Nov 2026 13:18:43 +0000</pubDate>
      <link>https://dev.to/mehedirafi/login-roles-and-permissions-in-laravel-the-setup-i-reuse-on-every-project-23i</link>
      <guid>https://dev.to/mehedirafi/login-roles-and-permissions-in-laravel-the-setup-i-reuse-on-every-project-23i</guid>
      <description>&lt;p&gt;Part 4 of Laravel in Production.&lt;/p&gt;

&lt;p&gt;Every admin panel I build reaches the same week. The owner starts as the only user, then staff need accounts: a receptionist who books appointments, a manager who sees reports, and someone who must never open the settings page. I run the same small setup each time. It is the setup behind the admin screens in AdminForge, and a larger version of it runs the hospital system I sell, where seven roles share one database.&lt;/p&gt;

&lt;p&gt;No package is required. Two tables, a pivot, one middleware, and one policy cover most small panels. If your app grows past this, the shape still holds and a package can take over later.&lt;/p&gt;

&lt;h2&gt;
  
  
  Plan the roles on paper first
&lt;/h2&gt;

&lt;p&gt;Write the roles as a table before any code. One row per screen or action, one column per role, and a plain yes or no in each cell. For a clinic panel mine looks like this:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Action&lt;/th&gt;
&lt;th&gt;Admin&lt;/th&gt;
&lt;th&gt;Manager&lt;/th&gt;
&lt;th&gt;Staff&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;View patients&lt;/td&gt;
&lt;td&gt;yes&lt;/td&gt;
&lt;td&gt;yes&lt;/td&gt;
&lt;td&gt;yes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Book appointments&lt;/td&gt;
&lt;td&gt;yes&lt;/td&gt;
&lt;td&gt;yes&lt;/td&gt;
&lt;td&gt;yes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Edit billing&lt;/td&gt;
&lt;td&gt;yes&lt;/td&gt;
&lt;td&gt;yes&lt;/td&gt;
&lt;td&gt;no&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;View reports&lt;/td&gt;
&lt;td&gt;yes&lt;/td&gt;
&lt;td&gt;yes&lt;/td&gt;
&lt;td&gt;no&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Manage users&lt;/td&gt;
&lt;td&gt;yes&lt;/td&gt;
&lt;td&gt;no&lt;/td&gt;
&lt;td&gt;no&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Change settings&lt;/td&gt;
&lt;td&gt;yes&lt;/td&gt;
&lt;td&gt;no&lt;/td&gt;
&lt;td&gt;no&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;This table does two jobs. The client agrees to it before I build, so access arguments end early. Later it becomes the test sheet: every cell is one login and one check.&lt;/p&gt;

&lt;h2&gt;
  
  
  Name permissions after the action
&lt;/h2&gt;

&lt;p&gt;Permissions get names in one fixed pattern: the resource, a dot, the action. &lt;code&gt;patients.view&lt;/code&gt;, &lt;code&gt;patients.create&lt;/code&gt;, &lt;code&gt;billing.edit&lt;/code&gt;, &lt;code&gt;settings.update&lt;/code&gt;, &lt;code&gt;users.manage&lt;/code&gt;. The pattern matters more than the list. A new screen gets a predictable name, and a search for &lt;code&gt;billing.&lt;/code&gt; in the code finds every billing check in seconds.&lt;/p&gt;

&lt;p&gt;Avoid role names inside permission checks. The day a manager also needs billing access, &lt;code&gt;if role is manager&lt;/code&gt; edits spread across the app. A permission moves by changing one row in a table.&lt;/p&gt;

&lt;h2&gt;
  
  
  The tables
&lt;/h2&gt;

&lt;p&gt;One role per user is enough for the panels I build, so users carry a &lt;code&gt;role_id&lt;/code&gt;. Permissions attach to roles through a pivot.&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="nc"&gt;Schema&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="s1"&gt;'roles'&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="nc"&gt;Blueprint&lt;/span&gt; &lt;span class="nv"&gt;$table&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nv"&gt;$table&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="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nv"&gt;$table&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'name'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;        &lt;span class="c1"&gt;// Admin&lt;/span&gt;
    &lt;span class="nv"&gt;$table&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'slug'&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;unique&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="c1"&gt;// admin&lt;/span&gt;
    &lt;span class="nv"&gt;$table&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;timestamps&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="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nc"&gt;Schema&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="s1"&gt;'permissions'&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="nc"&gt;Blueprint&lt;/span&gt; &lt;span class="nv"&gt;$table&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nv"&gt;$table&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="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nv"&gt;$table&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'name'&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;unique&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="c1"&gt;// patients.view&lt;/span&gt;
    &lt;span class="nv"&gt;$table&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;timestamps&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="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nc"&gt;Schema&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="s1"&gt;'permission_role'&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="nc"&gt;Blueprint&lt;/span&gt; &lt;span class="nv"&gt;$table&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nv"&gt;$table&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;foreignId&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'permission_id'&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;constrained&lt;/span&gt;&lt;span class="p"&gt;(&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;cascadeOnDelete&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="nv"&gt;$table&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;foreignId&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'role_id'&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;constrained&lt;/span&gt;&lt;span class="p"&gt;(&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;cascadeOnDelete&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="nv"&gt;$table&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;primary&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'permission_id'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'role_id'&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="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 Role model holds a &lt;code&gt;permissions()&lt;/code&gt; belongsToMany relation, and the User model gets one method that every check in the app goes through:&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="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;hasPermission&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="nv"&gt;$name&lt;/span&gt;&lt;span class="p"&gt;)&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="n"&gt;role&lt;/span&gt;
        &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;permissions&lt;/span&gt;
        &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;contains&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'name'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$name&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;Keep this method boring. Caching can come later; a clear check you can read at 2 am is worth more.&lt;/p&gt;

&lt;h2&gt;
  
  
  Block routes with middleware
&lt;/h2&gt;

&lt;p&gt;Register a middleware alias in bootstrap/app.php (Laravel 11 and 12 style):&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="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;withMiddleware&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="nc"&gt;Middleware&lt;/span&gt; &lt;span class="nv"&gt;$middleware&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nv"&gt;$middleware&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;alias&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;
        &lt;span class="s1"&gt;'permission'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; \&lt;span class="nc"&gt;App&lt;/span&gt;\&lt;span class="nc"&gt;Http&lt;/span&gt;\&lt;span class="nc"&gt;Middleware&lt;/span&gt;\&lt;span class="nc"&gt;CheckPermission&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="k"&gt;class&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="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 middleware itself is short:&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="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;handle&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&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="nc"&gt;Closure&lt;/span&gt; &lt;span class="nv"&gt;$next&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="nv"&gt;$permission&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;mixed&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="nv"&gt;$request&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="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;?-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;hasPermission&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$permission&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="nf"&gt;abort&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;403&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;return&lt;/span&gt; &lt;span class="nv"&gt;$next&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="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Routes then state their rule where a reader can see it:&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="nc"&gt;Route&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;middleware&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'auth'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'permission:settings.update'&lt;/span&gt;&lt;span class="p"&gt;]&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;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'/settings'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nc"&gt;SettingController&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="k"&gt;class&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'index'&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;First test: sign in as staff and type the settings address by hand. A 403 from the server is the pass mark. A hidden menu link is not. Menu hiding is display work, and it still matters for a clean screen, but the server check is the security.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fw5l76slukwp1f8i3h3vs.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fw5l76slukwp1f8i3h3vs.png" alt="AdminForge roles matrix screen, the grid of roles against permissions" width="800" height="500"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Check again inside a policy
&lt;/h2&gt;

&lt;p&gt;Middleware guards the door. A policy guards the record, for the cases where a role can open a list but only some rows are theirs. A doctor sees patients assigned to them, as an example:&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="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;PatientPolicy&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="nf"&gt;view&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&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="nc"&gt;Patient&lt;/span&gt; &lt;span class="nv"&gt;$patient&lt;/span&gt;&lt;span class="p"&gt;)&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;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt; &lt;span class="nv"&gt;$user&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;hasPermission&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'patients.view'&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;return&lt;/span&gt; &lt;span class="kc"&gt;false&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;$user&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;is_super_admin&lt;/span&gt;
            &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="nv"&gt;$patient&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;doctor_id&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="nv"&gt;$user&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;doctor&lt;/span&gt;&lt;span class="o"&gt;?-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;
            &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="nv"&gt;$user&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;role&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;slug&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="s1"&gt;'doctor'&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;Call it in the controller with &lt;code&gt;$this-&amp;gt;authorize('view', $patient);&lt;/code&gt; and Laravel returns the same 403. Two layers look like extra work until the first time a route gets reused by a new screen and the policy still holds.&lt;/p&gt;

&lt;h2&gt;
  
  
  One super admin, protected by rules
&lt;/h2&gt;

&lt;p&gt;Every panel needs one account that can fix access itself. I keep exactly one super admin, marked by an &lt;code&gt;is_super_admin&lt;/code&gt; flag on the user, and a Gate rule that lets that account pass every check:&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="nc"&gt;Gate&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;before&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="nc"&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;string&lt;/span&gt; &lt;span class="nv"&gt;$ability&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;$user&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;is_super_admin&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt; &lt;span class="p"&gt;:&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="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;Returning null matters: the normal checks still run for everyone else. Around this account sit three hard rules. The flag is never set from a form in the panel. The super admin account cannot be deactivated or deleted while signed in as itself. And its email is the owner's real inbox, so the password reset path always works. The setup stays honest: one known door back in, guarded well, instead of back doors in the code.&lt;/p&gt;

&lt;h2&gt;
  
  
  Seed the first admin, then lock the seeder down
&lt;/h2&gt;

&lt;p&gt;The first admin comes from a seeder that reads its values from the environment file, never from values typed into the code:&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="nc"&gt;User&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;updateOrCreate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'email'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;env&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'ADMIN_EMAIL'&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="s1"&gt;'name'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;env&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'ADMIN_NAME'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'Admin'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="s1"&gt;'password'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nc"&gt;Hash&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;make&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;env&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'ADMIN_PASSWORD'&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="s1"&gt;'role_id'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nc"&gt;Role&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;where&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'slug'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'admin'&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;value&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'id'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="s1"&gt;'is_super_admin'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="kc"&gt;true&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run it once on the server, then remove the password from the environment file and change it after the first login. A roles seeder runs alongside it, creating the roles and permissions from the paper table and attaching them, so a fresh install rebuilds the whole matrix with &lt;code&gt;php artisan migrate --seed&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fqr4abs6umro74meu3h7j.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fqr4abs6umro74meu3h7j.png" alt="AdminForge user list showing the role badges for admin, manager, and staff accounts" width="800" height="500"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Test every role with its own account
&lt;/h2&gt;

&lt;p&gt;Create one real account per role and walk the paper table cell by cell. Sign in as staff, open the settings address by typing it, and write down the result. Sign in as manager and open the user list. Each row of the table gets one pass or fail mark, on the day the feature ships, not from memory later.&lt;/p&gt;

&lt;p&gt;Two cells catch most faults. A staff account that can open a page by address means a route missed its middleware. A manager who gets a 403 on a page the table allows means a permission name drifted, usually a spelling difference between the seeder and the route. Both are five minute fixes on test day and half day hunts after launch.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fqcvdv5y8ikavh89jwsqa.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fqcvdv5y8ikavh89jwsqa.png" alt="AdminForge edit user screen with the role dropdown open" width="800" height="500"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The mistakes that lock owners out of their own panels
&lt;/h2&gt;

&lt;p&gt;Three faults come back again and again in panels I get asked to repair.&lt;/p&gt;

&lt;p&gt;The first is gating the role pages themselves behind a permission, then editing that permission away. The admin removes &lt;code&gt;users.manage&lt;/code&gt; from the admin role by accident, and the screen that would fix it now returns 403 for everyone. This is the job the protected super admin above exists for.&lt;/p&gt;

&lt;p&gt;The second is deleting or deactivating the last admin account during a staff cleanup. Guard it in code: the app refuses to deactivate the only remaining admin, the same way it refuses to delete the super admin.&lt;/p&gt;

&lt;p&gt;The third is quieter. The owner changes email, the old inbox dies, and the password reset link goes nowhere. A panel with no working reset path is one forgotten password away from a database edit. Keep the owner account on an inbox the owner controls, and test the reset mail once before handover. Panels break at the login screen more often than anywhere else; the deploy faults in my earlier post on Laravel routes returning 404 after a move (&lt;a href="https://dev.to/mehedirafi/laravel-returns-404-on-every-route-after-deployment-here-is-the-fix-34p3"&gt;https://dev.to/mehedirafi/laravel-returns-404-on-every-route-after-deployment-here-is-the-fix-34p3&lt;/a&gt;) cost owners the same locked-out afternoon.&lt;/p&gt;

&lt;h2&gt;
  
  
  The short version
&lt;/h2&gt;

&lt;p&gt;Plan the matrix on paper. Name permissions resource dot action. Check in middleware for the route and in a policy for the record. Keep one super admin behind hard rules, seed it once, and test every role with its own account before handover.&lt;/p&gt;

&lt;p&gt;AdminForge already has the roles matrix and user pages built as Blade views. If you want the screens done and only the wiring left, it is $29 on Gumroad: &lt;a href="https://mehedirafi.gumroad.com/l/adminforge" rel="noopener noreferrer"&gt;https://mehedirafi.gumroad.com/l/adminforge&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;I am Mehedi Mansur Rafi, a freelance Laravel developer (B.Sc. in Computer Science &amp;amp; Engineering). I build hospital, clinic, and small business websites, and I fix Laravel sites through Upwork: &lt;a href="https://www.upwork.com/freelancers/%7E0118ab607e0b4c599b" rel="noopener noreferrer"&gt;https://www.upwork.com/freelancers/~0118ab607e0b4c599b&lt;/a&gt;. My store is at &lt;a href="https://mehedirafi.gumroad.com/" rel="noopener noreferrer"&gt;https://mehedirafi.gumroad.com/&lt;/a&gt; and my site is &lt;a href="https://mehedimansurrafi.online" rel="noopener noreferrer"&gt;https://mehedimansurrafi.online&lt;/a&gt;&lt;/p&gt;

</description>
      <category>laravel</category>
      <category>php</category>
      <category>webdev</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>What to check before buying a ready-made admin panel template</title>
      <dc:creator>Mehedi Mansur Rafi</dc:creator>
      <pubDate>Fri, 13 Nov 2026 13:17:19 +0000</pubDate>
      <link>https://dev.to/mehedirafi/what-to-check-before-buying-a-ready-made-admin-panel-template-1p6e</link>
      <guid>https://dev.to/mehedirafi/what-to-check-before-buying-a-ready-made-admin-panel-template-1p6e</guid>
      <description>&lt;p&gt;Part 1 of Before You Buy Code.&lt;/p&gt;

&lt;p&gt;I build admin panels for clinic and small business sites, and I have bought templates to save time. Two of them cost me more time than they saved. The screenshots were fine. The faults sat in parts a screenshot cannot show: a login with no roles behind it, a package with half the pages from the sales page, and setup docs that stopped before the first error.&lt;/p&gt;

&lt;p&gt;Now I run the same checks on every Laravel admin panel template before I pay. Each check has a good sign and a red flag, and most take minutes with a demo or a file list. At the end I run the list on AdminForge, the kit I sell.&lt;/p&gt;

&lt;h2&gt;
  
  
  Check 1: log in, then log in as someone with fewer rights
&lt;/h2&gt;

&lt;p&gt;Open the demo and sign in as admin. Create a second account with a staff role, sign in as that account, and open a settings page by typing its address.&lt;/p&gt;

&lt;p&gt;Good sign: the second account sees fewer pages, and the server refuses the admin pages at the typed address.&lt;/p&gt;

&lt;p&gt;Red flag: the sales page lists roles, and the demo has one login that opens everything. A menu that hides links is decoration. When the second account can open the user list by address, permissions are missing, and adding them later means touching every page.&lt;/p&gt;

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

&lt;h2&gt;
  
  
  Check 2: count the Blade files and open the layout
&lt;/h2&gt;

&lt;p&gt;Ask for the file list, or open the package and count the files in resources/views. The count tells you how much of the panel is real pages. A sales page can show thirty screens that turn out to be ten views in different colors.&lt;/p&gt;

&lt;p&gt;Then open the main layout file. Good sign: the sidebar and the top bar sit in the layout once, and each page fills the middle. Red flag: the menu code is pasted into every view. With a pasted menu, one menu change becomes the same edit repeated across twenty files.&lt;/p&gt;

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

&lt;h2&gt;
  
  
  Check 3: look for migrations and run them
&lt;/h2&gt;

&lt;p&gt;Open database/migrations. Good sign: files exist for the tables the panel needs, users, roles, settings, and the rest, and &lt;code&gt;php artisan migrate&lt;/code&gt; builds them on a throwaway database with no errors.&lt;/p&gt;

&lt;p&gt;Red flag: the setup guide starts with "import this SQL file", and no migrations ship. A dump ties your project to the seller's test data. A second mismatch: HTML screens only, with no migrations, sold under copy that calls the package a complete admin system. An HTML kit is fair when the listing sells it as one.&lt;/p&gt;

&lt;h2&gt;
  
  
  Check 4: seed the database and look at full pages
&lt;/h2&gt;

&lt;p&gt;Check database/seeders, then run &lt;code&gt;php artisan db:seed&lt;/code&gt;. Good sign: seeding creates a demo admin account, some users, and sample rows in the main tables, and the docs print the demo login.&lt;/p&gt;

&lt;p&gt;Red flag: no seeders ship at all. Every list page opens empty, so you cannot tell an empty table from a broken query, and the first day goes to typing test rows by hand.&lt;/p&gt;

&lt;h2&gt;
  
  
  Check 5: read the documentation before the code
&lt;/h2&gt;

&lt;p&gt;Read the install guide from the top. Good sign: it lists the server requirements, the install commands in order, a page list, and the first changes every buyer makes, adding a menu item, changing the logo or colors. The screenshots in the docs show the version the package installs.&lt;/p&gt;

&lt;p&gt;Red flag: the whole documentation is one short readme that ends at the install command. When setup fails at step three, a thin readme leaves you searching the web for an answer the seller should have written down.&lt;/p&gt;

&lt;h2&gt;
  
  
  Check 6: read composer.json and match it against your server
&lt;/h2&gt;

&lt;p&gt;Open composer.json and read the require section. It names the PHP version and the laravel/framework version the kit was built for. Laravel 11 and 12 both need PHP 8.2 or above. Run &lt;code&gt;php -v&lt;/code&gt; on your server, or read the version in your hosting panel, and compare before you pay.&lt;/p&gt;

&lt;p&gt;Good sign: the listing states the versions and composer.json agrees. Red flag: the listing says the kit works with the latest Laravel, and composer.json pins an old major version. Treat a missing composer.json the same way when the kit calls itself a Laravel package.&lt;/p&gt;

&lt;p&gt;Once the panel is in your app, the app still has to go online. My earlier post on putting a Laravel website online covers the server side: &lt;a href="https://dev.to/mehedirafi/how-to-put-a-laravel-website-online-step-by-step-3oif"&gt;https://dev.to/mehedirafi/how-to-put-a-laravel-website-online-step-by-step-3oif&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Check 7: find the licence and answer three questions from it
&lt;/h2&gt;

&lt;p&gt;Find the licence file in the package, or the terms on the listing, and answer three questions from the text. Can you use the template in a client project? How many projects does one purchase cover? Can you charge the client for the finished site?&lt;/p&gt;

&lt;p&gt;Good sign: the licence answers all three in plain lines. Red flag: no licence file exists anywhere, or the terms allow one personal project while the sales page shows the kit inside client work. Buyers skip this check more than any other, and it is the one that can turn a paid template into an argument with your own client.&lt;/p&gt;

&lt;h2&gt;
  
  
  Check 8: check the update history and the questions under the listing
&lt;/h2&gt;

&lt;p&gt;Find the changelog or the release dates. Good sign: a release within the last few months that fixes bugs or follows a Laravel release, and an update window stated in the price.&lt;/p&gt;

&lt;p&gt;Then read the public questions under the listing. Sellers who support their work answer in the open. Red flag: the last update landed two Laravel versions ago, and the newest questions sit unanswered with bug reports in them.&lt;/p&gt;

&lt;h2&gt;
  
  
  A 15 minute test when a live demo exists
&lt;/h2&gt;

&lt;p&gt;Work through the demo in this order. Sign in. Open every item in the menu and note any page that errors. Save one setting and check that it stays saved. Open an invoice page and print it. Create the low role account from Check 1 and revisit one admin page.&lt;/p&gt;

&lt;p&gt;When no demo exists, read the file list against the page list twice, then send the seller the two questions the listing leaves open. The reply tells you a lot about the support from Check 8 before money moves.&lt;/p&gt;

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

&lt;h2&gt;
  
  
  The same list, run on my own kit
&lt;/h2&gt;

&lt;p&gt;AdminForge is my own product, so read this part as a seller showing his work. The listing states 34 Blade files and names the main pages: login, roles, settings, and invoice pages. Check 1 and Check 2 tell you to open those pages and count those files against the claim.&lt;/p&gt;

&lt;p&gt;AdminForge is a UI kit, and you connect the Blade views to your own app. That puts the database checks from this list on your side: your migrations, your seeders, your data.&lt;/p&gt;

&lt;h2&gt;
  
  
  A score sheet you can reuse
&lt;/h2&gt;

&lt;p&gt;Copy these lines into a note and mark each pass or fail:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;A low role account is blocked from admin pages by the server&lt;/li&gt;
&lt;li&gt;Blade file count matches the page list on the sales page&lt;/li&gt;
&lt;li&gt;Migrations ship with the package and run clean on a test database&lt;/li&gt;
&lt;li&gt;Seeders fill the main tables, and the docs print the demo login&lt;/li&gt;
&lt;li&gt;Documentation covers install, the page list, and first changes&lt;/li&gt;
&lt;li&gt;composer.json versions match the listing and your server&lt;/li&gt;
&lt;li&gt;The licence allows client work and states the project count&lt;/li&gt;
&lt;li&gt;A recent release exists, and listing questions get answers&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;AdminForge is my own Blade admin kit. It has 34 Blade files, with login, roles, settings, and invoice pages. It is a UI kit, so you connect it to your own app. The listing says exactly what is inside: &lt;a href="https://mehedirafi.gumroad.com/l/adminforge" rel="noopener noreferrer"&gt;https://mehedirafi.gumroad.com/l/adminforge&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;I am Mehedi Mansur Rafi, a freelance Laravel developer (B.Sc. in Computer Science &amp;amp; Engineering). I build hospital, clinic, and small business websites. CarePoint Admin is my admin kit for clinic work: &lt;a href="https://mehedirafi.gumroad.com/l/carepoint-admin" rel="noopener noreferrer"&gt;https://mehedirafi.gumroad.com/l/carepoint-admin&lt;/a&gt;. My full store is at &lt;a href="https://mehedirafi.gumroad.com/" rel="noopener noreferrer"&gt;https://mehedirafi.gumroad.com/&lt;/a&gt; and my site is &lt;a href="https://mehedimansurrafi.online" rel="noopener noreferrer"&gt;https://mehedimansurrafi.online&lt;/a&gt;&lt;/p&gt;

</description>
      <category>laravel</category>
      <category>webdev</category>
      <category>beginners</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Build a clinic appointment page in Laravel, step by step</title>
      <dc:creator>Mehedi Mansur Rafi</dc:creator>
      <pubDate>Tue, 10 Nov 2026 13:04:34 +0000</pubDate>
      <link>https://dev.to/mehedirafi/build-a-clinic-appointment-page-in-laravel-step-by-step-4ohg</link>
      <guid>https://dev.to/mehedirafi/build-a-clinic-appointment-page-in-laravel-step-by-step-4ohg</guid>
      <description>&lt;p&gt;Part 1 of Build the Clinic.&lt;/p&gt;

&lt;p&gt;A small clinic does not need a large hospital system on day one. It needs a page where a patient can pick a doctor, choose a time, and leave a phone number, plus a simple list where staff can see who is coming tomorrow. I built that flow in Laravel for a demo clinic project, and this tutorial rebuilds it step by step. You will create the doctor and appointment tables, add a booking form with basic validation, and build an admin list with search by date. The code stays small on purpose. Nothing in the build needs a paid package, so you can follow it on a local setup. By the end you will have a working appointment page you can run locally, test with fake bookings, and change for a dental practice, a diagnostic centre, or a single doctor chamber without rewriting the whole thing.&lt;/p&gt;

&lt;p&gt;The build has 5 parts: two tables, one form, one confirmation page, and one staff list.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1: the doctors and appointments tables
&lt;/h2&gt;

&lt;p&gt;Every booking points at one doctor and one time slot, so the database needs two tables.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;php artisan make:model Doctor -m
php artisan make:model Appointment -m
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Doctors table:&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="nc"&gt;Schema&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="s1"&gt;'doctors'&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="nc"&gt;Blueprint&lt;/span&gt; &lt;span class="nv"&gt;$table&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nv"&gt;$table&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="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nv"&gt;$table&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'name'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nv"&gt;$table&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'specialty'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nv"&gt;$table&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'room'&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;nullable&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="nv"&gt;$table&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;boolean&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'is_active'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="k"&gt;default&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nv"&gt;$table&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;timestamps&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="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;Appointments table:&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="nc"&gt;Schema&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="s1"&gt;'appointments'&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="nc"&gt;Blueprint&lt;/span&gt; &lt;span class="nv"&gt;$table&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nv"&gt;$table&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="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nv"&gt;$table&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;foreignId&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'doctor_id'&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;constrained&lt;/span&gt;&lt;span class="p"&gt;(&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;cascadeOnDelete&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="nv"&gt;$table&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'patient_name'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nv"&gt;$table&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'patient_phone'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nv"&gt;$table&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;date&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'appointment_date'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nv"&gt;$table&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;time&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'starts_at'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nv"&gt;$table&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'reason'&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;nullable&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="nv"&gt;$table&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'reference'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;12&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;unique&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="nv"&gt;$table&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'status'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="k"&gt;default&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'booked'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nv"&gt;$table&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;timestamps&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="nv"&gt;$table&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;unique&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'doctor_id'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'appointment_date'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'starts_at'&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="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 last line matters. One doctor cannot hold two bookings at the same date and time. The form checks this rule in a friendly way in step 3, and this index is the hard stop behind it.&lt;/p&gt;

&lt;p&gt;The models:&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;// Doctor model&lt;/span&gt;
&lt;span class="k"&gt;protected&lt;/span&gt; &lt;span class="nv"&gt;$fillable&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'name'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'specialty'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'room'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'is_active'&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="nf"&gt;appointments&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;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;hasMany&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Appointment&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="k"&gt;class&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="c1"&gt;// Appointment model&lt;/span&gt;
&lt;span class="k"&gt;protected&lt;/span&gt; &lt;span class="nv"&gt;$fillable&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="s1"&gt;'doctor_id'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'patient_name'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'patient_phone'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s1"&gt;'appointment_date'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'starts_at'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'reason'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'reference'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'status'&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;protected&lt;/span&gt; &lt;span class="nv"&gt;$casts&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'appointment_date'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s1"&gt;'date'&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="nf"&gt;doctor&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;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;belongsTo&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Doctor&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="k"&gt;class&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;Run the migrations, then add two test doctors:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;php artisan migrate
php artisan tinker
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nc"&gt;Doctor&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="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'name'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s1"&gt;'Dr. Ayesha Karim'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'specialty'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s1"&gt;'Medicine'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'room'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s1"&gt;'204'&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="nc"&gt;Doctor&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="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'name'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s1"&gt;'Dr. Tanvir Hasan'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'specialty'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s1"&gt;'Cardiology'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'room'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s1"&gt;'310'&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;h2&gt;
  
  
  Step 2: routes and the booking form
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="c1"&gt;// routes/web.php&lt;/span&gt;
&lt;span class="nc"&gt;Route&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'/book'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nc"&gt;AppointmentController&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="k"&gt;class&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'create'&lt;/span&gt;&lt;span class="p"&gt;]&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;name&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'appointments.create'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nc"&gt;Route&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;post&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'/book'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nc"&gt;AppointmentController&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="k"&gt;class&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="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;name&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'appointments.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;Route&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'/booking/{reference}'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nc"&gt;AppointmentController&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="k"&gt;class&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'confirmation'&lt;/span&gt;&lt;span class="p"&gt;]&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;name&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'appointments.confirmation'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nc"&gt;Route&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'/staff/appointments'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nc"&gt;StaffAppointmentController&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="k"&gt;class&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'index'&lt;/span&gt;&lt;span class="p"&gt;]&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;name&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'staff.appointments'&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 controller holds the clinic hours as one slot list, used by the form and by validation:&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="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;AppointmentController&lt;/span&gt; &lt;span class="k"&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;private&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="no"&gt;SLOTS&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
        &lt;span class="s1"&gt;'09:00'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'09:30'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'10:00'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'10:30'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'11:00'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'11:30'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="s1"&gt;'14:00'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'14:30'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'15:00'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'15:30'&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="nf"&gt;create&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="nv"&gt;$doctors&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Doctor&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;where&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'is_active'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;true&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;orderBy&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'name'&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;get&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;return&lt;/span&gt; &lt;span class="nf"&gt;view&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'appointments.create'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
            &lt;span class="s1"&gt;'doctors'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nv"&gt;$doctors&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="s1"&gt;'slots'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="kt"&gt;self&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="no"&gt;SLOTS&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="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 form, in resources/views/appointments/create.blade.php. The date field carries a min attribute set to today. The server checks the same rule in step 3, because a browser setting can be bypassed:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;form method="POST" action="{{ route('appointments.store') }}"&amp;gt;
    @csrf

    &amp;lt;label&amp;gt;Doctor&amp;lt;/label&amp;gt;
    &amp;lt;select name="doctor_id" required&amp;gt;
        &amp;lt;option value=""&amp;gt;Choose a doctor&amp;lt;/option&amp;gt;
        @foreach ($doctors as $doctor)
            &amp;lt;option value="{{ $doctor-&amp;gt;id }}" @selected(old('doctor_id') == $doctor-&amp;gt;id)&amp;gt;
                {{ $doctor-&amp;gt;name }} - {{ $doctor-&amp;gt;specialty }}
            &amp;lt;/option&amp;gt;
        @endforeach
    &amp;lt;/select&amp;gt;
    @error('doctor_id') &amp;lt;p&amp;gt;{{ $message }}&amp;lt;/p&amp;gt; @enderror

    &amp;lt;label&amp;gt;Your name&amp;lt;/label&amp;gt;
    &amp;lt;input type="text" name="patient_name" value="{{ old('patient_name') }}" required&amp;gt;
    @error('patient_name') &amp;lt;p&amp;gt;{{ $message }}&amp;lt;/p&amp;gt; @enderror

    &amp;lt;label&amp;gt;Phone&amp;lt;/label&amp;gt;
    &amp;lt;input type="text" name="patient_phone" value="{{ old('patient_phone') }}" required&amp;gt;
    @error('patient_phone') &amp;lt;p&amp;gt;{{ $message }}&amp;lt;/p&amp;gt; @enderror

    &amp;lt;label&amp;gt;Date&amp;lt;/label&amp;gt;
    &amp;lt;input type="date" name="appointment_date" value="{{ old('appointment_date') }}"
           min="{{ now()-&amp;gt;toDateString() }}" required&amp;gt;
    @error('appointment_date') &amp;lt;p&amp;gt;{{ $message }}&amp;lt;/p&amp;gt; @enderror

    &amp;lt;label&amp;gt;Time&amp;lt;/label&amp;gt;
    &amp;lt;select name="starts_at" required&amp;gt;
        &amp;lt;option value=""&amp;gt;Choose a time&amp;lt;/option&amp;gt;
        @foreach ($slots as $slot)
            &amp;lt;option value="{{ $slot }}" @selected(old('starts_at') === $slot)&amp;gt;{{ $slot }}&amp;lt;/option&amp;gt;
        @endforeach
    &amp;lt;/select&amp;gt;
    @error('starts_at') &amp;lt;p&amp;gt;{{ $message }}&amp;lt;/p&amp;gt; @enderror

    &amp;lt;label&amp;gt;Reason for the visit (optional)&amp;lt;/label&amp;gt;
    &amp;lt;input type="text" name="reason" value="{{ old('reason') }}"&amp;gt;

    &amp;lt;button type="submit"&amp;gt;Book appointment&amp;lt;/button&amp;gt;
&amp;lt;/form&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;[SCREENSHOT: booking form in his CarePoint clinic demo, doctor list open]&lt;/p&gt;

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

&lt;h2&gt;
  
  
  Step 3: store the booking and block double booking
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="k"&gt;use&lt;/span&gt; &lt;span class="nc"&gt;Illuminate&lt;/span&gt;\&lt;span class="nc"&gt;Validation&lt;/span&gt;\&lt;span class="nc"&gt;Rule&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;use&lt;/span&gt; &lt;span class="nc"&gt;Illuminate&lt;/span&gt;\&lt;span class="nc"&gt;Support&lt;/span&gt;\&lt;span class="nc"&gt;Str&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="nf"&gt;store&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&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="p"&gt;{&lt;/span&gt;
    &lt;span class="nv"&gt;$data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$request&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;validate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;
        &lt;span class="s1"&gt;'doctor_id'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'required'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'exists:doctors,id'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="s1"&gt;'patient_name'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'required'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'string'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'max:80'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="s1"&gt;'patient_phone'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'required'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'string'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'max:20'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="s1"&gt;'appointment_date'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'required'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'date'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'after_or_equal:today'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="s1"&gt;'starts_at'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'required'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;Rule&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;in&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;self&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="no"&gt;SLOTS&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="s1"&gt;'reason'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'nullable'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'string'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'max:255'&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="p"&gt;;&lt;/span&gt;

    &lt;span class="nv"&gt;$taken&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Appointment&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;where&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'doctor_id'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$data&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'doctor_id'&lt;/span&gt;&lt;span class="p"&gt;]&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;whereDate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'appointment_date'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$data&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'appointment_date'&lt;/span&gt;&lt;span class="p"&gt;]&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;where&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'starts_at'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$data&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'starts_at'&lt;/span&gt;&lt;span class="p"&gt;]&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;where&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'status'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'booked'&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;exists&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;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$taken&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;back&lt;/span&gt;&lt;span class="p"&gt;(&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;withInput&lt;/span&gt;&lt;span class="p"&gt;(&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;withErrors&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;
            &lt;span class="s1"&gt;'starts_at'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s1"&gt;'That time is already booked with this doctor. Please pick another slot.'&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="p"&gt;}&lt;/span&gt;

    &lt;span class="nv"&gt;$data&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'reference'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'APT-'&lt;/span&gt; &lt;span class="p"&gt;.&lt;/span&gt; &lt;span class="nf"&gt;strtoupper&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Str&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;random&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;6&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="nv"&gt;$appointment&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Appointment&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="nv"&gt;$data&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;redirect&lt;/span&gt;&lt;span class="p"&gt;(&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;route&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'appointments.confirmation'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$appointment&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;reference&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="nf"&gt;confirmation&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="nv"&gt;$reference&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nv"&gt;$appointment&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Appointment&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;with&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'doctor'&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;where&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'reference'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$reference&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;firstOrFail&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;return&lt;/span&gt; &lt;span class="nf"&gt;view&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'appointments.confirmation'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'appointment'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nv"&gt;$appointment&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Read the order of the checks. Validation runs first, so a past date or a time outside clinic hours never reaches the database. The taken check runs second and keeps the form values, so the patient picks another slot instead of starting over. The unique index from step 1 sits behind both checks. If two patients submit the same slot in the same second, the database rejects the second write.&lt;/p&gt;

&lt;p&gt;The confirmation view can stay plain:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;h1&amp;gt;Booking confirmed&amp;lt;/h1&amp;gt;
&amp;lt;p&amp;gt;Your booking reference is &amp;lt;strong&amp;gt;{{ $appointment-&amp;gt;reference }}&amp;lt;/strong&amp;gt;&amp;lt;/p&amp;gt;
&amp;lt;p&amp;gt;{{ $appointment-&amp;gt;doctor-&amp;gt;name }} ({{ $appointment-&amp;gt;doctor-&amp;gt;specialty }})&amp;lt;/p&amp;gt;
&amp;lt;p&amp;gt;{{ $appointment-&amp;gt;appointment_date-&amp;gt;format('l, d M Y') }} at {{ $appointment-&amp;gt;starts_at }}&amp;lt;/p&amp;gt;
&amp;lt;p&amp;gt;Please arrive 10 minutes early and bring this reference with you.&amp;lt;/p&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The patient reads the reference over the phone when they call, and staff search by it. That one string removes most of the name confusion at a small clinic desk.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 4: the staff list for tomorrow
&lt;/h2&gt;

&lt;p&gt;Reception needs one screen in the morning: who is coming, in time order, with phone numbers. This page defaults to tomorrow and accepts a date and doctor filter:&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="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;StaffAppointmentController&lt;/span&gt; &lt;span class="k"&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="nf"&gt;index&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&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="p"&gt;{&lt;/span&gt;
        &lt;span class="nv"&gt;$date&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$request&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;input&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'date'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nf"&gt;now&lt;/span&gt;&lt;span class="p"&gt;(&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;addDay&lt;/span&gt;&lt;span class="p"&gt;(&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;toDateString&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="nv"&gt;$appointments&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Appointment&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;with&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'doctor'&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;whereDate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'appointment_date'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$date&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;when&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$request&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;filled&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'doctor_id'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                &lt;span class="k"&gt;fn&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$query&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nv"&gt;$query&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;where&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'doctor_id'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$request&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;doctor_id&lt;/span&gt;&lt;span class="p"&gt;)&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;orderBy&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'starts_at'&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;get&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="nv"&gt;$doctors&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Doctor&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;orderBy&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'name'&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;get&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;return&lt;/span&gt; &lt;span class="nf"&gt;view&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'staff.appointments.index'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
            &lt;span class="s1"&gt;'appointments'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nv"&gt;$appointments&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="s1"&gt;'doctors'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nv"&gt;$doctors&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="s1"&gt;'date'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nv"&gt;$date&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="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 view is a filter form and a table. The table is the part staff live in, so keep the columns short:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;table&amp;gt;
    &amp;lt;tr&amp;gt;
        &amp;lt;th&amp;gt;Time&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Patient&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Phone&amp;lt;/th&amp;gt;
        &amp;lt;th&amp;gt;Doctor&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Reference&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Status&amp;lt;/th&amp;gt;
    &amp;lt;/tr&amp;gt;
    @forelse ($appointments as $appointment)
        &amp;lt;tr&amp;gt;
            &amp;lt;td&amp;gt;{{ substr($appointment-&amp;gt;starts_at, 0, 5) }}&amp;lt;/td&amp;gt;
            &amp;lt;td&amp;gt;{{ $appointment-&amp;gt;patient_name }}&amp;lt;/td&amp;gt;
            &amp;lt;td&amp;gt;{{ $appointment-&amp;gt;patient_phone }}&amp;lt;/td&amp;gt;
            &amp;lt;td&amp;gt;{{ $appointment-&amp;gt;doctor-&amp;gt;name }}&amp;lt;/td&amp;gt;
            &amp;lt;td&amp;gt;{{ $appointment-&amp;gt;reference }}&amp;lt;/td&amp;gt;
            &amp;lt;td&amp;gt;{{ $appointment-&amp;gt;status }}&amp;lt;/td&amp;gt;
        &amp;lt;/tr&amp;gt;
    @empty
        &amp;lt;tr&amp;gt;&amp;lt;td colspan="6"&amp;gt;No appointments on this date.&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;
    @endforelse
&amp;lt;/table&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Put this route behind your staff login before the page goes anywhere near a live clinic. In my own clinic work the staff list sits inside the admin panel, and this public tutorial leaves the login out only to keep the code short.&lt;/p&gt;

&lt;p&gt;[SCREENSHOT: staff appointment list in his CarePoint clinic demo, one date]&lt;/p&gt;

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

&lt;h2&gt;
  
  
  Step 5: test the flow before you call it done
&lt;/h2&gt;

&lt;p&gt;Book 10 appointments through the form, by hand. Spread them across both doctors and three dates. Then run these checks:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Book one slot, then book the same doctor, date, and slot again. The second attempt must return with the "already booked" message, and the database must still hold one row for that slot.&lt;/li&gt;
&lt;li&gt;Pick a date in the past by editing the form value. Validation must reject it. The server rule is the test, not the min attribute.&lt;/li&gt;
&lt;li&gt;Open the staff list with no filter. It must show tomorrow, in time order.&lt;/li&gt;
&lt;li&gt;Filter the staff list by one doctor. The other doctor rows must disappear.&lt;/li&gt;
&lt;li&gt;Open a confirmation link, change one character in the reference, and reload. You should get a 404, which proves the reference lookup is exact.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If all 5 checks pass, the core flow is done: a patient can book, a double booking is blocked in two places, and staff can plan the next day from one screen.&lt;/p&gt;

&lt;h2&gt;
  
  
  What to add next
&lt;/h2&gt;

&lt;p&gt;Two additions cover most of what a growing clinic asks for next. An SMS reminder the evening before the appointment cuts missed visits. It needs a local SMS provider account and a queue job that sends one message per booking. A payment step at booking time needs a gateway account and a refund rule for clinic cancellations. Both sit on top of the tables you already built.&lt;/p&gt;

&lt;p&gt;When the page is ready to go online, my earlier tutorial on putting a Laravel website online, step by step, covers the deployment: &lt;a href="https://dev.to/mehedirafi/how-to-put-a-laravel-website-online-step-by-step-3oif"&gt;https://dev.to/mehedirafi/how-to-put-a-laravel-website-online-step-by-step-3oif&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The finished version
&lt;/h2&gt;

&lt;p&gt;The finished version of this project, with the admin screens already built, is CarePoint Clinic on my Gumroad store for $19. The tutorial above builds the core flow from scratch. The paid version saves you the admin work: &lt;a href="https://mehedirafi.gumroad.com/l/carepoint-clinic" rel="noopener noreferrer"&gt;https://mehedirafi.gumroad.com/l/carepoint-clinic&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;I am Mehedi Mansur Rafi, a freelance Laravel developer (B.Sc. in Computer Science &amp;amp; Engineering). I build hospital, clinic, and small business websites. My full store is at &lt;a href="https://mehedirafi.gumroad.com/" rel="noopener noreferrer"&gt;https://mehedirafi.gumroad.com/&lt;/a&gt; and my site is &lt;a href="https://mehedimansurrafi.online" rel="noopener noreferrer"&gt;https://mehedimansurrafi.online&lt;/a&gt;&lt;/p&gt;

</description>
      <category>laravel</category>
      <category>php</category>
      <category>tutorial</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Laravel returns 404 on every route after deployment. Here is the fix.</title>
      <dc:creator>Mehedi Mansur Rafi</dc:creator>
      <pubDate>Sat, 07 Nov 2026 13:19:13 +0000</pubDate>
      <link>https://dev.to/mehedirafi/laravel-returns-404-on-every-route-after-deployment-here-is-the-fix-34p3</link>
      <guid>https://dev.to/mehedirafi/laravel-returns-404-on-every-route-after-deployment-here-is-the-fix-34p3</guid>
      <description>&lt;p&gt;Part 3 of &lt;em&gt;Laravel in Production&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;You uploaded your Laravel project, the home page opens, and every other page shows 404. I have seen this exact fault on shared hosting, on a cloud server, and on my own laptop server. In most cases the code is fine. The server is looking in the wrong folder. Laravel expects requests to reach public/index.php. If the web root points at the project folder instead, the home page can load by luck while the rest fail, or the whole site breaks in a way that looks like a routing bug. I will also show the two log lines that tell you the server hit the wrong folder, so you can prove the cause. This tutorial walks through the check I run first, how to set the document root on cPanel and on a plain Apache or Nginx server, and how to confirm the fix in a private browser window before you touch any route file.&lt;/p&gt;

&lt;h2&gt;
  
  
  The 2 minute check
&lt;/h2&gt;

&lt;p&gt;Do not edit any code yet. Open two addresses in a private browser window:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Your home page: &lt;code&gt;https://your-site.com/&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;One inner route: &lt;code&gt;https://your-site.com/login&lt;/code&gt; (or any page that works on your laptop)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Then open a third address: &lt;code&gt;https://your-site.com/index.php/login&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The third address tells you almost everything:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;/index.php/login&lt;/code&gt; works, &lt;code&gt;/login&lt;/code&gt; shows 404&lt;/strong&gt; — your routes are fine. The server is not rewriting inner requests to &lt;code&gt;index.php&lt;/code&gt;. That is the &lt;code&gt;.htaccess&lt;/code&gt; / rewrite problem, covered in step 2 below.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Both fail, and the home page also fails or shows a folder listing&lt;/strong&gt; — the web root is pointing at the wrong folder. That is step 1.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Everything works in the private window&lt;/strong&gt; — you were logged in locally or your browser cached the old site. Log out, hard refresh, and test again before changing anything.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;One more piece of proof, from two logs. First open &lt;code&gt;storage/logs/laravel.log&lt;/code&gt;, then load the failing route again. If no new line appears in Laravel's log, Laravel never saw the request — the fault is in the server setup, not in your routes. Then check the web server's error log (on cPanel: &lt;strong&gt;Metrics&lt;/strong&gt;, then &lt;strong&gt;Errors&lt;/strong&gt;). A wrong web root leaves a line like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[error] [client 203.0.113.8] File does not exist: /home/youruser/public_html/login
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That path is the giveaway. The server looked for a real file called &lt;code&gt;login&lt;/code&gt; inside &lt;code&gt;public_html&lt;/code&gt;, found nothing, and answered 404 itself. It never passed the request to Laravel, so no route file edit will fix it.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fr2v6cvbn2dp0z8t974gv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fr2v6cvbn2dp0z8t974gv.png" alt="Laravel 404 error page on an inner route" width="800" height="500"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1: Point the web root at the public folder
&lt;/h2&gt;

&lt;p&gt;Laravel's only public folder is &lt;code&gt;public/&lt;/code&gt;. Every request has to enter through &lt;code&gt;public/index.php&lt;/code&gt;. If the server's document root is the project folder itself, the app is exposed in the wrong way and inner routes break.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;cPanel.&lt;/strong&gt; Go to &lt;strong&gt;Domains&lt;/strong&gt;, find your domain, and set the &lt;strong&gt;Document Root&lt;/strong&gt; to the &lt;code&gt;public&lt;/code&gt; folder inside your project, for example &lt;code&gt;/home/youruser/public_html/public&lt;/code&gt; if the project sits in &lt;code&gt;public_html&lt;/code&gt;. Two warnings from my own deploys:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Set the document root inside &lt;code&gt;public_html&lt;/code&gt; when you create the domain or subdomain. On some cPanel setups, a document root outside &lt;code&gt;public_html&lt;/code&gt; makes the server quietly ignore your &lt;code&gt;.htaccess&lt;/code&gt; file, and then every route 404s even though the file is correct.&lt;/li&gt;
&lt;li&gt;If your plan does not let you change the document root, use the shim method instead: copy &lt;code&gt;public/index.php&lt;/code&gt; and &lt;code&gt;public/.htaccess&lt;/code&gt; into &lt;code&gt;public_html&lt;/code&gt;, then edit the two paths in &lt;code&gt;index.php&lt;/code&gt; so they point at the real project folder:
&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;require&lt;/span&gt; &lt;span class="k"&gt;__DIR__&lt;/span&gt;&lt;span class="mf"&gt;.&lt;/span&gt;&lt;span class="s1"&gt;'/../project-folder/vendor/autoload.php'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nv"&gt;$app&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;require_once&lt;/span&gt; &lt;span class="k"&gt;__DIR__&lt;/span&gt;&lt;span class="mf"&gt;.&lt;/span&gt;&lt;span class="s1"&gt;'/../project-folder/bootstrap/app.php'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Plain Apache.&lt;/strong&gt; In the virtual host:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight apache"&gt;&lt;code&gt;&lt;span class="nc"&gt;DocumentRoot&lt;/span&gt; /var/www/your-app/public

&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nl"&gt;Directory&lt;/span&gt;&lt;span class="sr"&gt; /var/www/your-app/public&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;
&lt;/span&gt;    &lt;span class="nc"&gt;AllowOverride&lt;/span&gt; &lt;span class="ss"&gt;All&lt;/span&gt;
    &lt;span class="nc"&gt;Require&lt;/span&gt; &lt;span class="ss"&gt;all&lt;/span&gt; granted
&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nl"&gt;Directory&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;AllowOverride All&lt;/code&gt; matters: without it, Apache ignores the &lt;code&gt;.htaccess&lt;/code&gt; in step 2. Restart Apache after the change.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Nginx.&lt;/strong&gt; In the server block:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight nginx"&gt;&lt;code&gt;&lt;span class="k"&gt;root&lt;/span&gt; &lt;span class="n"&gt;/var/www/your-app/public&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;location&lt;/span&gt; &lt;span class="n"&gt;/&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kn"&gt;try_files&lt;/span&gt; &lt;span class="nv"&gt;$uri&lt;/span&gt; &lt;span class="nv"&gt;$uri&lt;/span&gt;&lt;span class="n"&gt;/&lt;/span&gt; &lt;span class="n"&gt;/index.php?&lt;/span&gt;&lt;span class="nv"&gt;$query_string&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;Reload Nginx, then repeat the 2 minute check.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2: Check .htaccess and index.php placement
&lt;/h2&gt;

&lt;p&gt;Inside &lt;code&gt;public/&lt;/code&gt; there must be two files: &lt;code&gt;index.php&lt;/code&gt; and &lt;code&gt;.htaccess&lt;/code&gt;. After an FTP upload, the &lt;code&gt;.htaccess&lt;/code&gt; is the file most often missing, because some FTP clients hide dotfiles. Turn on "show hidden files" in your client and check.&lt;/p&gt;

&lt;p&gt;The standard Laravel &lt;code&gt;.htaccess&lt;/code&gt; is short:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight apache"&gt;&lt;code&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nl"&gt;IfModule&lt;/span&gt;&lt;span class="sr"&gt; mod_rewrite.c&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;
&lt;/span&gt;    &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nl"&gt;IfModule&lt;/span&gt;&lt;span class="sr"&gt; mod_negotiation.c&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;
&lt;/span&gt;        &lt;span class="nc"&gt;Options&lt;/span&gt; -MultiViews -Indexes
    &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nl"&gt;IfModule&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;
&lt;/span&gt;
    &lt;span class="nc"&gt;RewriteEngine&lt;/span&gt; &lt;span class="ss"&gt;On&lt;/span&gt;

    &lt;span class="c"&gt;# Handle Authorization Header&lt;/span&gt;
    &lt;span class="nc"&gt;RewriteCond&lt;/span&gt; %{HTTP:Authorization} .
    &lt;span class="nc"&gt;RewriteRule&lt;/span&gt; .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

    &lt;span class="c"&gt;# Redirect Trailing Slashes If Not A Folder...&lt;/span&gt;
    &lt;span class="nc"&gt;RewriteCond&lt;/span&gt; %{REQUEST_FILENAME} !-d
    &lt;span class="nc"&gt;RewriteCond&lt;/span&gt; %{REQUEST_URI} (.+)/$
    &lt;span class="nc"&gt;RewriteRule&lt;/span&gt; ^ %1 [L,R=301]

    &lt;span class="c"&gt;# Send Requests To Front Controller...&lt;/span&gt;
    &lt;span class="nc"&gt;RewriteCond&lt;/span&gt; %{REQUEST_FILENAME} !-d
    &lt;span class="nc"&gt;RewriteCond&lt;/span&gt; %{REQUEST_FILENAME} !-f
    &lt;span class="nc"&gt;RewriteRule&lt;/span&gt; ^ index.php [L]
&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nl"&gt;IfModule&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Also check permissions. Folders should be &lt;code&gt;755&lt;/code&gt; and files &lt;code&gt;644&lt;/code&gt;. This sounds basic until it bites you: I have seen uploads land with files at &lt;code&gt;660&lt;/code&gt; and folders at &lt;code&gt;770&lt;/code&gt;, owned in a way the web server cannot read. The server then cannot read &lt;code&gt;.htaccess&lt;/code&gt; at all, the rewrite rules never apply, and every route 404s while the files look "present" in the file manager. If your static files (CSS, images) also return 404, permissions are the first suspect:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;find /var/www/your-app &lt;span class="nt"&gt;-type&lt;/span&gt; d &lt;span class="nt"&gt;-exec&lt;/span&gt; &lt;span class="nb"&gt;chmod &lt;/span&gt;755 &lt;span class="o"&gt;{}&lt;/span&gt; &lt;span class="se"&gt;\;&lt;/span&gt;
find /var/www/your-app &lt;span class="nt"&gt;-type&lt;/span&gt; f &lt;span class="nt"&gt;-exec&lt;/span&gt; &lt;span class="nb"&gt;chmod &lt;/span&gt;644 &lt;span class="o"&gt;{}&lt;/span&gt; &lt;span class="se"&gt;\;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;On shared hosting without SSH, fix permissions from the file manager, one folder at a time, or ask support to reset them.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fwjnxk6shkpt1ja93crco.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fwjnxk6shkpt1ja93crco.png" alt="Project folder showing public/index.php and .htaccess" width="800" height="500"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 3: Clear the cached routes and config
&lt;/h2&gt;

&lt;p&gt;Laravel caches routes and config into &lt;code&gt;bootstrap/cache/&lt;/code&gt;. If you uploaded a cache built on your laptop, the server can run routes from your local machine's paths. Clear it on the server:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;php artisan route:clear
php artisan config:clear
php artisan cache:clear
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;No SSH on your plan? Delete these files through the file manager and Laravel rebuilds them on the next request:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;bootstrap/cache/config.php
bootstrap/cache/routes-v7.php   (the name varies slightly by version)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With SSH, one more proof: &lt;code&gt;php artisan route:list&lt;/code&gt; should show the route you are testing. If the route is missing from that list, the problem is inside the app (see the last section). If it is listed and the document root is right, the server side is done.&lt;/p&gt;

&lt;p&gt;Then repeat the 2 minute check, logged out, in a private window. Testing while logged in hides this class of bug, because your session can carry you past a broken login route.&lt;/p&gt;

&lt;h2&gt;
  
  
  If the main fix fails: three less common causes
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;1. Wrong APP_URL.&lt;/strong&gt; Open &lt;code&gt;.env&lt;/code&gt; on the server and check &lt;code&gt;APP_URL&lt;/code&gt;. It should be the real address, for example &lt;code&gt;APP_URL=https://your-site.com&lt;/code&gt;. A wrong value usually does not 404 the page itself — it breaks the links, redirects, and asset URLs the app generates, which looks like random broken pages. Fix the value and run &lt;code&gt;php artisan config:clear&lt;/code&gt; again.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Case-sensitive file names.&lt;/strong&gt; Your laptop (Windows or macOS) does not care about letter case in file names. A Linux server does. If &lt;code&gt;routes/web.php&lt;/code&gt; calls &lt;code&gt;DashboardController&lt;/code&gt; but the uploaded file is &lt;code&gt;dashboardController.php&lt;/code&gt;, that one route fails on the server while it worked at home. Symptom to recognise: one or two routes fail, the rest work. Match the file name's case to the class name exactly.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. An incomplete upload.&lt;/strong&gt; If the upload stopped halfway, later routes in &lt;code&gt;routes/web.php&lt;/code&gt; or a controller file may simply not be on the server. The routes that did upload still work, and the missing ones return a real 404 — because as far as the server knows, they do not exist. Compare the file count and sizes in your FTP client on both sides, and re-upload anything that differs.&lt;/p&gt;

&lt;h2&gt;
  
  
  Deploy checklist: save this for next time
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Document root points at &lt;code&gt;public/&lt;/code&gt; (or the shim files are in place).&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;public/.htaccess&lt;/code&gt; exists on the server, and hidden files were shown during upload.&lt;/li&gt;
&lt;li&gt;Permissions: folders &lt;code&gt;755&lt;/code&gt;, files &lt;code&gt;644&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;route:clear&lt;/code&gt; and &lt;code&gt;config:clear&lt;/code&gt; run on the server after upload.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;APP_URL&lt;/code&gt; in the server &lt;code&gt;.env&lt;/code&gt; matches the real domain.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;route:list&lt;/code&gt; on the server shows the routes you are about to test.&lt;/li&gt;
&lt;li&gt;Test &lt;code&gt;/&lt;/code&gt;, one inner route, and &lt;code&gt;/index.php/that-route&lt;/code&gt; in a private window, logged out.&lt;/li&gt;
&lt;li&gt;Both logs checked once: Laravel's log for new lines, the server error log for &lt;code&gt;File does not exist&lt;/code&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If you are setting a Laravel site up from zero, my earlier walkthrough covers the full deployment in order: &lt;a href="https://dev.to/mehedirafi/how-to-put-a-laravel-website-online-step-by-step-3oif"&gt;How to put a Laravel website online, step by step&lt;/a&gt;.&lt;/p&gt;




&lt;p&gt;If your site is stuck on this error and you need it fixed today, I fix Laravel deployment errors through Upwork. Send me the error page and your hosting type and I will tell you the cost before I start: &lt;a href="https://www.upwork.com/freelancers/~0118ab607e0b4c599b" rel="noopener noreferrer"&gt;Upwork profile&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can also find my services on &lt;a href="https://www.fiverr.com/mehedi__rafi" rel="noopener noreferrer"&gt;Fiverr&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>laravel</category>
      <category>php</category>
      <category>webdev</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>The cheapest good way to host a small business website</title>
      <dc:creator>Mehedi Mansur Rafi</dc:creator>
      <pubDate>Wed, 04 Nov 2026 05:05:11 +0000</pubDate>
      <link>https://dev.to/mehedirafi/the-cheapest-good-way-to-host-a-small-business-website-53c1</link>
      <guid>https://dev.to/mehedirafi/the-cheapest-good-way-to-host-a-small-business-website-53c1</guid>
      <description>&lt;p&gt;Every small business owner I talk to asks the same question in a different way: "Where should I put my website so it stays online, loads fast, and does not eat money every month?"&lt;/p&gt;

&lt;p&gt;Cheap hosting is easy to find. Cheap hosting that is still good in year two is the real problem. This post walks through the two routes that make sense for a small business site, what each one actually costs you over time, and how to pick.&lt;/p&gt;

&lt;p&gt;A note before the details: some links in my posts may be affiliate links. I only write about services I have checked carefully, and I will say plainly when a recommendation is based on a provider's published terms rather than my own usage.&lt;/p&gt;

&lt;h2&gt;
  
  
  What a small business website actually needs
&lt;/h2&gt;

&lt;p&gt;Strip away the marketing pages and a business site needs five things:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;HTTPS (SSL)&lt;/strong&gt; — free at any decent host now. If a plan charges extra for SSL, walk away.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Backups you can restore&lt;/strong&gt; — not just "backups exist", but a button you can press to roll the site back.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A renewal price you can live with&lt;/strong&gt; — the first-term price is advertising. The renewal price is the real price.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Support that answers&lt;/strong&gt; — when your site is down before a workday, a slow ticket queue costs more than the hosting saved you.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Room for one step of growth&lt;/strong&gt; — a contact form today, a booking page or small shop next year, without migrating on day one.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Keep those five in mind and most "unlimited everything for $1" offers sort themselves out.&lt;/p&gt;

&lt;h2&gt;
  
  
  Route 1: Shared hosting (the budget route)
&lt;/h2&gt;

&lt;p&gt;Shared hosting means your site lives on a server with many other sites, and the provider manages everything: updates, security patches, the control panel. Hostinger is the name that comes up most in this category right now, and its published model is the standard one for budget shared hosting: a low introductory price when you pay for a long first term, then a higher renewal price afterwards.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Who it fits:&lt;/strong&gt; a brochure site, a blog, a portfolio, a small shop that is just starting. WordPress and simple PHP sites run fine here.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What to check before you buy:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The renewal price, not the banner price. Work out the cost over three years, not three months.&lt;/li&gt;
&lt;li&gt;How long the first term must be to get the low price. A 4-year commitment is a real decision, not a discount detail.&lt;/li&gt;
&lt;li&gt;Whether backups are included in the plan tier you picked, or only in the tier above.&lt;/li&gt;
&lt;li&gt;Whether business email is included or sold separately.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;The honest trade-off:&lt;/strong&gt; you give up control and some speed headroom, and in exchange you pay the least and manage almost nothing. For a site whose job is to be found and to look trustworthy, that trade is usually right.&lt;/p&gt;

&lt;h2&gt;
  
  
  Route 2: Managed cloud hosting (the growth route)
&lt;/h2&gt;

&lt;p&gt;A step up is a cloud server (a VPS) with a management layer on top. Cloudways is the example I use when explaining this route: you pick a cloud server from providers like DigitalOcean or Vultr, and their platform handles the server setup, updates, caching, and backups for a monthly fee on top of the server cost.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Who it fits:&lt;/strong&gt; a site that runs custom code (for example a Laravel application), a shop that is starting to sell seriously, or any site where slow loading directly costs orders.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What to check before you buy:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The total monthly number: platform fee plus server size. It is monthly, with no long commitment, which makes the real cost easier to see than an intro offer.&lt;/li&gt;
&lt;li&gt;Email is usually NOT included. Budget for a separate email service if the business needs mailboxes on the domain.&lt;/li&gt;
&lt;li&gt;Backups and staging (a safe copy of the site to test changes on) are the features you are really paying for. If you will never use staging, you may be paying for headroom you do not need yet.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;The honest trade-off:&lt;/strong&gt; it costs several times more than budget shared hosting, and in exchange you get speed, scaling, and tools that matter once the site earns money.&lt;/p&gt;

&lt;h2&gt;
  
  
  The costs people forget
&lt;/h2&gt;

&lt;p&gt;Whichever route you pick, these are the lines that surprise people later:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Renewal jumps.&lt;/strong&gt; A plan that starts at a few dollars a month can renew at two or three times that. Put the renewal date and price in your calendar the day you buy.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Domain privacy and renewals.&lt;/strong&gt; The domain itself renews every year, and privacy protection is worth having.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Your own hours.&lt;/strong&gt; The cheapest plan that takes you a weekend to fix is not cheap. Price your time honestly.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Migration pain.&lt;/strong&gt; Leaving a host is easiest before you need to. Keep your own copy of the site's files and database from day one, outside the host.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  A simple way to decide
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Your site is pages, photos, a contact form, maybe a small shop starting out → &lt;strong&gt;shared hosting&lt;/strong&gt; (route 1). Spend the savings on a good design and your Google Business Profile.&lt;/li&gt;
&lt;li&gt;Your site runs an application, takes bookings or payments you depend on, or you expect real growth this year → &lt;strong&gt;managed cloud&lt;/strong&gt; (route 2). The monthly cost is a business expense, and downtime is the expensive option.&lt;/li&gt;
&lt;li&gt;You are not sure → start on route 1 with a short enough term that changing your mind is painless, and move up when the site gives you a reason. Moving a simple site is a routine job; I wrote up the general shape of putting a site online in my previous post.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  If you would rather hand this over
&lt;/h2&gt;

&lt;p&gt;Choosing the host is the easy part. Setting the site up cleanly, connecting the domain, and keeping it updated is the ongoing work. If you want help with that, I take small website jobs and monthly care work through Upwork and Fiverr — the links are on my profile here. Tell me what the site needs to do, and I will tell you honestly which of the two routes above it belongs on, including when the answer is the cheaper one.&lt;/p&gt;

</description>
      <category>webdevbegintutorialners</category>
    </item>
    <item>
      <title>How to put a Laravel website online, step by step</title>
      <dc:creator>Mehedi Mansur Rafi</dc:creator>
      <pubDate>Wed, 04 Nov 2026 03:39:00 +0000</pubDate>
      <link>https://dev.to/mehedirafi/how-to-put-a-laravel-website-online-step-by-step-3oif</link>
      <guid>https://dev.to/mehedirafi/how-to-put-a-laravel-website-online-step-by-step-3oif</guid>
      <description>&lt;p&gt;&lt;em&gt;Disclosure: some links in this post may be affiliate links. If you buy hosting&lt;br&gt;
through one of them, I earn a commission and you pay the same price. I only&lt;br&gt;
link to services I would use for my own projects.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;A Laravel app that runs on your laptop is not finished. It is finished when a&lt;br&gt;
stranger can open it in a browser. This is the full path I use when I deploy&lt;br&gt;
Laravel projects for myself and for clients, written in the order I actually&lt;br&gt;
do the work.&lt;/p&gt;
&lt;h2&gt;
  
  
  What you need before you start
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;A domain name. Any registrar works.&lt;/li&gt;
&lt;li&gt;A server or hosting account that runs PHP 8.2 or newer and MySQL.&lt;/li&gt;
&lt;li&gt;Your Laravel project in a Git repository, or as a clean zip without
&lt;code&gt;vendor/&lt;/code&gt; and &lt;code&gt;node_modules/&lt;/code&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;For a small Laravel site you have two sane choices. Shared hosting is cheap&lt;br&gt;
and fine for low traffic, but you get no SSH on most plans, and that makes&lt;br&gt;
Laravel painful. A managed cloud server costs a bit more and removes most of&lt;br&gt;
that pain. This walkthrough uses Cloudways, because it gives you a real&lt;br&gt;
server with SSH, Git deployment and SSL handled, without making you&lt;br&gt;
administer the machine itself. Their plans are listed at&lt;br&gt;
&lt;a href="https://www.cloudways.com/en/?id=2224301" rel="noopener noreferrer"&gt;https://www.cloudways.com/en/?id=2224301&lt;/a&gt; (plain link).&lt;/p&gt;
&lt;h2&gt;
  
  
  Step 1: Create the server and the application
&lt;/h2&gt;

&lt;p&gt;In Cloudways, launch a server (DigitalOcean or Vultr, 1–2 GB RAM is enough&lt;br&gt;
for a small app), then add an application and choose "Custom PHP App" or the&lt;br&gt;
Laravel option if it is offered. Cloudways creates the database, the SFTP&lt;br&gt;
user and the folder structure for you. Write down three things: the server&lt;br&gt;
IP, the application public path (it ends in &lt;code&gt;public_html&lt;/code&gt;), and the database&lt;br&gt;
name, user and password from the application's Access Details page.&lt;/p&gt;
&lt;h2&gt;
  
  
  Step 2: Get your code onto the server
&lt;/h2&gt;

&lt;p&gt;Two ways work well:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Git:&lt;/strong&gt; add the server as a deployment target and pull your repository
into the application folder. Best if you deploy often.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Upload:&lt;/strong&gt; zip your project locally (without &lt;code&gt;vendor/&lt;/code&gt;), upload it through
SFTP or the file manager, extract it into the application folder, then run
&lt;code&gt;composer install&lt;/code&gt; over SSH.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;After the code is there, run these once:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;composer &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;--no-dev&lt;/span&gt; &lt;span class="nt"&gt;--optimize-autoloader&lt;/span&gt;
&lt;span class="nb"&gt;cp&lt;/span&gt; .env.example .env
php artisan key:generate
php artisan storage:link
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 3: Point the web root at the &lt;code&gt;public&lt;/code&gt; folder
&lt;/h2&gt;

&lt;p&gt;This is the step people skip, and then every route returns 404. Laravel's&lt;br&gt;
entry point is &lt;code&gt;public/index.php&lt;/code&gt;. The web server must serve the &lt;code&gt;public&lt;/code&gt;&lt;br&gt;
folder, not the project root. On Cloudways the application already serves&lt;br&gt;
from &lt;code&gt;public_html&lt;/code&gt;, so make sure your project root sits in &lt;code&gt;public_html&lt;/code&gt; and&lt;br&gt;
that &lt;code&gt;public_html/public&lt;/code&gt; is not an extra nested level. On shared hosting,&lt;br&gt;
create the subdomain or addon domain with its document root ending in&lt;br&gt;
&lt;code&gt;/public&lt;/code&gt;. If you get this wrong, no &lt;code&gt;.htaccess&lt;/code&gt; trick will save you.&lt;/p&gt;
&lt;h2&gt;
  
  
  Step 4: Fill in &lt;code&gt;.env&lt;/code&gt; for production
&lt;/h2&gt;

&lt;p&gt;Open &lt;code&gt;.env&lt;/code&gt; on the server and set the values that matter:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight conf"&gt;&lt;code&gt;&lt;span class="n"&gt;APP_ENV&lt;/span&gt;=&lt;span class="n"&gt;production&lt;/span&gt;
&lt;span class="n"&gt;APP_DEBUG&lt;/span&gt;=&lt;span class="n"&gt;false&lt;/span&gt;
&lt;span class="n"&gt;APP_URL&lt;/span&gt;=&lt;span class="n"&gt;https&lt;/span&gt;://&lt;span class="n"&gt;yourdomain&lt;/span&gt;.&lt;span class="n"&gt;com&lt;/span&gt;
&lt;span class="n"&gt;DB_DATABASE&lt;/span&gt;=&lt;span class="n"&gt;your_database_name&lt;/span&gt;
&lt;span class="n"&gt;DB_USERNAME&lt;/span&gt;=&lt;span class="n"&gt;your_database_user&lt;/span&gt;
&lt;span class="n"&gt;DB_PASSWORD&lt;/span&gt;=&lt;span class="n"&gt;your_database_password&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;APP_DEBUG=false&lt;/code&gt; is not decoration. With debug on, an error page shows your&lt;br&gt;
file paths, your environment values and parts of your code to anyone who&lt;br&gt;
triggers an error. Turn it off before the site is public, every time.&lt;/p&gt;

&lt;p&gt;Then:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;php artisan config:cache
php artisan route:cache
php artisan view:cache
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 5: Create the database tables
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;php artisan migrate &lt;span class="nt"&gt;--force&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;--force&lt;/code&gt; is required in production; without it Artisan asks for confirmation&lt;br&gt;
and your deployment script hangs. If your host gives you no SSH and no&lt;br&gt;
Artisan, export the SQL from your local database and import it through&lt;br&gt;
phpMyAdmin instead. It is slower and easier to get wrong, which is one more&lt;br&gt;
reason to pick hosting with SSH.&lt;/p&gt;
&lt;h2&gt;
  
  
  Step 6: Fix file permissions
&lt;/h2&gt;

&lt;p&gt;Uploads made through a file manager often land with permissions the web&lt;br&gt;
server cannot read. The symptom is a white page or a 500 error right after a&lt;br&gt;
"successful" upload. The fix:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Files: &lt;code&gt;644&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Folders: &lt;code&gt;755&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;storage/&lt;/code&gt; and &lt;code&gt;bootstrap/cache/&lt;/code&gt; must be writable by the web server.
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;chmod&lt;/span&gt; &lt;span class="nt"&gt;-R&lt;/span&gt; 755 storage bootstrap/cache
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h2&gt;
  
  
  Step 7: Connect the domain and turn on SSL
&lt;/h2&gt;

&lt;p&gt;Point your domain's A record to the server IP. In Cloudways, add the domain&lt;br&gt;
under Domain Management for the application, then issue the free Let's&lt;br&gt;
Encrypt certificate from the SSL page. Wait for DNS to spread (a few minutes&lt;br&gt;
to a few hours), then open the site with &lt;code&gt;https://&lt;/code&gt; and check that the padlock&lt;br&gt;
shows and no page element still loads over plain &lt;code&gt;http://&lt;/code&gt;.&lt;/p&gt;
&lt;h2&gt;
  
  
  Step 8: Add the scheduler and queues
&lt;/h2&gt;

&lt;p&gt;Laravel's scheduler needs one cron line on the server:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="k"&gt;*&lt;/span&gt; &lt;span class="k"&gt;*&lt;/span&gt; &lt;span class="k"&gt;*&lt;/span&gt; &lt;span class="k"&gt;*&lt;/span&gt; &lt;span class="k"&gt;*&lt;/span&gt; &lt;span class="nb"&gt;cd&lt;/span&gt; /path-to-your-app &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; php artisan schedule:run &lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; /dev/null 2&amp;gt;&amp;amp;1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Cloudways lets you add this from the application's Cron Job Management page.&lt;br&gt;
If your app sends mail or does slow work in queues, run a queue worker under&lt;br&gt;
a supervisor (Cloudways has one built in) instead of letting requests wait:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;php artisan queue:work &lt;span class="nt"&gt;--tries&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;3
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 9: Test like a visitor, not like the developer
&lt;/h2&gt;

&lt;p&gt;Open the site in a private browser window. Register an account. Log out and&lt;br&gt;
back in. Submit every form. Upload a file if your app takes uploads. Then&lt;br&gt;
check on your phone. I test this way because the developer session hides&lt;br&gt;
bugs: you are logged in as admin, your browser has cached assets, and your&lt;br&gt;
&lt;code&gt;.env&lt;/code&gt; mistakes only show for guests. Half the deployment bugs I have fixed&lt;br&gt;
for clients were invisible from the developer's own chair.&lt;/p&gt;

&lt;h2&gt;
  
  
  The short checklist
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Code on the server, &lt;code&gt;composer install --no-dev&lt;/code&gt; done.&lt;/li&gt;
&lt;li&gt;Web root points at &lt;code&gt;public&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;.env&lt;/code&gt; set, &lt;code&gt;APP_DEBUG=false&lt;/code&gt;, key generated.&lt;/li&gt;
&lt;li&gt;Database migrated.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;storage/&lt;/code&gt; writable, permissions sane.&lt;/li&gt;
&lt;li&gt;Domain connected, SSL on.&lt;/li&gt;
&lt;li&gt;Scheduler cron added.&lt;/li&gt;
&lt;li&gt;Tested logged-out, on desktop and on a phone.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Do those eight and your Laravel site is online in a way that stays online.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;I deploy and maintain Laravel websites for small businesses. If your site is&lt;br&gt;
stuck on one of these steps, or you want someone to look after updates,&lt;br&gt;
backups and fixes every month, you can hire me on&lt;br&gt;
&lt;a href="https://www.upwork.com/freelancers/~0118ab607e0b4c599b" rel="noopener noreferrer"&gt;Upwork&lt;/a&gt; or&lt;br&gt;
&lt;a href="https://www.fiverr.com/mehedi__rafi" rel="noopener noreferrer"&gt;Fiverr&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>laravelphpwetutorialbdev</category>
    </item>
  </channel>
</rss>
