CINXE.COM

Laravel Bootcamp

<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>Laravel Bootcamp</title> <!-- Primary Meta Tags --> <meta name="title" content="Laravel Bootcamp - Learn the PHP Framework for Web Artisans"> <meta name="description" content="Together let's walk through building and deploying a modern Laravel application from scratch."> <!-- Open Graph / Facebook --> <meta property="og:type" content="website"> <meta property="og:url" content="https://bootcamp.laravel.com/"> <meta property="og:title" content="Laravel Bootcamp - Learn the PHP Framework for Web Artisans"> <meta property="og:description" content="Together let's walk through building and deploying a modern Laravel application from scratch."> <meta property="og:image" content="https://bootcamp.laravel.com/img/og-image.jpg"> <!-- Twitter --> <meta property="twitter:card" content="summary_large_image"> <meta property="twitter:url" content="https://bootcamp.laravel.com/"> <meta property="twitter:title" content="Laravel - Learn the PHP Framework for Web Artisans"> <meta property="twitter:description" content="Together let's walk through building and deploying a modern Laravel application from scratch."> <meta property="twitter:image" content="https://bootcamp.laravel.com/img/og-image.jpg"> <!-- Favicon --> <link rel="apple-touch-icon" sizes="180x180" href="/img/favicon/apple-touch-icon.png"> <link rel="icon" type="image/png" sizes="32x32" href="/img/favicon/favicon-32x32.png"> <link rel="icon" type="image/png" sizes="16x16" href="/img/favicon/favicon-16x16.png"> <link rel="manifest" href="/img/favicon/site.webmanifest"> <link rel="mask-icon" href="/img/favicon/safari-pinned-tab.svg" color="#ff2d20"> <link rel="shortcut icon" href="/img/favicon/favicon.ico"> <meta name="msapplication-TileColor" content="#ff2d20"> <meta name="msapplication-config" content="/img/favicon/browserconfig.xml"> <meta name="theme-color" content="#ffffff"> <meta name="color-scheme" content="light"> <!-- Fonts --> <link rel="stylesheet" href="https://use.typekit.net/ins2wgm.css"> <!-- Scripts & Styles --> <link rel="stylesheet" href="https://bootcamp.laravel.com/build/assets/app.1fe37668.css" /><script type="module" src="https://bootcamp.laravel.com/build/assets/app.f1116ac0.js"></script> <!-- Fathom - beautiful, simple website analytics --> <script src="https://cdn.usefathom.com/script.js" data-site="KRRQTWHM" defer></script> <!-- / Fathom --> <script> window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', e => { if (localStorage.theme === 'system') { if (e.matches) { document.documentElement.classList.add('dark'); } else { document.documentElement.classList.remove('dark'); } } }); function updateTheme() { if (!('theme' in localStorage)) { localStorage.theme = 'system'; } switch (localStorage.theme) { case 'system': if (window.matchMedia('(prefers-color-scheme: dark)').matches) { document.documentElement.classList.add('dark'); } else { document.documentElement.classList.remove('dark'); } document.documentElement.setAttribute('color-theme', 'system'); break; case 'dark': document.documentElement.classList.add('dark'); document.documentElement.setAttribute('color-theme', 'dark'); break; case 'light': document.documentElement.classList.remove('dark'); document.documentElement.setAttribute('color-theme', 'light'); break; } } updateTheme(); </script> </head> <body x-data="{ navIsOpen: false }" class="font-sans text-gray-900 antialiased" > <a id="skip-to-content-link" href="#main-content" class="absolute bg-gray-100 px-4 py-2 top-3 left-3 text-gray-700 shadow-xl" > Skip to content </a> <div class="min-h-screen dark:bg-dark-700"> <div class="relative lg:flex lg:items-start"> <aside id="sidebar" class="min-h-screen hidden fixed top-0 bottom-0 left-0 z-20 h-full w-16 bg-gradient-to-b from-gray-100 to-white transition-all duration-300 overflow-hidden lg:sticky lg:w-80 lg:shrink-0 lg:flex lg:flex-col lg:justify-end lg:items-end 2xl:max-w-lg 2xl:w-full dark:from-dark-800 dark:to-dark-700" > <div class="relative min-h-0 flex-1 flex flex-col xl:w-80"> <a href="/" class="flex items-center py-8 px-4 lg:px-8 xl:px-16"> <img class="w-8 h-8 shrink-0 transition-all duration-300 lg:w-12 lg:h-12" :class="{ 'w-12 h-12': navIsOpen }" src="/img/logomark.min.svg" alt="Laravel" width="50" height="52" > <span class="hidden lg:block ml-4 text-red-500 text-3xl font-medium">Bootcamp</span> </a> <div class="overflow-y-auto overflow-x-hidden px-4 lg:overflow-hidden lg:px-8 xl:px-16"> <nav id="indexed-nav" class="hidden lg:block lg:mt-4"> <div class="docs_sidebar"> <ul> <li> <h2><a id="introduction" href="#introduction" class="heading-permalink" aria-hidden="true" title="Permalink">#</a><a href="/introduction">Introduction</a></h2> </li> <li> <h2><a id="build-chirper-with-blade" href="#build-chirper-with-blade" class="heading-permalink" aria-hidden="true" title="Permalink">#</a>Build Chirper with Blade</h2> <ul> <li> <a href="/blade/installation">Installation</a> </li> <li> <a href="/blade/creating-chirps">Creating Chirps</a> </li> <li> <a href="/blade/showing-chirps">Showing Chirps</a> </li> <li> <a href="/blade/editing-chirps">Editing Chirps</a> </li> <li> <a href="/blade/deleting-chirps">Deleting Chirps</a> </li> <li> <a href="/blade/notifications-and-events">Notifications &amp; Events</a> </li> </ul> </li> <li> <h2><a id="build-chirper-with-livewire" href="#build-chirper-with-livewire" class="heading-permalink" aria-hidden="true" title="Permalink">#</a>Build Chirper with Livewire</h2> <ul> <li> <a href="/livewire/installation">Installation</a> </li> <li> <a href="/livewire/creating-chirps">Creating Chirps</a> </li> <li> <a href="/livewire/showing-chirps">Showing Chirps</a> </li> <li> <a href="/livewire/editing-chirps">Editing Chirps</a> </li> <li> <a href="/livewire/deleting-chirps">Deleting Chirps</a> </li> <li> <a href="/livewire/notifications-and-events">Notifications &amp; Events</a> </li> </ul> </li> <li> <h2><a id="build-chirper-with-inertia" href="#build-chirper-with-inertia" class="heading-permalink" aria-hidden="true" title="Permalink">#</a>Build Chirper with Inertia</h2> <ul> <li> <a href="/inertia/installation">Installation</a> </li> <li> <a href="/inertia/creating-chirps">Creating Chirps</a> </li> <li> <a href="/inertia/showing-chirps">Showing Chirps</a> </li> <li> <a href="/inertia/editing-chirps">Editing Chirps</a> </li> <li> <a href="/inertia/deleting-chirps">Deleting Chirps</a> </li> <li> <a href="/inertia/notifications-and-events">Notifications &amp; Events</a> </li> </ul> </li> <li> <h2><a id="deploying" href="#deploying" class="heading-permalink" aria-hidden="true" title="Permalink">#</a><a href="/deploying">Deploying</a></h2> </li> <li> <h2><a id="conclusion" href="#conclusion" class="heading-permalink" aria-hidden="true" title="Permalink">#</a><a href="/conclusion">Conclusion</a></h2> </li> </ul> </div> </nav> </div> <div class="flex-grow flex flex-col justify-end"> <div class="hidden 2xl:block mb-12 pl-16"> <svg x-data="{ initializeAnimation: false, init() { setTimeout(() => { this.initializeAnimation = true; }, 0); }, }" :class="initializeAnimation ? 'animate-cube' : ''" class="text-red-600 ml-8" width="46" height="53" viewBox="0 0 46 53" fill="none" xmlns="http://www.w3.org/2000/svg" > <path d="m23.102 1 22.1 12.704v25.404M23.101 1l-22.1 12.704v25.404" stroke="currentColor" stroke-width="1.435" stroke-linejoin="bevel"/><path d="m45.202 39.105-22.1 12.702L1 39.105" stroke="currentColor" stroke-width="1.435" stroke-linejoin="bevel"/><path transform="matrix(.86698 .49834 .00003 1 1 13.699)" stroke="currentColor" stroke-width="1.435" stroke-linejoin="bevel" d="M0 0h25.491v25.405H0z"/><path transform="matrix(.86698 -.49834 -.00003 1 23.102 26.402)" stroke="currentColor" stroke-width="1.435" stroke-linejoin="bevel" d="M0 0h25.491v25.405H0z"/><path transform="matrix(.86701 -.49829 .86701 .49829 1 13.702)" stroke="currentColor" stroke-width="1.435" stroke-linejoin="bevel" d="M0 0h25.491v25.491H0z"/> </svg> <svg x-data="{ initializeAnimation: false, init() { setTimeout(() => { this.initializeAnimation = true; }, 2000); }, }" :class="initializeAnimation ? 'animate-cube' : ''" class="text-red-600 mt-6 ml-32" width="46" height="53" viewBox="0 0 46 53" fill="none" xmlns="http://www.w3.org/2000/svg" > <path d="m23.102 1 22.1 12.704v25.404M23.101 1l-22.1 12.704v25.404" stroke="currentColor" stroke-width="1.435" stroke-linejoin="bevel"/><path d="m45.202 39.105-22.1 12.702L1 39.105" stroke="currentColor" stroke-width="1.435" stroke-linejoin="bevel"/><path transform="matrix(.86698 .49834 .00003 1 1 13.699)" stroke="currentColor" stroke-width="1.435" stroke-linejoin="bevel" d="M0 0h25.491v25.405H0z"/><path transform="matrix(.86698 -.49834 -.00003 1 23.102 26.402)" stroke="currentColor" stroke-width="1.435" stroke-linejoin="bevel" d="M0 0h25.491v25.405H0z"/><path transform="matrix(.86701 -.49829 .86701 .49829 1 13.702)" stroke="currentColor" stroke-width="1.435" stroke-linejoin="bevel" d="M0 0h25.491v25.491H0z"/> </svg> <svg x-data="{ initializeAnimation: false, init() { setTimeout(() => { this.initializeAnimation = true; }, 1000); }, }" :class="initializeAnimation ? 'animate-cube' : ''" class="text-red-600 mt-12" width="46" height="53" viewBox="0 0 46 53" fill="none" xmlns="http://www.w3.org/2000/svg" > <path d="m23.102 1 22.1 12.704v25.404M23.101 1l-22.1 12.704v25.404" stroke="currentColor" stroke-width="1.435" stroke-linejoin="bevel"/><path d="m45.202 39.105-22.1 12.702L1 39.105" stroke="currentColor" stroke-width="1.435" stroke-linejoin="bevel"/><path transform="matrix(.86698 .49834 .00003 1 1 13.699)" stroke="currentColor" stroke-width="1.435" stroke-linejoin="bevel" d="M0 0h25.491v25.405H0z"/><path transform="matrix(.86698 -.49834 -.00003 1 23.102 26.402)" stroke="currentColor" stroke-width="1.435" stroke-linejoin="bevel" d="M0 0h25.491v25.405H0z"/><path transform="matrix(.86701 -.49829 .86701 .49829 1 13.702)" stroke="currentColor" stroke-width="1.435" stroke-linejoin="bevel" d="M0 0h25.491v25.491H0z"/> </svg> </div> </div> </div> </aside> <header id="header" class="lg:hidden" @keydown.window.escape="navIsOpen = false" @click.away="navIsOpen = false" > <div class="relative mx-auto w-full py-10 bg-white transition duration-200 dark:bg-dark-700"> <div class="mx-auto px-8 sm:px-16 flex items-center justify-between"> <a href="/" class="flex items-center"> <img class="" src="/img/logomark.min.svg" alt="Laravel"> <span class="hidden sm:block ml-5 text-red-500 text-3xl font-medium">Bootcamp</span> </a> <div class="flex-1 flex items-center justify-end"> <button id="header__sun" onclick="toSystemMode()" title="Switch to system theme" class="relative w-10 h-10 focus:outline-none focus:shadow-outline text-gray-500"> <svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-sun" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"> <path stroke="none" d="M0 0h24v24H0z" fill="none"></path> <circle cx="12" cy="12" r="4"></circle> <path d="M3 12h1m8 -9v1m8 8h1m-9 8v1m-6.4 -15.4l.7 .7m12.1 -.7l-.7 .7m0 11.4l.7 .7m-12.1 -.7l-.7 .7"></path> </svg> </button> <button id="header__moon" onclick="toLightMode()" title="Switch to light mode" class="relative w-10 h-10 focus:outline-none focus:shadow-outline text-gray-500"> <svg style="width:24px;height:24px" viewBox="0 0 24 24"> <path fill="currentColor" d="M17.75,4.09L15.22,6.03L16.13,9.09L13.5,7.28L10.87,9.09L11.78,6.03L9.25,4.09L12.44,4L13.5,1L14.56,4L17.75,4.09M21.25,11L19.61,12.25L20.2,14.23L18.5,13.06L16.8,14.23L17.39,12.25L15.75,11L17.81,10.95L18.5,9L19.19,10.95L21.25,11M18.97,15.95C19.8,15.87 20.69,17.05 20.16,17.8C19.84,18.25 19.5,18.67 19.08,19.07C15.17,23 8.84,23 4.94,19.07C1.03,15.17 1.03,8.83 4.94,4.93C5.34,4.53 5.76,4.17 6.21,3.85C6.96,3.32 8.14,4.21 8.06,5.04C7.79,7.9 8.75,10.87 10.95,13.06C13.14,15.26 16.1,16.22 18.97,15.95M17.33,17.97C14.5,17.81 11.7,16.64 9.53,14.5C7.36,12.31 6.2,9.5 6.04,6.68C3.23,9.82 3.34,14.64 6.35,17.66C9.37,20.67 14.19,20.78 17.33,17.97Z" /> </svg> </button> <button id="header__indeterminate" onclick="toDarkMode()" title="Switch to dark mode" class="relative w-10 h-10 focus:outline-none focus:shadow-outline text-gray-500"> <svg style="width:24px;height:24px" viewBox="0 0 24 24"> <path fill="currentColor" d="M12 2A10 10 0 0 0 2 12A10 10 0 0 0 12 22A10 10 0 0 0 22 12A10 10 0 0 0 12 2M12 4A8 8 0 0 1 20 12A8 8 0 0 1 12 20V4Z" /> </svg> </button> <button class="ml-2 relative w-10 h-10 p-2 text-red-600 lg:hidden focus:outline-none focus:shadow-outline" aria-label="Menu" @click.prevent="navIsOpen = !navIsOpen"> <svg x-show="! navIsOpen" x-transition.opacity class="absolute inset-0 mt-2 ml-2 w-6 h-6" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2" fill="none" stroke-linecap="round" stroke-linejoin="round"><line x1="3" y1="12" x2="21" y2="12"></line><line x1="3" y1="6" x2="21" y2="6"></line><line x1="3" y1="18" x2="21" y2="18"></line></svg> <svg x-show="navIsOpen" x-transition.opacity x-cloak class="absolute inset-0 mt-2 ml-2 w-6 h-6" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2" fill="none" stroke-linecap="round" stroke-linejoin="round"><line x1="18" y1="6" x2="6" y2="18"></line><line x1="6" y1="6" x2="18" y2="18"></line></svg> </button> </div> </div> <span :class="{ 'shadow-sm': navIsOpen }" class="absolute inset-0 z-20 pointer-events-none"></span> </div> <div x-show="navIsOpen" x-transition:enter="duration-150" x-transition:leave="duration-100 ease-in" x-cloak > <nav x-show="navIsOpen" x-cloak class="absolute w-full transform origin-top shadow-sm z-10" x-transition:enter="duration-150 ease-out" x-transition:enter-start="opacity-0 -translate-y-8 scale-75" x-transition:enter-end="opacity-100 scale-100" x-transition:leave="duration-100 ease-in" x-transition:leave-start="opacity-100 scale-100" x-transition:leave-end="opacity-0 -translate-y-8 scale-75" > <div class="relative p-8 bg-white docs_sidebar dark:bg-dark-600"> <ul> <li> <h2><a id="introduction" href="#introduction" class="heading-permalink" aria-hidden="true" title="Permalink">#</a><a href="/introduction">Introduction</a></h2> </li> <li> <h2><a id="build-chirper-with-blade" href="#build-chirper-with-blade" class="heading-permalink" aria-hidden="true" title="Permalink">#</a>Build Chirper with Blade</h2> <ul> <li> <a href="/blade/installation">Installation</a> </li> <li> <a href="/blade/creating-chirps">Creating Chirps</a> </li> <li> <a href="/blade/showing-chirps">Showing Chirps</a> </li> <li> <a href="/blade/editing-chirps">Editing Chirps</a> </li> <li> <a href="/blade/deleting-chirps">Deleting Chirps</a> </li> <li> <a href="/blade/notifications-and-events">Notifications &amp; Events</a> </li> </ul> </li> <li> <h2><a id="build-chirper-with-livewire" href="#build-chirper-with-livewire" class="heading-permalink" aria-hidden="true" title="Permalink">#</a>Build Chirper with Livewire</h2> <ul> <li> <a href="/livewire/installation">Installation</a> </li> <li> <a href="/livewire/creating-chirps">Creating Chirps</a> </li> <li> <a href="/livewire/showing-chirps">Showing Chirps</a> </li> <li> <a href="/livewire/editing-chirps">Editing Chirps</a> </li> <li> <a href="/livewire/deleting-chirps">Deleting Chirps</a> </li> <li> <a href="/livewire/notifications-and-events">Notifications &amp; Events</a> </li> </ul> </li> <li> <h2><a id="build-chirper-with-inertia" href="#build-chirper-with-inertia" class="heading-permalink" aria-hidden="true" title="Permalink">#</a>Build Chirper with Inertia</h2> <ul> <li> <a href="/inertia/installation">Installation</a> </li> <li> <a href="/inertia/creating-chirps">Creating Chirps</a> </li> <li> <a href="/inertia/showing-chirps">Showing Chirps</a> </li> <li> <a href="/inertia/editing-chirps">Editing Chirps</a> </li> <li> <a href="/inertia/deleting-chirps">Deleting Chirps</a> </li> <li> <a href="/inertia/notifications-and-events">Notifications &amp; Events</a> </li> </ul> </li> <li> <h2><a id="deploying" href="#deploying" class="heading-permalink" aria-hidden="true" title="Permalink">#</a><a href="/deploying">Deploying</a></h2> </li> <li> <h2><a id="conclusion" href="#conclusion" class="heading-permalink" aria-hidden="true" title="Permalink">#</a><a href="/conclusion">Conclusion</a></h2> </li> </ul> </div> </nav> </div> </header> <section class="flex-1 dark:bg-dark-700"> <span class="hidden dark:hidden fixed -bottom-[350px] ml-[300px] bg-radial-gradient opacity-[.15] pointer-events-none lg:inline-flex w-[800px] h-[600px]"></span> <div class="px-8 sm:px-16 lg:px-24"> <div class="max-w-screen-lg flex flex-col items-end transition-colors dark:border-gray-700 lg:mt-8 lg:flex-row-reverse"> <div class="fixed top-8 hidden lg:flex items-center justify-center"> <button id="header__sun" onclick="toSystemMode()" title="Switch to system theme" class="relative w-10 h-10 focus:outline-none focus:shadow-outline text-gray-500"> <svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-sun" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"> <path stroke="none" d="M0 0h24v24H0z" fill="none"></path> <circle cx="12" cy="12" r="4"></circle> <path d="M3 12h1m8 -9v1m8 8h1m-9 8v1m-6.4 -15.4l.7 .7m12.1 -.7l-.7 .7m0 11.4l.7 .7m-12.1 -.7l-.7 .7"></path> </svg> </button> <button id="header__moon" onclick="toLightMode()" title="Switch to light mode" class="relative w-10 h-10 focus:outline-none focus:shadow-outline text-gray-500"> <svg style="width:24px;height:24px" viewBox="0 0 24 24"> <path fill="currentColor" d="M17.75,4.09L15.22,6.03L16.13,9.09L13.5,7.28L10.87,9.09L11.78,6.03L9.25,4.09L12.44,4L13.5,1L14.56,4L17.75,4.09M21.25,11L19.61,12.25L20.2,14.23L18.5,13.06L16.8,14.23L17.39,12.25L15.75,11L17.81,10.95L18.5,9L19.19,10.95L21.25,11M18.97,15.95C19.8,15.87 20.69,17.05 20.16,17.8C19.84,18.25 19.5,18.67 19.08,19.07C15.17,23 8.84,23 4.94,19.07C1.03,15.17 1.03,8.83 4.94,4.93C5.34,4.53 5.76,4.17 6.21,3.85C6.96,3.32 8.14,4.21 8.06,5.04C7.79,7.9 8.75,10.87 10.95,13.06C13.14,15.26 16.1,16.22 18.97,15.95M17.33,17.97C14.5,17.81 11.7,16.64 9.53,14.5C7.36,12.31 6.2,9.5 6.04,6.68C3.23,9.82 3.34,14.64 6.35,17.66C9.37,20.67 14.19,20.78 17.33,17.97Z" /> </svg> </button> <button id="header__indeterminate" onclick="toDarkMode()" title="Switch to dark mode" class="relative w-10 h-10 focus:outline-none focus:shadow-outline text-gray-500"> <svg style="width:24px;height:24px" viewBox="0 0 24 24"> <path fill="currentColor" d="M12 2A10 10 0 0 0 2 12A10 10 0 0 0 12 22A10 10 0 0 0 22 12A10 10 0 0 0 12 2M12 4A8 8 0 0 1 20 12A8 8 0 0 1 12 20V4Z" /> </svg> </button> </div> </div> <section class="pt-8 pb-8 md:pt-16 md:pb-16 flex"> <section class="docs_main flex-1 max-w-full"> <div id="main-content"> <div class="prose dark:prose-invert relative"> <aside class="table-of-contents-sidebar-wrapper not-prose"><aside class="table-of-contents-sidebar not-prose"><h2>On this page</h2><ul class="table-of-contents"> <li> <a href="#retrieving-the-chirps">Retrieving the Chirps</a> </li> <li> <a href="#connecting-users-to-chirps">Connecting users to Chirps</a> </li> <li> <a href="#updating-our-component">Updating our component</a> <ul> <li> <a href="#extra-credit-relative-dates">Extra Credit: Relative dates</a> </li> </ul> </li> </ul></aside></aside> <h1><b>04.</b> Showing Chirps</h1> <p>In the previous step we added the ability to create Chirps, now we're ready to display them!</p> <h2><a id="retrieving-the-chirps" href="#retrieving-the-chirps" class="heading-permalink" aria-hidden="true" title="Permalink">#</a>Retrieving the Chirps</h2> <p>Let's update the <code>index</code> method of our <code>ChirpController</code> class to pass Chirps from every user to our Index page:</p> <div class="code-container"> <div class="code-container-filename">app/Http/Controllers/ChirpController.php</div> <pre><code data-theme="olaolu-palenight" data-lang="php" class='torchlight has-add-lines has-remove-lines has-diff-lines has-summaries' style='background-color: #292D3E; --theme-selection-background: #7580B850;'><!-- Syntax highlighted by torchlight.dev --><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span class='summary-caret summary-caret-empty' style='user-select: none; color: #4c5374'></span><span style="color: #D3423E;">&lt;?php</span></div><details><summary style='cursor: pointer; display: block'><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span class='summary-caret summary-caret-start' style='user-select: none; color: #4c5374'></span>&nbsp;<span class='summary-hide-when-open' style='color:#4c5374'>...</span></div></summary><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span class='summary-caret summary-caret-middle' style='user-select: none; color: #4c5374'></span><span style="color: #C792EA;">namespace</span><span style="color: #BFC7D5;"> App\Http\Controllers;</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span class='summary-caret summary-caret-middle' style='user-select: none; color: #4c5374'></span>&nbsp;</div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span class='summary-caret summary-caret-middle' style='user-select: none; color: #4c5374'></span><span style="color: #C792EA;">use</span><span style="color: #BFC7D5;"> App\Models\</span><span style="color: #FFCB8B;">Chirp</span><span style="color: #BFC7D5;">;</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span class='summary-caret summary-caret-middle' style='user-select: none; color: #4c5374'></span><span style="color: #C792EA;">use</span><span style="color: #BFC7D5;"> Illuminate\Http\</span><span style="color: #FFCB8B;">RedirectResponse</span><span style="color: #BFC7D5;">;</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span class='summary-caret summary-caret-middle' style='user-select: none; color: #4c5374'></span><span style="color: #C792EA;">use</span><span style="color: #BFC7D5;"> Illuminate\Http\</span><span style="color: #FFCB8B;">Request</span><span style="color: #BFC7D5;">;</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span class='summary-caret summary-caret-middle' style='user-select: none; color: #4c5374'></span><span style="color: #C792EA;">use</span><span style="color: #BFC7D5;"> Inertia\</span><span style="color: #FFCB8B;">Inertia</span><span style="color: #BFC7D5;">;</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span class='summary-caret summary-caret-middle' style='user-select: none; color: #4c5374'></span><span style="color: #C792EA;">use</span><span style="color: #BFC7D5;"> Inertia\</span><span style="color: #FFCB8B;">Response</span><span style="color: #BFC7D5;">;</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span class='summary-caret summary-caret-end' style='user-select: none; color: #4c5374'></span>&nbsp;</div></details><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span class='summary-caret summary-caret-empty' style='user-select: none; color: #4c5374'></span><span style="color: #C792EA;">class</span><span style="color: #BFC7D5;"> </span><span style="color: #FFCB6B;">ChirpController</span><span style="color: #BFC7D5;"> </span><span style="color: #C792EA;">extends</span><span style="color: #BFC7D5;"> </span><span style="color: #A9C77D;">Controller</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span class='summary-caret summary-caret-empty' style='user-select: none; color: #4c5374'></span><span style="color: #BFC7D5;">{</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span class='summary-caret summary-caret-empty' style='user-select: none; color: #4c5374'></span><span style="color: #BFC7D5;"> </span><span style="color: #697098;">/**</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span class='summary-caret summary-caret-empty' style='user-select: none; color: #4c5374'></span><span style="color: #697098;"> * Display a listing of the resource.</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span class='summary-caret summary-caret-empty' style='user-select: none; color: #4c5374'></span><span style="color: #697098;"> </span><span style="color: #697098;">*/</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span class='summary-caret summary-caret-empty' style='user-select: none; color: #4c5374'></span><span style="color: #BFC7D5;"> </span><span style="color: #C792EA;">public</span><span style="color: #BFC7D5;"> </span><span style="color: #C792EA;">function</span><span style="color: #BFC7D5;"> </span><span style="color: #82AAFF;">index</span><span style="color: #D9F5DD;">()</span><span style="color: #89DDFF;">:</span><span style="color: #BFC7D5;"> </span><span style="color: #FFCB8B;">Response</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span class='summary-caret summary-caret-empty' style='user-select: none; color: #4c5374'></span><span style="color: #BFC7D5;"> {</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span class='summary-caret summary-caret-empty' style='user-select: none; color: #4c5374'></span><span style="color: #BFC7D5;"> </span><span style="color: #C792EA;">return</span><span style="color: #BFC7D5;"> </span><span style="color: #FFCB8B;">Inertia</span><span style="color: #89DDFF;">::</span><span style="color: #82AAFF;">render</span><span style="color: #BFC7D5;">(</span><span style="color: #D9F5DD;">&#39;</span><span style="color: #C3E88D;">Chirps/Index</span><span style="color: #D9F5DD;">&#39;</span><span style="color: #BFC7D5;">, [</span></div><div class='line line-remove line-has-background' style='background-color: #ef535033'><span style="color:#f07178; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number">-</span><span class='summary-caret summary-caret-empty' style='user-select: none; color: #4c5374'></span><span style="color: #BFC7D5;"> </span><span style="color: #697098;">//</span></div><div class='line line-add line-has-background' style='background-color: #99b76d23'><span style="color:#C3E88D; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number">+</span><span class='summary-caret summary-caret-empty' style='user-select: none; color: #4c5374'></span><span style="color: #BFC7D5;"> </span><span style="color: #D9F5DD;">&#39;</span><span style="color: #C3E88D;">chirps</span><span style="color: #D9F5DD;">&#39;</span><span style="color: #BFC7D5;"> </span><span style="color: #89DDFF;">=&gt;</span><span style="color: #BFC7D5;"> </span><span style="color: #FFCB8B;">Chirp</span><span style="color: #89DDFF;">::</span><span style="color: #82AAFF;">with</span><span style="color: #BFC7D5;">(</span><span style="color: #D9F5DD;">&#39;</span><span style="color: #C3E88D;">user:id,name</span><span style="color: #D9F5DD;">&#39;</span><span style="color: #BFC7D5;">)</span><span style="color: #89DDFF;">-&gt;</span><span style="color: #82AAFF;">latest</span><span style="color: #BFC7D5;">()</span><span style="color: #89DDFF;">-&gt;</span><span style="color: #82AAFF;">get</span><span style="color: #BFC7D5;">(),</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span class='summary-caret summary-caret-empty' style='user-select: none; color: #4c5374'></span><span style="color: #BFC7D5;"> ]);</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span class='summary-caret summary-caret-empty' style='user-select: none; color: #4c5374'></span><span style="color: #BFC7D5;"> }</span></div><details><summary style='cursor: pointer; display: block'><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span class='summary-caret summary-caret-start' style='user-select: none; color: #4c5374'></span>&nbsp;<span class='summary-hide-when-open' style='color:#4c5374'>...</span></div></summary><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span class='summary-caret summary-caret-middle' style='user-select: none; color: #4c5374'></span><span style="color: #BFC7D5;"> </span><span style="color: #697098;">/**</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span class='summary-caret summary-caret-middle' style='user-select: none; color: #4c5374'></span><span style="color: #697098;"> * Show the form for creating a new resource.</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span class='summary-caret summary-caret-middle' style='user-select: none; color: #4c5374'></span><span style="color: #697098;"> </span><span style="color: #697098;">*/</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span class='summary-caret summary-caret-middle' style='user-select: none; color: #4c5374'></span><span style="color: #BFC7D5;"> </span><span style="color: #C792EA;">public</span><span style="color: #BFC7D5;"> </span><span style="color: #C792EA;">function</span><span style="color: #BFC7D5;"> </span><span style="color: #82AAFF;">create</span><span style="color: #D9F5DD;">()</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span class='summary-caret summary-caret-middle' style='user-select: none; color: #4c5374'></span><span style="color: #BFC7D5;"> {</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span class='summary-caret summary-caret-middle' style='user-select: none; color: #4c5374'></span><span style="color: #BFC7D5;"> </span><span style="color: #697098;">//</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span class='summary-caret summary-caret-middle' style='user-select: none; color: #4c5374'></span><span style="color: #BFC7D5;"> }</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span class='summary-caret summary-caret-middle' style='user-select: none; color: #4c5374'></span>&nbsp;</div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span class='summary-caret summary-caret-middle' style='user-select: none; color: #4c5374'></span><span style="color: #BFC7D5;"> </span><span style="color: #697098;">/**</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span class='summary-caret summary-caret-middle' style='user-select: none; color: #4c5374'></span><span style="color: #697098;"> * Store a newly created resource in storage.</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span class='summary-caret summary-caret-middle' style='user-select: none; color: #4c5374'></span><span style="color: #697098;"> </span><span style="color: #697098;">*/</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span class='summary-caret summary-caret-middle' style='user-select: none; color: #4c5374'></span><span style="color: #BFC7D5;"> </span><span style="color: #C792EA;">public</span><span style="color: #BFC7D5;"> </span><span style="color: #C792EA;">function</span><span style="color: #BFC7D5;"> </span><span style="color: #82AAFF;">store</span><span style="color: #D9F5DD;">(</span><span style="color: #FFCB8B;">Request</span><span style="color: #BFC7D5;"> </span><span style="color: #BEC5D4;">$request</span><span style="color: #D9F5DD;">)</span><span style="color: #89DDFF;">:</span><span style="color: #BFC7D5;"> </span><span style="color: #FFCB8B;">RedirectResponse</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span class='summary-caret summary-caret-middle' style='user-select: none; color: #4c5374'></span><span style="color: #BFC7D5;"> {</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span class='summary-caret summary-caret-middle' style='user-select: none; color: #4c5374'></span><span style="color: #BFC7D5;"> </span><span style="color: #BEC5D4;">$validated</span><span style="color: #BFC7D5;"> </span><span style="color: #C792EA;">=</span><span style="color: #BFC7D5;"> </span><span style="color: #BEC5D4;">$request</span><span style="color: #89DDFF;">-&gt;</span><span style="color: #82AAFF;">validate</span><span style="color: #BFC7D5;">([</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span class='summary-caret summary-caret-middle' style='user-select: none; color: #4c5374'></span><span style="color: #BFC7D5;"> </span><span style="color: #D9F5DD;">&#39;</span><span style="color: #C3E88D;">message</span><span style="color: #D9F5DD;">&#39;</span><span style="color: #BFC7D5;"> </span><span style="color: #89DDFF;">=&gt;</span><span style="color: #BFC7D5;"> </span><span style="color: #D9F5DD;">&#39;</span><span style="color: #C3E88D;">required|string|max:255</span><span style="color: #D9F5DD;">&#39;</span><span style="color: #BFC7D5;">,</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span class='summary-caret summary-caret-middle' style='user-select: none; color: #4c5374'></span><span style="color: #BFC7D5;"> ]);</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span class='summary-caret summary-caret-middle' style='user-select: none; color: #4c5374'></span>&nbsp;</div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span class='summary-caret summary-caret-middle' style='user-select: none; color: #4c5374'></span><span style="color: #BFC7D5;"> </span><span style="color: #BEC5D4;">$request</span><span style="color: #89DDFF;">-&gt;</span><span style="color: #82AAFF;">user</span><span style="color: #BFC7D5;">()</span><span style="color: #89DDFF;">-&gt;</span><span style="color: #82AAFF;">chirps</span><span style="color: #BFC7D5;">()</span><span style="color: #89DDFF;">-&gt;</span><span style="color: #82AAFF;">create</span><span style="color: #BFC7D5;">(</span><span style="color: #BEC5D4;">$validated</span><span style="color: #BFC7D5;">);</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span class='summary-caret summary-caret-middle' style='user-select: none; color: #4c5374'></span>&nbsp;</div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span class='summary-caret summary-caret-middle' style='user-select: none; color: #4c5374'></span><span style="color: #BFC7D5;"> </span><span style="color: #C792EA;">return</span><span style="color: #BFC7D5;"> </span><span style="color: #82AAFF;">redirect</span><span style="color: #BFC7D5;">(</span><span style="color: #82AAFF;">route</span><span style="color: #BFC7D5;">(</span><span style="color: #D9F5DD;">&#39;</span><span style="color: #C3E88D;">chirps.index</span><span style="color: #D9F5DD;">&#39;</span><span style="color: #BFC7D5;">));</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span class='summary-caret summary-caret-middle' style='user-select: none; color: #4c5374'></span><span style="color: #BFC7D5;"> }</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span class='summary-caret summary-caret-middle' style='user-select: none; color: #4c5374'></span>&nbsp;</div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span class='summary-caret summary-caret-middle' style='user-select: none; color: #4c5374'></span><span style="color: #BFC7D5;"> </span><span style="color: #697098;">/**</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span class='summary-caret summary-caret-middle' style='user-select: none; color: #4c5374'></span><span style="color: #697098;"> * Display the specified resource.</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span class='summary-caret summary-caret-middle' style='user-select: none; color: #4c5374'></span><span style="color: #697098;"> </span><span style="color: #697098;">*/</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span class='summary-caret summary-caret-middle' style='user-select: none; color: #4c5374'></span><span style="color: #BFC7D5;"> </span><span style="color: #C792EA;">public</span><span style="color: #BFC7D5;"> </span><span style="color: #C792EA;">function</span><span style="color: #BFC7D5;"> </span><span style="color: #82AAFF;">show</span><span style="color: #D9F5DD;">(</span><span style="color: #FFCB8B;">Chirp</span><span style="color: #BFC7D5;"> </span><span style="color: #BEC5D4;">$chirp</span><span style="color: #D9F5DD;">)</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span class='summary-caret summary-caret-middle' style='user-select: none; color: #4c5374'></span><span style="color: #BFC7D5;"> {</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span class='summary-caret summary-caret-middle' style='user-select: none; color: #4c5374'></span><span style="color: #BFC7D5;"> </span><span style="color: #697098;">//</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span class='summary-caret summary-caret-middle' style='user-select: none; color: #4c5374'></span><span style="color: #BFC7D5;"> }</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span class='summary-caret summary-caret-middle' style='user-select: none; color: #4c5374'></span>&nbsp;</div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span class='summary-caret summary-caret-middle' style='user-select: none; color: #4c5374'></span><span style="color: #BFC7D5;"> </span><span style="color: #697098;">/**</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span class='summary-caret summary-caret-middle' style='user-select: none; color: #4c5374'></span><span style="color: #697098;"> * Show the form for editing the specified resource.</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span class='summary-caret summary-caret-middle' style='user-select: none; color: #4c5374'></span><span style="color: #697098;"> </span><span style="color: #697098;">*/</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span class='summary-caret summary-caret-middle' style='user-select: none; color: #4c5374'></span><span style="color: #BFC7D5;"> </span><span style="color: #C792EA;">public</span><span style="color: #BFC7D5;"> </span><span style="color: #C792EA;">function</span><span style="color: #BFC7D5;"> </span><span style="color: #82AAFF;">edit</span><span style="color: #D9F5DD;">(</span><span style="color: #FFCB8B;">Chirp</span><span style="color: #BFC7D5;"> </span><span style="color: #BEC5D4;">$chirp</span><span style="color: #D9F5DD;">)</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span class='summary-caret summary-caret-middle' style='user-select: none; color: #4c5374'></span><span style="color: #BFC7D5;"> {</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span class='summary-caret summary-caret-middle' style='user-select: none; color: #4c5374'></span><span style="color: #BFC7D5;"> </span><span style="color: #697098;">//</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span class='summary-caret summary-caret-middle' style='user-select: none; color: #4c5374'></span><span style="color: #BFC7D5;"> }</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span class='summary-caret summary-caret-middle' style='user-select: none; color: #4c5374'></span>&nbsp;</div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span class='summary-caret summary-caret-middle' style='user-select: none; color: #4c5374'></span><span style="color: #BFC7D5;"> </span><span style="color: #697098;">/**</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span class='summary-caret summary-caret-middle' style='user-select: none; color: #4c5374'></span><span style="color: #697098;"> * Update the specified resource in storage.</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span class='summary-caret summary-caret-middle' style='user-select: none; color: #4c5374'></span><span style="color: #697098;"> </span><span style="color: #697098;">*/</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span class='summary-caret summary-caret-middle' style='user-select: none; color: #4c5374'></span><span style="color: #BFC7D5;"> </span><span style="color: #C792EA;">public</span><span style="color: #BFC7D5;"> </span><span style="color: #C792EA;">function</span><span style="color: #BFC7D5;"> </span><span style="color: #82AAFF;">update</span><span style="color: #D9F5DD;">(</span><span style="color: #FFCB8B;">Request</span><span style="color: #BFC7D5;"> </span><span style="color: #BEC5D4;">$request</span><span style="color: #BFC7D5;">, </span><span style="color: #FFCB8B;">Chirp</span><span style="color: #BFC7D5;"> </span><span style="color: #BEC5D4;">$chirp</span><span style="color: #D9F5DD;">)</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span class='summary-caret summary-caret-middle' style='user-select: none; color: #4c5374'></span><span style="color: #BFC7D5;"> {</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span class='summary-caret summary-caret-middle' style='user-select: none; color: #4c5374'></span><span style="color: #BFC7D5;"> </span><span style="color: #697098;">//</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span class='summary-caret summary-caret-middle' style='user-select: none; color: #4c5374'></span><span style="color: #BFC7D5;"> }</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span class='summary-caret summary-caret-middle' style='user-select: none; color: #4c5374'></span>&nbsp;</div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span class='summary-caret summary-caret-middle' style='user-select: none; color: #4c5374'></span><span style="color: #BFC7D5;"> </span><span style="color: #697098;">/**</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span class='summary-caret summary-caret-middle' style='user-select: none; color: #4c5374'></span><span style="color: #697098;"> * Remove the specified resource from storage.</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span class='summary-caret summary-caret-middle' style='user-select: none; color: #4c5374'></span><span style="color: #697098;"> </span><span style="color: #697098;">*/</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span class='summary-caret summary-caret-middle' style='user-select: none; color: #4c5374'></span><span style="color: #BFC7D5;"> </span><span style="color: #C792EA;">public</span><span style="color: #BFC7D5;"> </span><span style="color: #C792EA;">function</span><span style="color: #BFC7D5;"> </span><span style="color: #82AAFF;">destroy</span><span style="color: #D9F5DD;">(</span><span style="color: #FFCB8B;">Chirp</span><span style="color: #BFC7D5;"> </span><span style="color: #BEC5D4;">$chirp</span><span style="color: #D9F5DD;">)</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span class='summary-caret summary-caret-middle' style='user-select: none; color: #4c5374'></span><span style="color: #BFC7D5;"> {</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span class='summary-caret summary-caret-middle' style='user-select: none; color: #4c5374'></span><span style="color: #BFC7D5;"> </span><span style="color: #697098;">//</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span class='summary-caret summary-caret-middle' style='user-select: none; color: #4c5374'></span><span style="color: #BFC7D5;"> }</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span class='summary-caret summary-caret-end' style='user-select: none; color: #4c5374'></span>&nbsp;</div></details><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span class='summary-caret summary-caret-empty' style='user-select: none; color: #4c5374'></span><span style="color: #BFC7D5;">}</span></div></code></pre> </div> <p>Here we've used Eloquent's <code>with</code> method to <a href="https://laravel.com/docs/eloquent-relationships#eager-loading">eager-load</a> every Chirp's associated user's ID and name. We've also used the <code>latest</code> scope to return the records in reverse-chronological order.</p> <aside class="mb-10 max-w-2xl mx-auto px-4 py-8 shadow-lg lg:flex lg:items-center bg-white dark:bg-dark-700"><div class="w-20 h-20 mb-6 flex items-center justify-center shrink-0 bg-purple-600 lg:mb-0"><img src="/img/callouts/lightbulb.min.svg" class="opacity-75"></img></div><div class="lg:ml-6 prose-p:m-0"><p> Returning all Chirps at once won't scale in production. Take a look at Laravel's powerful <a href="https://laravel.com/docs/pagination">pagination</a> to improve performance.</p></div></aside> <h2><a id="connecting-users-to-chirps" href="#connecting-users-to-chirps" class="heading-permalink" aria-hidden="true" title="Permalink">#</a>Connecting users to Chirps</h2> <p>We've instructed Laravel to return the <code>id</code> and <code>name</code> property from the <code>user</code> relationship so that we can display the name of the Chirp's author without returning other potentially sensitive information such as the author's email address. But, the Chirp's <code>user</code> relationship hasn't been defined yet. To fix this, let's add a new <a href="https://laravel.com/docs/eloquent-relationships#one-to-many-inverse">&quot;belongs to&quot;</a> relationship to our <code>Chirp</code> model:</p> <div class="code-container"> <div class="code-container-filename">app/Models/Chirp.php</div> <pre><code data-theme="olaolu-palenight" data-lang="php" class='torchlight has-add-lines has-diff-lines has-summaries' style='background-color: #292D3E; --theme-selection-background: #7580B850;'><!-- Syntax highlighted by torchlight.dev --><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span class='summary-caret summary-caret-empty' style='user-select: none; color: #4c5374'></span><span style="color: #D3423E;">&lt;?php</span></div><details><summary style='cursor: pointer; display: block'><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span class='summary-caret summary-caret-start' style='user-select: none; color: #4c5374'></span>&nbsp;<span class='summary-hide-when-open' style='color:#4c5374'>...</span></div></summary><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span class='summary-caret summary-caret-middle' style='user-select: none; color: #4c5374'></span><span style="color: #C792EA;">namespace</span><span style="color: #BFC7D5;"> App\Models;</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span class='summary-caret summary-caret-middle' style='user-select: none; color: #4c5374'></span>&nbsp;</div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span class='summary-caret summary-caret-middle' style='user-select: none; color: #4c5374'></span><span style="color: #C792EA;">use</span><span style="color: #BFC7D5;"> Illuminate\Database\Eloquent\Factories\</span><span style="color: #FFCB8B;">HasFactory</span><span style="color: #BFC7D5;">;</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span class='summary-caret summary-caret-end' style='user-select: none; color: #4c5374'></span><span style="color: #C792EA;">use</span><span style="color: #BFC7D5;"> Illuminate\Database\Eloquent\</span><span style="color: #FFCB8B;">Model</span><span style="color: #BFC7D5;">;</span></div></details><div class='line line-add line-has-background' style='background-color: #99b76d23'><span style="color:#C3E88D; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number">+</span><span class='summary-caret summary-caret-empty' style='user-select: none; color: #4c5374'></span><span style="color: #C792EA;">use</span><span style="color: #BFC7D5;"> Illuminate\Database\Eloquent\Relations\</span><span style="color: #FFCB8B;">BelongsTo</span><span style="color: #BFC7D5;">;</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span class='summary-caret summary-caret-empty' style='user-select: none; color: #4c5374'></span>&nbsp;</div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span class='summary-caret summary-caret-empty' style='user-select: none; color: #4c5374'></span><span style="color: #C792EA;">class</span><span style="color: #BFC7D5;"> </span><span style="color: #FFCB6B;">Chirp</span><span style="color: #BFC7D5;"> </span><span style="color: #C792EA;">extends</span><span style="color: #BFC7D5;"> </span><span style="color: #A9C77D;">Model</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span class='summary-caret summary-caret-empty' style='user-select: none; color: #4c5374'></span><span style="color: #BFC7D5;">{</span></div><details><summary style='cursor: pointer; display: block'><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span class='summary-caret summary-caret-start' style='user-select: none; color: #4c5374'></span>&nbsp;<span class='summary-hide-when-open' style='color:#4c5374'>...</span></div></summary><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span class='summary-caret summary-caret-middle' style='user-select: none; color: #4c5374'></span><span style="color: #BFC7D5;"> </span><span style="color: #C792EA;">use</span><span style="color: #BFC7D5;"> </span><span style="color: #FFCB8B;">HasFactory</span><span style="color: #BFC7D5;">;</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span class='summary-caret summary-caret-middle' style='user-select: none; color: #4c5374'></span>&nbsp;</div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span class='summary-caret summary-caret-middle' style='user-select: none; color: #4c5374'></span><span style="color: #BFC7D5;"> </span><span style="color: #C792EA;">protected</span><span style="color: #BFC7D5;"> </span><span style="color: #BEC5D4;">$fillable</span><span style="color: #BFC7D5;"> </span><span style="color: #C792EA;">=</span><span style="color: #BFC7D5;"> [</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span class='summary-caret summary-caret-middle' style='user-select: none; color: #4c5374'></span><span style="color: #BFC7D5;"> </span><span style="color: #D9F5DD;">&#39;</span><span style="color: #C3E88D;">message</span><span style="color: #D9F5DD;">&#39;</span><span style="color: #BFC7D5;">,</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span class='summary-caret summary-caret-middle' style='user-select: none; color: #4c5374'></span><span style="color: #BFC7D5;"> ];</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span class='summary-caret summary-caret-end' style='user-select: none; color: #4c5374'></span>&nbsp;</div></details><div class='line line-add line-has-background' style='background-color: #99b76d23'><span style="color:#C3E88D; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number">+</span><span class='summary-caret summary-caret-empty' style='user-select: none; color: #4c5374'></span><span style="color: #BFC7D5;"> </span><span style="color: #C792EA;">public</span><span style="color: #BFC7D5;"> </span><span style="color: #C792EA;">function</span><span style="color: #BFC7D5;"> </span><span style="color: #82AAFF;">user</span><span style="color: #D9F5DD;">()</span><span style="color: #89DDFF;">:</span><span style="color: #BFC7D5;"> </span><span style="color: #FFCB8B;">BelongsTo</span></div><div class='line line-add line-has-background' style='background-color: #99b76d23'><span style="color:#C3E88D; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number">+</span><span class='summary-caret summary-caret-empty' style='user-select: none; color: #4c5374'></span><span style="color: #BFC7D5;"> {</span></div><div class='line line-add line-has-background' style='background-color: #99b76d23'><span style="color:#C3E88D; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number">+</span><span class='summary-caret summary-caret-empty' style='user-select: none; color: #4c5374'></span><span style="color: #BFC7D5;"> </span><span style="color: #C792EA;">return</span><span style="color: #BFC7D5;"> </span><span style="color: #FF5572;">$this</span><span style="color: #89DDFF;">-&gt;</span><span style="color: #82AAFF;">belongsTo</span><span style="color: #BFC7D5;">(</span><span style="color: #FFCB8B;">User</span><span style="color: #89DDFF;">::</span><span style="color: #C792EA;">class</span><span style="color: #BFC7D5;">);</span></div><div class='line line-add line-has-background' style='background-color: #99b76d23'><span style="color:#C3E88D; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number">+</span><span class='summary-caret summary-caret-empty' style='user-select: none; color: #4c5374'></span><span style="color: #BFC7D5;"> }</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span class='summary-caret summary-caret-empty' style='user-select: none; color: #4c5374'></span><span style="color: #BFC7D5;">}</span></div></code></pre> </div> <p>This relationship is the inverse of the &quot;has many&quot; relationship we created earlier on the <code>User</code> model.</p> <h2><a id="updating-our-component" href="#updating-our-component" class="heading-permalink" aria-hidden="true" title="Permalink">#</a>Updating our component</h2> <p>Next, let's create a <code>Chirp</code> component for our front-end. This component will be responsible for displaying an individual Chirp:</p> <div class="tabbed-code" data-group="f86d679141246e9825a8f6c067a5f5a8"> <div class="tabbed-code-nav"> <button class="tabbed-code-nav-button active" data-tab="Vue" onClick="setTab('Vue', 'f86d679141246e9825a8f6c067a5f5a8')">Vue</button> <button class="tabbed-code-nav-button" data-tab="React" onClick="setTab('React', 'f86d679141246e9825a8f6c067a5f5a8')">React</button> </div> <div class="tabbed-code-body"> <div class="code-container active" data-tab="Vue"> <div class="code-container-filename">resources/js/Components/Chirp.vue</div> <pre><code data-theme="olaolu-palenight" data-lang="vue" class='torchlight' style='background-color: #292D3E; --theme-selection-background: #7580B850;'><!-- Syntax highlighted by torchlight.dev --><div class='line'><span style="color: #89DDFF;">&lt;</span><span style="color: #FF5572;">script</span><span style="color: #BFC7D5;"> </span><span style="color: #FFCB6B;">setup</span><span style="color: #89DDFF;">&gt;</span></div><div class='line'><span style="color: #82AAFF;">defineProps</span><span style="color: #BFC7D5;">([</span><span style="color: #D9F5DD;">&#39;</span><span style="color: #C3E88D;">chirp</span><span style="color: #D9F5DD;">&#39;</span><span style="color: #BFC7D5;">]);</span></div><div class='line'><span style="color: #89DDFF;">&lt;/</span><span style="color: #FF5572;">script</span><span style="color: #89DDFF;">&gt;</span></div><div class='line'>&nbsp;</div><div class='line'><span style="color: #89DDFF;">&lt;</span><span style="color: #FF5572;">template</span><span style="color: #89DDFF;">&gt;</span></div><div class='line'><span style="color: #BFC7D5;"> </span><span style="color: #89DDFF;">&lt;</span><span style="color: #FF5572;">div</span><span style="color: #89DDFF;"> </span><span style="color: #FFCB6B;">class</span><span style="color: #89DDFF;">=</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #C3E88D;">p-6 flex space-x-2</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #89DDFF;">&gt;</span></div><div class='line'><span style="color: #BFC7D5;"> </span><span style="color: #89DDFF;">&lt;</span><span style="color: #FF5572;">svg</span><span style="color: #89DDFF;"> </span><span style="color: #FFCB6B;">xmlns</span><span style="color: #89DDFF;">=</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #C3E88D;">http://www.w3.org/2000/svg</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #89DDFF;"> </span><span style="color: #FFCB6B;">class</span><span style="color: #89DDFF;">=</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #C3E88D;">h-6 w-6 text-gray-600 -scale-x-100</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #89DDFF;"> </span><span style="color: #FFCB6B;">fill</span><span style="color: #89DDFF;">=</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #C3E88D;">none</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #89DDFF;"> </span><span style="color: #FFCB6B;">viewBox</span><span style="color: #89DDFF;">=</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #C3E88D;">0 0 24 24</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #89DDFF;"> </span><span style="color: #FFCB6B;">stroke</span><span style="color: #89DDFF;">=</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #C3E88D;">currentColor</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #89DDFF;"> </span><span style="color: #FFCB6B;">stroke-width</span><span style="color: #89DDFF;">=</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #C3E88D;">2</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #89DDFF;">&gt;</span></div><div class='line'><span style="color: #BFC7D5;"> </span><span style="color: #89DDFF;">&lt;</span><span style="color: #FF5572;">path</span><span style="color: #89DDFF;"> </span><span style="color: #FFCB6B;">stroke-linecap</span><span style="color: #89DDFF;">=</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #C3E88D;">round</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #89DDFF;"> </span><span style="color: #FFCB6B;">stroke-linejoin</span><span style="color: #89DDFF;">=</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #C3E88D;">round</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #89DDFF;"> </span><span style="color: #FFCB6B;">d</span><span style="color: #89DDFF;">=</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #C3E88D;">M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #89DDFF;"> /&gt;</span></div><div class='line'><span style="color: #BFC7D5;"> </span><span style="color: #89DDFF;">&lt;/</span><span style="color: #FF5572;">svg</span><span style="color: #89DDFF;">&gt;</span></div><div class='line'><span style="color: #BFC7D5;"> </span><span style="color: #89DDFF;">&lt;</span><span style="color: #FF5572;">div</span><span style="color: #89DDFF;"> </span><span style="color: #FFCB6B;">class</span><span style="color: #89DDFF;">=</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #C3E88D;">flex-1</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #89DDFF;">&gt;</span></div><div class='line'><span style="color: #BFC7D5;"> </span><span style="color: #89DDFF;">&lt;</span><span style="color: #FF5572;">div</span><span style="color: #89DDFF;"> </span><span style="color: #FFCB6B;">class</span><span style="color: #89DDFF;">=</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #C3E88D;">flex justify-between items-center</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #89DDFF;">&gt;</span></div><div class='line'><span style="color: #BFC7D5;"> </span><span style="color: #89DDFF;">&lt;</span><span style="color: #FF5572;">div</span><span style="color: #89DDFF;">&gt;</span></div><div class='line'><span style="color: #BFC7D5;"> </span><span style="color: #89DDFF;">&lt;</span><span style="color: #FF5572;">span</span><span style="color: #89DDFF;"> </span><span style="color: #FFCB6B;">class</span><span style="color: #89DDFF;">=</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #C3E88D;">text-gray-800</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #89DDFF;">&gt;</span><span style="color: #BFC7D5;">{{ chirp</span><span style="color: #C792EA;">.</span><span style="color: #89DDFF;">user</span><span style="color: #C792EA;">.</span><span style="color: #89DDFF;">name</span><span style="color: #BFC7D5;"> }}</span><span style="color: #89DDFF;">&lt;/</span><span style="color: #FF5572;">span</span><span style="color: #89DDFF;">&gt;</span></div><div class='line'><span style="color: #BFC7D5;"> </span><span style="color: #89DDFF;">&lt;</span><span style="color: #FF5572;">small</span><span style="color: #89DDFF;"> </span><span style="color: #FFCB6B;">class</span><span style="color: #89DDFF;">=</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #C3E88D;">ml-2 text-sm text-gray-600</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #89DDFF;">&gt;</span><span style="color: #BFC7D5;">{{ </span><span style="color: #89DDFF;">new</span><span style="color: #BFC7D5;"> </span><span style="color: #FFCB6B;">Date</span><span style="color: #BFC7D5;">(chirp</span><span style="color: #C792EA;">.</span><span style="color: #89DDFF;">created_at</span><span style="color: #BFC7D5;">)</span><span style="color: #C792EA;">.</span><span style="color: #82AAFF;">toLocaleString</span><span style="color: #BFC7D5;">() }}</span><span style="color: #89DDFF;">&lt;/</span><span style="color: #FF5572;">small</span><span style="color: #89DDFF;">&gt;</span></div><div class='line'><span style="color: #BFC7D5;"> </span><span style="color: #89DDFF;">&lt;/</span><span style="color: #FF5572;">div</span><span style="color: #89DDFF;">&gt;</span></div><div class='line'><span style="color: #BFC7D5;"> </span><span style="color: #89DDFF;">&lt;/</span><span style="color: #FF5572;">div</span><span style="color: #89DDFF;">&gt;</span></div><div class='line'><span style="color: #BFC7D5;"> </span><span style="color: #89DDFF;">&lt;</span><span style="color: #FF5572;">p</span><span style="color: #89DDFF;"> </span><span style="color: #FFCB6B;">class</span><span style="color: #89DDFF;">=</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #C3E88D;">mt-4 text-lg text-gray-900</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #89DDFF;">&gt;</span><span style="color: #BFC7D5;">{{ chirp</span><span style="color: #C792EA;">.</span><span style="color: #89DDFF;">message</span><span style="color: #BFC7D5;"> }}</span><span style="color: #89DDFF;">&lt;/</span><span style="color: #FF5572;">p</span><span style="color: #89DDFF;">&gt;</span></div><div class='line'><span style="color: #BFC7D5;"> </span><span style="color: #89DDFF;">&lt;/</span><span style="color: #FF5572;">div</span><span style="color: #89DDFF;">&gt;</span></div><div class='line'><span style="color: #BFC7D5;"> </span><span style="color: #89DDFF;">&lt;/</span><span style="color: #FF5572;">div</span><span style="color: #89DDFF;">&gt;</span></div><div class='line'><span style="color: #89DDFF;">&lt;/</span><span style="color: #FF5572;">template</span><span style="color: #89DDFF;">&gt;</span></div></code></pre> </div> <div class="code-container" data-tab="React"> <div class="code-container-filename">resources/js/Components/Chirp.jsx</div> <pre><code data-theme="olaolu-palenight" data-lang="javascript" class='torchlight' style='background-color: #292D3E; --theme-selection-background: #7580B850;'><!-- Syntax highlighted by torchlight.dev --><div class='line'><span style="color: #C792EA;">import</span><span style="color: #BFC7D5;"> React </span><span style="color: #C792EA;">from</span><span style="color: #BFC7D5;"> </span><span style="color: #D9F5DD;">&#39;</span><span style="color: #C3E88D;">react</span><span style="color: #D9F5DD;">&#39;</span><span style="color: #BFC7D5;">;</span></div><div class='line'>&nbsp;</div><div class='line'><span style="color: #C792EA;">export</span><span style="color: #BFC7D5;"> </span><span style="color: #C792EA;">default</span><span style="color: #BFC7D5;"> </span><span style="color: #C792EA;">function</span><span style="color: #BFC7D5;"> </span><span style="color: #82AAFF;">Chirp</span><span style="color: #D9F5DD;">(</span><span style="color: #BFC7D5;">{ </span><span style="color: #7986E7;">chirp</span><span style="color: #BFC7D5;"> }</span><span style="color: #D9F5DD;">)</span><span style="color: #BFC7D5;"> {</span></div><div class='line'><span style="color: #BFC7D5;"> </span><span style="color: #C792EA;">return</span><span style="color: #BFC7D5;"> (</span></div><div class='line'><span style="color: #BFC7D5;"> </span><span style="color: #89DDFF;">&lt;</span><span style="color: #FF5572;">div</span><span style="color: #89DDFF;"> </span><span style="color: #FFCB6B;">className</span><span style="color: #C792EA;">=</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #C3E88D;">p-6 flex space-x-2</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #89DDFF;">&gt;</span></div><div class='line'><span style="color: #BFC7D5;"> </span><span style="color: #89DDFF;">&lt;</span><span style="color: #FF5572;">svg</span><span style="color: #89DDFF;"> </span><span style="color: #FFCB6B;">xmlns</span><span style="color: #C792EA;">=</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #C3E88D;">http://www.w3.org/2000/svg</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #89DDFF;"> </span><span style="color: #FFCB6B;">className</span><span style="color: #C792EA;">=</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #C3E88D;">h-6 w-6 text-gray-600 -scale-x-100</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #89DDFF;"> </span><span style="color: #FFCB6B;">fill</span><span style="color: #C792EA;">=</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #C3E88D;">none</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #89DDFF;"> </span><span style="color: #FFCB6B;">viewBox</span><span style="color: #C792EA;">=</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #C3E88D;">0 0 24 24</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #89DDFF;"> </span><span style="color: #FFCB6B;">stroke</span><span style="color: #C792EA;">=</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #C3E88D;">currentColor</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #89DDFF;"> </span><span style="color: #FFCB6B;">strokeWidth</span><span style="color: #C792EA;">=</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #C3E88D;">2</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #89DDFF;">&gt;</span></div><div class='line'><span style="color: #BFC7D5;"> </span><span style="color: #89DDFF;">&lt;</span><span style="color: #FF5572;">path</span><span style="color: #89DDFF;"> </span><span style="color: #FFCB6B;">strokeLinecap</span><span style="color: #C792EA;">=</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #C3E88D;">round</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #89DDFF;"> </span><span style="color: #FFCB6B;">strokeLinejoin</span><span style="color: #C792EA;">=</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #C3E88D;">round</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #89DDFF;"> </span><span style="color: #FFCB6B;">d</span><span style="color: #C792EA;">=</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #C3E88D;">M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #89DDFF;"> /&gt;</span></div><div class='line'><span style="color: #BFC7D5;"> </span><span style="color: #89DDFF;">&lt;/</span><span style="color: #FF5572;">svg</span><span style="color: #89DDFF;">&gt;</span></div><div class='line'><span style="color: #BFC7D5;"> </span><span style="color: #89DDFF;">&lt;</span><span style="color: #FF5572;">div</span><span style="color: #89DDFF;"> </span><span style="color: #FFCB6B;">className</span><span style="color: #C792EA;">=</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #C3E88D;">flex-1</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #89DDFF;">&gt;</span></div><div class='line'><span style="color: #BFC7D5;"> </span><span style="color: #89DDFF;">&lt;</span><span style="color: #FF5572;">div</span><span style="color: #89DDFF;"> </span><span style="color: #FFCB6B;">className</span><span style="color: #C792EA;">=</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #C3E88D;">flex justify-between items-center</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #89DDFF;">&gt;</span></div><div class='line'><span style="color: #BFC7D5;"> </span><span style="color: #89DDFF;">&lt;</span><span style="color: #FF5572;">div</span><span style="color: #89DDFF;">&gt;</span></div><div class='line'><span style="color: #BFC7D5;"> </span><span style="color: #89DDFF;">&lt;</span><span style="color: #FF5572;">span</span><span style="color: #89DDFF;"> </span><span style="color: #FFCB6B;">className</span><span style="color: #C792EA;">=</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #C3E88D;">text-gray-800</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #89DDFF;">&gt;</span><span style="color: #D3423E;">{</span><span style="color: #BFC7D5;">chirp</span><span style="color: #C792EA;">.</span><span style="color: #89DDFF;">user</span><span style="color: #C792EA;">.</span><span style="color: #89DDFF;">name</span><span style="color: #D3423E;">}</span><span style="color: #89DDFF;">&lt;/</span><span style="color: #FF5572;">span</span><span style="color: #89DDFF;">&gt;</span></div><div class='line'><span style="color: #BFC7D5;"> </span><span style="color: #89DDFF;">&lt;</span><span style="color: #FF5572;">small</span><span style="color: #89DDFF;"> </span><span style="color: #FFCB6B;">className</span><span style="color: #C792EA;">=</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #C3E88D;">ml-2 text-sm text-gray-600</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #89DDFF;">&gt;</span><span style="color: #D3423E;">{</span><span style="color: #89DDFF;">new</span><span style="color: #BFC7D5;"> </span><span style="color: #FFCB6B;">Date</span><span style="color: #BFC7D5;">(chirp</span><span style="color: #C792EA;">.</span><span style="color: #89DDFF;">created_at</span><span style="color: #BFC7D5;">)</span><span style="color: #C792EA;">.</span><span style="color: #82AAFF;">toLocaleString</span><span style="color: #BFC7D5;">()</span><span style="color: #D3423E;">}</span><span style="color: #89DDFF;">&lt;/</span><span style="color: #FF5572;">small</span><span style="color: #89DDFF;">&gt;</span></div><div class='line'><span style="color: #BFC7D5;"> </span><span style="color: #89DDFF;">&lt;/</span><span style="color: #FF5572;">div</span><span style="color: #89DDFF;">&gt;</span></div><div class='line'><span style="color: #BFC7D5;"> </span><span style="color: #89DDFF;">&lt;/</span><span style="color: #FF5572;">div</span><span style="color: #89DDFF;">&gt;</span></div><div class='line'><span style="color: #BFC7D5;"> </span><span style="color: #89DDFF;">&lt;</span><span style="color: #FF5572;">p</span><span style="color: #89DDFF;"> </span><span style="color: #FFCB6B;">className</span><span style="color: #C792EA;">=</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #C3E88D;">mt-4 text-lg text-gray-900</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #89DDFF;">&gt;</span><span style="color: #D3423E;">{</span><span style="color: #BFC7D5;">chirp</span><span style="color: #C792EA;">.</span><span style="color: #89DDFF;">message</span><span style="color: #D3423E;">}</span><span style="color: #89DDFF;">&lt;/</span><span style="color: #FF5572;">p</span><span style="color: #89DDFF;">&gt;</span></div><div class='line'><span style="color: #BFC7D5;"> </span><span style="color: #89DDFF;">&lt;/</span><span style="color: #FF5572;">div</span><span style="color: #89DDFF;">&gt;</span></div><div class='line'><span style="color: #BFC7D5;"> </span><span style="color: #89DDFF;">&lt;/</span><span style="color: #FF5572;">div</span><span style="color: #89DDFF;">&gt;</span></div><div class='line'><span style="color: #BFC7D5;"> );</span></div><div class='line'><span style="color: #BFC7D5;">}</span></div></code></pre> </div> </div> </div> <p>Finally, we will update our <code>Chirps/Index</code> page component to accept the <code>chirps</code> prop and render the Chirps below our form using our new component:</p> <div class="tabbed-code" data-group="f86d679141246e9825a8f6c067a5f5a8"> <div class="tabbed-code-nav"> <button class="tabbed-code-nav-button active" data-tab="Vue" onClick="setTab('Vue', 'f86d679141246e9825a8f6c067a5f5a8')">Vue</button> <button class="tabbed-code-nav-button" data-tab="React" onClick="setTab('React', 'f86d679141246e9825a8f6c067a5f5a8')">React</button> </div> <div class="tabbed-code-body"> <div class="code-container active" data-tab="Vue"> <div class="code-container-filename">resources/js/Pages/Chirps/Index.vue</div> <pre><code data-theme="olaolu-palenight" data-lang="vue" class='torchlight has-add-lines has-diff-lines' style='background-color: #292D3E; --theme-selection-background: #7580B850;'><!-- Syntax highlighted by torchlight.dev --><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span style="color: #89DDFF;">&lt;</span><span style="color: #FF5572;">script</span><span style="color: #BFC7D5;"> </span><span style="color: #FFCB6B;">setup</span><span style="color: #89DDFF;">&gt;</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span style="color: #C792EA;">import</span><span style="color: #BFC7D5;"> AuthenticatedLayout </span><span style="color: #C792EA;">from</span><span style="color: #BFC7D5;"> </span><span style="color: #D9F5DD;">&#39;</span><span style="color: #C3E88D;">@/Layouts/AuthenticatedLayout.vue</span><span style="color: #D9F5DD;">&#39;</span><span style="color: #BFC7D5;">;</span></div><div class='line line-add line-has-background' style='background-color: #99b76d23'><span style="color:#C3E88D; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number">+</span><span style="color: #C792EA;">import</span><span style="color: #BFC7D5;"> Chirp </span><span style="color: #C792EA;">from</span><span style="color: #BFC7D5;"> </span><span style="color: #D9F5DD;">&#39;</span><span style="color: #C3E88D;">@/Components/Chirp.vue</span><span style="color: #D9F5DD;">&#39;</span><span style="color: #BFC7D5;">;</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span style="color: #C792EA;">import</span><span style="color: #BFC7D5;"> InputError </span><span style="color: #C792EA;">from</span><span style="color: #BFC7D5;"> </span><span style="color: #D9F5DD;">&#39;</span><span style="color: #C3E88D;">@/Components/InputError.vue</span><span style="color: #D9F5DD;">&#39;</span><span style="color: #BFC7D5;">;</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span style="color: #C792EA;">import</span><span style="color: #BFC7D5;"> PrimaryButton </span><span style="color: #C792EA;">from</span><span style="color: #BFC7D5;"> </span><span style="color: #D9F5DD;">&#39;</span><span style="color: #C3E88D;">@/Components/PrimaryButton.vue</span><span style="color: #D9F5DD;">&#39;</span><span style="color: #BFC7D5;">;</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span style="color: #C792EA;">import</span><span style="color: #BFC7D5;"> { useForm, Head } </span><span style="color: #C792EA;">from</span><span style="color: #BFC7D5;"> </span><span style="color: #D9F5DD;">&#39;</span><span style="color: #C3E88D;">@inertiajs/vue3</span><span style="color: #D9F5DD;">&#39;</span><span style="color: #BFC7D5;">;</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span>&nbsp;</div><div class='line line-add line-has-background' style='background-color: #99b76d23'><span style="color:#C3E88D; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number">+</span><span style="color: #82AAFF;">defineProps</span><span style="color: #BFC7D5;">([</span><span style="color: #D9F5DD;">&#39;</span><span style="color: #C3E88D;">chirps</span><span style="color: #D9F5DD;">&#39;</span><span style="color: #BFC7D5;">]);</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span>&nbsp;</div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span style="color: #C792EA;">const</span><span style="color: #BFC7D5;"> </span><span style="color: #82AAFF;">form</span><span style="color: #BFC7D5;"> </span><span style="color: #C792EA;">=</span><span style="color: #BFC7D5;"> </span><span style="color: #82AAFF;">useForm</span><span style="color: #BFC7D5;">({</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span style="color: #BFC7D5;"> message: </span><span style="color: #D9F5DD;">&#39;&#39;</span><span style="color: #BFC7D5;">,</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span style="color: #BFC7D5;">});</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span style="color: #89DDFF;">&lt;/</span><span style="color: #FF5572;">script</span><span style="color: #89DDFF;">&gt;</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span>&nbsp;</div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span style="color: #89DDFF;">&lt;</span><span style="color: #FF5572;">template</span><span style="color: #89DDFF;">&gt;</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span style="color: #BFC7D5;"> </span><span style="color: #89DDFF;">&lt;</span><span style="color: #FFCB6B;">Head</span><span style="color: #89DDFF;"> </span><span style="color: #FFCB6B;">title</span><span style="color: #89DDFF;">=</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #C3E88D;">Dashboard</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #89DDFF;"> /&gt;</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span>&nbsp;</div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span style="color: #BFC7D5;"> </span><span style="color: #89DDFF;">&lt;</span><span style="color: #FFCB6B;">AuthenticatedLayout</span><span style="color: #89DDFF;">&gt;</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span style="color: #BFC7D5;"> </span><span style="color: #89DDFF;">&lt;</span><span style="color: #FF5572;">div</span><span style="color: #89DDFF;"> </span><span style="color: #FFCB6B;">class</span><span style="color: #89DDFF;">=</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #C3E88D;">max-w-2xl mx-auto p-4 sm:p-6 lg:p-8</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #89DDFF;">&gt;</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span style="color: #BFC7D5;"> </span><span style="color: #89DDFF;">&lt;</span><span style="color: #FF5572;">form</span><span style="color: #89DDFF;"> @</span><span style="color: #FFCB6B;">submit</span><span style="color: #89DDFF;">.</span><span style="color: #FFCB6B;">prevent</span><span style="color: #89DDFF;">=</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #BFC7D5;">form</span><span style="color: #C792EA;">.</span><span style="color: #82AAFF;">post</span><span style="color: #BFC7D5;">(</span><span style="color: #82AAFF;">route</span><span style="color: #BFC7D5;">(</span><span style="color: #D9F5DD;">&#39;</span><span style="color: #C3E88D;">chirps.store</span><span style="color: #D9F5DD;">&#39;</span><span style="color: #BFC7D5;">)</span><span style="color: #89DDFF;">, { </span><span style="color: #82AAFF;">onSuccess</span><span style="color: #BFC7D5;">:</span><span style="color: #89DDFF;"> </span><span style="color: #D9F5DD;">()</span><span style="color: #89DDFF;"> </span><span style="color: #C792EA;">=&gt;</span><span style="color: #89DDFF;"> </span><span style="color: #BFC7D5;">form</span><span style="color: #C792EA;">.</span><span style="color: #82AAFF;">reset</span><span style="color: #BFC7D5;">()</span><span style="color: #89DDFF;"> }</span><span style="color: #BFC7D5;">)</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #89DDFF;">&gt;</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span style="color: #BFC7D5;"> </span><span style="color: #89DDFF;">&lt;</span><span style="color: #FF5572;">textarea</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span style="color: #89DDFF;"> </span><span style="color: #FFCB6B;">v-model</span><span style="color: #89DDFF;">=</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #BFC7D5;">form</span><span style="color: #C792EA;">.</span><span style="color: #89DDFF;">message</span><span style="color: #D9F5DD;">&quot;</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span style="color: #89DDFF;"> </span><span style="color: #FFCB6B;">placeholder</span><span style="color: #89DDFF;">=</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #C3E88D;">What&#39;s on your mind?</span><span style="color: #D9F5DD;">&quot;</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span style="color: #89DDFF;"> </span><span style="color: #FFCB6B;">class</span><span style="color: #89DDFF;">=</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #C3E88D;">block w-full border-gray-300 focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50 rounded-md shadow-sm</span><span style="color: #D9F5DD;">&quot;</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span style="color: #89DDFF;"> &gt;&lt;/</span><span style="color: #FF5572;">textarea</span><span style="color: #89DDFF;">&gt;</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span style="color: #BFC7D5;"> </span><span style="color: #89DDFF;">&lt;</span><span style="color: #FFCB6B;">InputError</span><span style="color: #89DDFF;"> :</span><span style="color: #FFCB6B;">message</span><span style="color: #89DDFF;">=</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #BFC7D5;">form</span><span style="color: #C792EA;">.</span><span style="color: #89DDFF;">errors</span><span style="color: #C792EA;">.</span><span style="color: #89DDFF;">message</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #89DDFF;"> </span><span style="color: #FFCB6B;">class</span><span style="color: #89DDFF;">=</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #C3E88D;">mt-2</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #89DDFF;"> /&gt;</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span style="color: #BFC7D5;"> </span><span style="color: #89DDFF;">&lt;</span><span style="color: #FFCB6B;">PrimaryButton</span><span style="color: #89DDFF;"> </span><span style="color: #FFCB6B;">class</span><span style="color: #89DDFF;">=</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #C3E88D;">mt-4</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #89DDFF;">&gt;</span><span style="color: #BFC7D5;">Chirp</span><span style="color: #89DDFF;">&lt;/</span><span style="color: #FFCB6B;">PrimaryButton</span><span style="color: #89DDFF;">&gt;</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span style="color: #BFC7D5;"> </span><span style="color: #89DDFF;">&lt;/</span><span style="color: #FF5572;">form</span><span style="color: #89DDFF;">&gt;</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span>&nbsp;</div><div class='line line-add line-has-background' style='background-color: #99b76d23'><span style="color:#C3E88D; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number">+</span><span style="color: #BFC7D5;"> </span><span style="color: #89DDFF;">&lt;</span><span style="color: #FF5572;">div</span><span style="color: #89DDFF;"> </span><span style="color: #FFCB6B;">class</span><span style="color: #89DDFF;">=</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #C3E88D;">mt-6 bg-white shadow-sm rounded-lg divide-y</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #89DDFF;">&gt;</span></div><div class='line line-add line-has-background' style='background-color: #99b76d23'><span style="color:#C3E88D; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number">+</span><span style="color: #BFC7D5;"> </span><span style="color: #89DDFF;">&lt;</span><span style="color: #FFCB6B;">Chirp</span></div><div class='line line-add line-has-background' style='background-color: #99b76d23'><span style="color:#C3E88D; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number">+</span><span style="color: #89DDFF;"> </span><span style="color: #FFCB6B;">v-for</span><span style="color: #89DDFF;">=</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #BFC7D5;">chirp</span><span style="color: #89DDFF;"> in </span><span style="color: #BFC7D5;">chirps</span><span style="color: #D9F5DD;">&quot;</span></div><div class='line line-add line-has-background' style='background-color: #99b76d23'><span style="color:#C3E88D; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number">+</span><span style="color: #89DDFF;"> :</span><span style="color: #FFCB6B;">key</span><span style="color: #89DDFF;">=</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #BFC7D5;">chirp</span><span style="color: #C792EA;">.</span><span style="color: #89DDFF;">id</span><span style="color: #D9F5DD;">&quot;</span></div><div class='line line-add line-has-background' style='background-color: #99b76d23'><span style="color:#C3E88D; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number">+</span><span style="color: #89DDFF;"> :</span><span style="color: #FFCB6B;">chirp</span><span style="color: #89DDFF;">=</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #BFC7D5;">chirp</span><span style="color: #D9F5DD;">&quot;</span></div><div class='line line-add line-has-background' style='background-color: #99b76d23'><span style="color:#C3E88D; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number">+</span><span style="color: #89DDFF;"> /&gt;</span></div><div class='line line-add line-has-background' style='background-color: #99b76d23'><span style="color:#C3E88D; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number">+</span><span style="color: #BFC7D5;"> </span><span style="color: #89DDFF;">&lt;/</span><span style="color: #FF5572;">div</span><span style="color: #89DDFF;">&gt;</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span style="color: #BFC7D5;"> </span><span style="color: #89DDFF;">&lt;/</span><span style="color: #FF5572;">div</span><span style="color: #89DDFF;">&gt;</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span style="color: #BFC7D5;"> </span><span style="color: #89DDFF;">&lt;/</span><span style="color: #FFCB6B;">AuthenticatedLayout</span><span style="color: #89DDFF;">&gt;</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span style="color: #89DDFF;">&lt;/</span><span style="color: #FF5572;">template</span><span style="color: #89DDFF;">&gt;</span></div></code></pre> </div> <div class="code-container" data-tab="React"> <div class="code-container-filename">resources/js/Pages/Chirps/Index.jsx</div> <pre><code data-theme="olaolu-palenight" data-lang="javascript" class='torchlight has-add-lines has-remove-lines has-diff-lines' style='background-color: #292D3E; --theme-selection-background: #7580B850;'><!-- Syntax highlighted by torchlight.dev --><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span style="color: #C792EA;">import</span><span style="color: #BFC7D5;"> React </span><span style="color: #C792EA;">from</span><span style="color: #BFC7D5;"> </span><span style="color: #D9F5DD;">&#39;</span><span style="color: #C3E88D;">react</span><span style="color: #D9F5DD;">&#39;</span><span style="color: #BFC7D5;">;</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span style="color: #C792EA;">import</span><span style="color: #BFC7D5;"> AuthenticatedLayout </span><span style="color: #C792EA;">from</span><span style="color: #BFC7D5;"> </span><span style="color: #D9F5DD;">&#39;</span><span style="color: #C3E88D;">@/Layouts/AuthenticatedLayout</span><span style="color: #D9F5DD;">&#39;</span><span style="color: #BFC7D5;">;</span></div><div class='line line-add line-has-background' style='background-color: #99b76d23'><span style="color:#C3E88D; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number">+</span><span style="color: #C792EA;">import</span><span style="color: #BFC7D5;"> Chirp </span><span style="color: #C792EA;">from</span><span style="color: #BFC7D5;"> </span><span style="color: #D9F5DD;">&#39;</span><span style="color: #C3E88D;">@/Components/Chirp</span><span style="color: #D9F5DD;">&#39;</span><span style="color: #BFC7D5;">;</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span style="color: #C792EA;">import</span><span style="color: #BFC7D5;"> InputError </span><span style="color: #C792EA;">from</span><span style="color: #BFC7D5;"> </span><span style="color: #D9F5DD;">&#39;</span><span style="color: #C3E88D;">@/Components/InputError</span><span style="color: #D9F5DD;">&#39;</span><span style="color: #BFC7D5;">;</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span style="color: #C792EA;">import</span><span style="color: #BFC7D5;"> PrimaryButton </span><span style="color: #C792EA;">from</span><span style="color: #BFC7D5;"> </span><span style="color: #D9F5DD;">&#39;</span><span style="color: #C3E88D;">@/Components/PrimaryButton</span><span style="color: #D9F5DD;">&#39;</span><span style="color: #BFC7D5;">;</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span style="color: #C792EA;">import</span><span style="color: #BFC7D5;"> { useForm, Head } </span><span style="color: #C792EA;">from</span><span style="color: #BFC7D5;"> </span><span style="color: #D9F5DD;">&#39;</span><span style="color: #C3E88D;">@inertiajs/react</span><span style="color: #D9F5DD;">&#39;</span><span style="color: #BFC7D5;">;</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span>&nbsp;</div><div class='line line-remove line-has-background' style='background-color: #ef535033'><span style="color:#f07178; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number">-</span><span style="color: #C792EA;">export</span><span style="color: #BFC7D5;"> </span><span style="color: #C792EA;">default</span><span style="color: #BFC7D5;"> </span><span style="color: #C792EA;">function</span><span style="color: #BFC7D5;"> </span><span style="color: #82AAFF;">Index</span><span style="color: #D9F5DD;">(</span><span style="color: #BFC7D5;">{ </span><span style="color: #7986E7;">auth</span><span style="color: #BFC7D5;"> }</span><span style="color: #D9F5DD;">)</span><span style="color: #BFC7D5;"> {</span></div><div class='line line-add line-has-background' style='background-color: #99b76d23'><span style="color:#C3E88D; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number">+</span><span style="color: #C792EA;">export</span><span style="color: #BFC7D5;"> </span><span style="color: #C792EA;">default</span><span style="color: #BFC7D5;"> </span><span style="color: #C792EA;">function</span><span style="color: #BFC7D5;"> </span><span style="color: #82AAFF;">Index</span><span style="color: #D9F5DD;">(</span><span style="color: #BFC7D5;">{ </span><span style="color: #7986E7;">auth</span><span style="color: #EEFFFF;">,</span><span style="color: #BFC7D5;"> </span><span style="color: #7986E7;">chirps</span><span style="color: #BFC7D5;"> }</span><span style="color: #D9F5DD;">)</span><span style="color: #BFC7D5;"> {</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span style="color: #BFC7D5;"> </span><span style="color: #C792EA;">const</span><span style="color: #BFC7D5;"> { </span><span style="color: #82AAFF;">data</span><span style="color: #EEFFFF;">,</span><span style="color: #BFC7D5;"> </span><span style="color: #82AAFF;">setData</span><span style="color: #EEFFFF;">,</span><span style="color: #BFC7D5;"> </span><span style="color: #82AAFF;">post</span><span style="color: #EEFFFF;">,</span><span style="color: #BFC7D5;"> </span><span style="color: #82AAFF;">processing</span><span style="color: #EEFFFF;">,</span><span style="color: #BFC7D5;"> </span><span style="color: #82AAFF;">reset</span><span style="color: #EEFFFF;">,</span><span style="color: #BFC7D5;"> </span><span style="color: #82AAFF;">errors</span><span style="color: #BFC7D5;"> } </span><span style="color: #C792EA;">=</span><span style="color: #BFC7D5;"> </span><span style="color: #82AAFF;">useForm</span><span style="color: #BFC7D5;">({</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span style="color: #BFC7D5;"> message: </span><span style="color: #D9F5DD;">&#39;&#39;</span><span style="color: #EEFFFF;">,</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span style="color: #BFC7D5;"> });</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span>&nbsp;</div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span style="color: #BFC7D5;"> </span><span style="color: #C792EA;">const</span><span style="color: #BFC7D5;"> </span><span style="color: #82AAFF;">submit</span><span style="color: #BFC7D5;"> </span><span style="color: #C792EA;">=</span><span style="color: #BFC7D5;"> </span><span style="color: #D9F5DD;">(</span><span style="color: #7986E7;">e</span><span style="color: #D9F5DD;">)</span><span style="color: #BFC7D5;"> </span><span style="color: #C792EA;">=&gt;</span><span style="color: #BFC7D5;"> {</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span style="color: #BFC7D5;"> e</span><span style="color: #C792EA;">.</span><span style="color: #82AAFF;">preventDefault</span><span style="color: #BFC7D5;">();</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span style="color: #BFC7D5;"> </span><span style="color: #82AAFF;">post</span><span style="color: #BFC7D5;">(</span><span style="color: #82AAFF;">route</span><span style="color: #BFC7D5;">(</span><span style="color: #D9F5DD;">&#39;</span><span style="color: #C3E88D;">chirps.store</span><span style="color: #D9F5DD;">&#39;</span><span style="color: #BFC7D5;">)</span><span style="color: #EEFFFF;">,</span><span style="color: #BFC7D5;"> { </span><span style="color: #82AAFF;">onSuccess</span><span style="color: #BFC7D5;">: </span><span style="color: #D9F5DD;">()</span><span style="color: #BFC7D5;"> </span><span style="color: #C792EA;">=&gt;</span><span style="color: #BFC7D5;"> </span><span style="color: #82AAFF;">reset</span><span style="color: #BFC7D5;">() })</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span style="color: #BFC7D5;"> };</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span>&nbsp;</div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span style="color: #BFC7D5;"> </span><span style="color: #C792EA;">return</span><span style="color: #BFC7D5;"> (</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span style="color: #BFC7D5;"> </span><span style="color: #89DDFF;">&lt;</span><span style="color: #FF5572;">AuthenticatedLayout</span><span style="color: #89DDFF;">&gt;</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span style="color: #BFC7D5;"> </span><span style="color: #89DDFF;">&lt;</span><span style="color: #FF5572;">Head</span><span style="color: #89DDFF;"> </span><span style="color: #FFCB6B;">title</span><span style="color: #C792EA;">=</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #C3E88D;">Chirps</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #89DDFF;"> /&gt;</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span>&nbsp;</div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span style="color: #BFC7D5;"> </span><span style="color: #89DDFF;">&lt;</span><span style="color: #FF5572;">div</span><span style="color: #89DDFF;"> </span><span style="color: #FFCB6B;">className</span><span style="color: #C792EA;">=</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #C3E88D;">max-w-2xl mx-auto p-4 sm:p-6 lg:p-8</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #89DDFF;">&gt;</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span style="color: #BFC7D5;"> </span><span style="color: #89DDFF;">&lt;</span><span style="color: #FF5572;">form</span><span style="color: #89DDFF;"> </span><span style="color: #FFCB6B;">onSubmit</span><span style="color: #C792EA;">=</span><span style="color: #D3423E;">{</span><span style="color: #BFC7D5;">submit</span><span style="color: #D3423E;">}</span><span style="color: #89DDFF;">&gt;</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span style="color: #BFC7D5;"> </span><span style="color: #89DDFF;">&lt;</span><span style="color: #FF5572;">textarea</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span style="color: #89DDFF;"> </span><span style="color: #FFCB6B;">value</span><span style="color: #C792EA;">=</span><span style="color: #D3423E;">{</span><span style="color: #BFC7D5;">data</span><span style="color: #C792EA;">.</span><span style="color: #89DDFF;">message</span><span style="color: #D3423E;">}</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span style="color: #89DDFF;"> </span><span style="color: #FFCB6B;">placeholder</span><span style="color: #C792EA;">=</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #C3E88D;">What&#39;s on your mind?</span><span style="color: #D9F5DD;">&quot;</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span style="color: #89DDFF;"> </span><span style="color: #FFCB6B;">className</span><span style="color: #C792EA;">=</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #C3E88D;">block w-full border-gray-300 focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50 rounded-md shadow-sm</span><span style="color: #D9F5DD;">&quot;</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span style="color: #89DDFF;"> </span><span style="color: #FFCB6B;">onChange</span><span style="color: #C792EA;">=</span><span style="color: #D3423E;">{</span><span style="color: #7986E7;">e</span><span style="color: #89DDFF;"> </span><span style="color: #C792EA;">=&gt;</span><span style="color: #89DDFF;"> </span><span style="color: #82AAFF;">setData</span><span style="color: #BFC7D5;">(</span><span style="color: #D9F5DD;">&#39;</span><span style="color: #C3E88D;">message</span><span style="color: #D9F5DD;">&#39;</span><span style="color: #EEFFFF;">,</span><span style="color: #89DDFF;"> </span><span style="color: #BFC7D5;">e</span><span style="color: #C792EA;">.</span><span style="color: #89DDFF;">target</span><span style="color: #C792EA;">.</span><span style="color: #89DDFF;">value</span><span style="color: #BFC7D5;">)</span><span style="color: #D3423E;">}</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span style="color: #89DDFF;"> &gt;&lt;/</span><span style="color: #FF5572;">textarea</span><span style="color: #89DDFF;">&gt;</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span style="color: #BFC7D5;"> </span><span style="color: #89DDFF;">&lt;</span><span style="color: #FF5572;">InputError</span><span style="color: #89DDFF;"> </span><span style="color: #FFCB6B;">message</span><span style="color: #C792EA;">=</span><span style="color: #D3423E;">{</span><span style="color: #BFC7D5;">errors</span><span style="color: #C792EA;">.</span><span style="color: #89DDFF;">message</span><span style="color: #D3423E;">}</span><span style="color: #89DDFF;"> </span><span style="color: #FFCB6B;">className</span><span style="color: #C792EA;">=</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #C3E88D;">mt-2</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #89DDFF;"> /&gt;</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span style="color: #BFC7D5;"> </span><span style="color: #89DDFF;">&lt;</span><span style="color: #FF5572;">PrimaryButton</span><span style="color: #89DDFF;"> </span><span style="color: #FFCB6B;">className</span><span style="color: #C792EA;">=</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #C3E88D;">mt-4</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #89DDFF;"> </span><span style="color: #FFCB6B;">disabled</span><span style="color: #C792EA;">=</span><span style="color: #D3423E;">{</span><span style="color: #BFC7D5;">processing</span><span style="color: #D3423E;">}</span><span style="color: #89DDFF;">&gt;</span><span style="color: #BFC7D5;">Chirp</span><span style="color: #89DDFF;">&lt;/</span><span style="color: #FF5572;">PrimaryButton</span><span style="color: #89DDFF;">&gt;</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span style="color: #BFC7D5;"> </span><span style="color: #89DDFF;">&lt;/</span><span style="color: #FF5572;">form</span><span style="color: #89DDFF;">&gt;</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span>&nbsp;</div><div class='line line-add line-has-background' style='background-color: #99b76d23'><span style="color:#C3E88D; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number">+</span><span style="color: #BFC7D5;"> </span><span style="color: #89DDFF;">&lt;</span><span style="color: #FF5572;">div</span><span style="color: #89DDFF;"> </span><span style="color: #FFCB6B;">className</span><span style="color: #C792EA;">=</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #C3E88D;">mt-6 bg-white shadow-sm rounded-lg divide-y</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #89DDFF;">&gt;</span></div><div class='line line-add line-has-background' style='background-color: #99b76d23'><span style="color:#C3E88D; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number">+</span><span style="color: #BFC7D5;"> </span><span style="color: #D3423E;">{</span><span style="color: #BFC7D5;">chirps</span><span style="color: #C792EA;">.</span><span style="color: #82AAFF;">map</span><span style="color: #BFC7D5;">(</span><span style="color: #7986E7;">chirp</span><span style="color: #BFC7D5;"> </span><span style="color: #C792EA;">=&gt;</span></div><div class='line line-add line-has-background' style='background-color: #99b76d23'><span style="color:#C3E88D; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number">+</span><span style="color: #BFC7D5;"> </span><span style="color: #89DDFF;">&lt;</span><span style="color: #FF5572;">Chirp</span><span style="color: #89DDFF;"> </span><span style="color: #FFCB6B;">key</span><span style="color: #C792EA;">=</span><span style="color: #D3423E;">{</span><span style="color: #BFC7D5;">chirp</span><span style="color: #C792EA;">.</span><span style="color: #89DDFF;">id</span><span style="color: #D3423E;">}</span><span style="color: #89DDFF;"> </span><span style="color: #FFCB6B;">chirp</span><span style="color: #C792EA;">=</span><span style="color: #D3423E;">{</span><span style="color: #BFC7D5;">chirp</span><span style="color: #D3423E;">}</span><span style="color: #89DDFF;"> /&gt;</span></div><div class='line line-add line-has-background' style='background-color: #99b76d23'><span style="color:#C3E88D; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number">+</span><span style="color: #BFC7D5;"> )</span><span style="color: #D3423E;">}</span></div><div class='line line-add line-has-background' style='background-color: #99b76d23'><span style="color:#C3E88D; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number">+</span><span style="color: #BFC7D5;"> </span><span style="color: #89DDFF;">&lt;/</span><span style="color: #FF5572;">div</span><span style="color: #89DDFF;">&gt;</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span style="color: #BFC7D5;"> </span><span style="color: #89DDFF;">&lt;/</span><span style="color: #FF5572;">div</span><span style="color: #89DDFF;">&gt;</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span style="color: #BFC7D5;"> </span><span style="color: #89DDFF;">&lt;/</span><span style="color: #FF5572;">AuthenticatedLayout</span><span style="color: #89DDFF;">&gt;</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span style="color: #BFC7D5;"> );</span></div><div class='line hidden'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span>&nbsp;</div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span style="color: #BFC7D5;">}</span></div></code></pre> </div> </div> </div> <p>Now take a look in your browser to see the message you Chirped earlier!</p> <img src="/img/screenshots/chirp-index.png" alt="Chirp listing" class="rounded-lg border dark:border-none shadow-lg" /> <h3><a id="extra-credit-relative-dates" href="#extra-credit-relative-dates" class="heading-permalink" aria-hidden="true" title="Permalink">#</a>Extra Credit: Relative dates</h3> <p>In our <code>Chirp</code> component we formatted the dates to be human-readable, but we can take that one step further by displaying relative dates using the popular <a href="https://day.js.org">Day.js</a> library.</p> <p>First, install the <code>dayjs</code> NPM package:</p> <div class="code-container"> <pre><code data-theme="olaolu-palenight" data-lang="shell" class='torchlight' style='background-color: #292D3E; --theme-selection-background: #7580B850;'><!-- Syntax highlighted by torchlight.dev --><div class='line'><span style="color: #BFC7D5;">npm </span><span style="color: #BFC7D5;">install</span><span style="color: #BFC7D5;"> </span><span style="color: #BFC7D5;">dayjs</span></div></code></pre> </div> <p>Then we can use this library in our <code>Chirp</code> component to display relative dates:</p> <div class="tabbed-code" data-group="f86d679141246e9825a8f6c067a5f5a8"> <div class="tabbed-code-nav"> <button class="tabbed-code-nav-button active" data-tab="Vue" onClick="setTab('Vue', 'f86d679141246e9825a8f6c067a5f5a8')">Vue</button> <button class="tabbed-code-nav-button" data-tab="React" onClick="setTab('React', 'f86d679141246e9825a8f6c067a5f5a8')">React</button> </div> <div class="tabbed-code-body"> <div class="code-container active" data-tab="Vue"> <div class="code-container-filename">resources/js/Components/Chirp.vue</div> <pre><code data-theme="olaolu-palenight" data-lang="vue" class='torchlight has-add-lines has-remove-lines has-diff-lines' style='background-color: #292D3E; --theme-selection-background: #7580B850;'><!-- Syntax highlighted by torchlight.dev --><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span style="color: #89DDFF;">&lt;</span><span style="color: #FF5572;">script</span><span style="color: #BFC7D5;"> </span><span style="color: #FFCB6B;">setup</span><span style="color: #89DDFF;">&gt;</span></div><div class='line line-add line-has-background' style='background-color: #99b76d23'><span style="color:#C3E88D; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number">+</span><span style="color: #C792EA;">import</span><span style="color: #BFC7D5;"> dayjs </span><span style="color: #C792EA;">from</span><span style="color: #BFC7D5;"> </span><span style="color: #D9F5DD;">&#39;</span><span style="color: #C3E88D;">dayjs</span><span style="color: #D9F5DD;">&#39;</span><span style="color: #BFC7D5;">;</span></div><div class='line line-add line-has-background' style='background-color: #99b76d23'><span style="color:#C3E88D; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number">+</span><span style="color: #C792EA;">import</span><span style="color: #BFC7D5;"> relativeTime </span><span style="color: #C792EA;">from</span><span style="color: #BFC7D5;"> </span><span style="color: #D9F5DD;">&#39;</span><span style="color: #C3E88D;">dayjs/plugin/relativeTime</span><span style="color: #D9F5DD;">&#39;</span><span style="color: #BFC7D5;">;</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span>&nbsp;</div><div class='line line-add line-has-background' style='background-color: #99b76d23'><span style="color:#C3E88D; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number">+</span><span style="color: #BFC7D5;">dayjs</span><span style="color: #C792EA;">.</span><span style="color: #82AAFF;">extend</span><span style="color: #BFC7D5;">(relativeTime);</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span>&nbsp;</div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span style="color: #82AAFF;">defineProps</span><span style="color: #BFC7D5;">([</span><span style="color: #D9F5DD;">&#39;</span><span style="color: #C3E88D;">chirp</span><span style="color: #D9F5DD;">&#39;</span><span style="color: #BFC7D5;">]);</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span style="color: #89DDFF;">&lt;/</span><span style="color: #FF5572;">script</span><span style="color: #89DDFF;">&gt;</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span>&nbsp;</div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span style="color: #89DDFF;">&lt;</span><span style="color: #FF5572;">template</span><span style="color: #89DDFF;">&gt;</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span style="color: #BFC7D5;"> </span><span style="color: #89DDFF;">&lt;</span><span style="color: #FF5572;">div</span><span style="color: #89DDFF;"> </span><span style="color: #FFCB6B;">class</span><span style="color: #89DDFF;">=</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #C3E88D;">p-6 flex space-x-2</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #89DDFF;">&gt;</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span style="color: #BFC7D5;"> </span><span style="color: #89DDFF;">&lt;</span><span style="color: #FF5572;">svg</span><span style="color: #89DDFF;"> </span><span style="color: #FFCB6B;">xmlns</span><span style="color: #89DDFF;">=</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #C3E88D;">http://www.w3.org/2000/svg</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #89DDFF;"> </span><span style="color: #FFCB6B;">class</span><span style="color: #89DDFF;">=</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #C3E88D;">h-6 w-6 text-gray-600 -scale-x-100</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #89DDFF;"> </span><span style="color: #FFCB6B;">fill</span><span style="color: #89DDFF;">=</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #C3E88D;">none</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #89DDFF;"> </span><span style="color: #FFCB6B;">viewBox</span><span style="color: #89DDFF;">=</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #C3E88D;">0 0 24 24</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #89DDFF;"> </span><span style="color: #FFCB6B;">stroke</span><span style="color: #89DDFF;">=</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #C3E88D;">currentColor</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #89DDFF;"> </span><span style="color: #FFCB6B;">stroke-width</span><span style="color: #89DDFF;">=</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #C3E88D;">2</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #89DDFF;">&gt;</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span style="color: #BFC7D5;"> </span><span style="color: #89DDFF;">&lt;</span><span style="color: #FF5572;">path</span><span style="color: #89DDFF;"> </span><span style="color: #FFCB6B;">stroke-linecap</span><span style="color: #89DDFF;">=</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #C3E88D;">round</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #89DDFF;"> </span><span style="color: #FFCB6B;">stroke-linejoin</span><span style="color: #89DDFF;">=</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #C3E88D;">round</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #89DDFF;"> </span><span style="color: #FFCB6B;">d</span><span style="color: #89DDFF;">=</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #C3E88D;">M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #89DDFF;"> /&gt;</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span style="color: #BFC7D5;"> </span><span style="color: #89DDFF;">&lt;/</span><span style="color: #FF5572;">svg</span><span style="color: #89DDFF;">&gt;</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span style="color: #BFC7D5;"> </span><span style="color: #89DDFF;">&lt;</span><span style="color: #FF5572;">div</span><span style="color: #89DDFF;"> </span><span style="color: #FFCB6B;">class</span><span style="color: #89DDFF;">=</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #C3E88D;">flex-1</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #89DDFF;">&gt;</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span style="color: #BFC7D5;"> </span><span style="color: #89DDFF;">&lt;</span><span style="color: #FF5572;">div</span><span style="color: #89DDFF;"> </span><span style="color: #FFCB6B;">class</span><span style="color: #89DDFF;">=</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #C3E88D;">flex justify-between items-center</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #89DDFF;">&gt;</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span style="color: #BFC7D5;"> </span><span style="color: #89DDFF;">&lt;</span><span style="color: #FF5572;">div</span><span style="color: #89DDFF;">&gt;</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span style="color: #BFC7D5;"> </span><span style="color: #89DDFF;">&lt;</span><span style="color: #FF5572;">span</span><span style="color: #89DDFF;"> </span><span style="color: #FFCB6B;">class</span><span style="color: #89DDFF;">=</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #C3E88D;">text-gray-800</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #89DDFF;">&gt;</span><span style="color: #BFC7D5;">{{ chirp</span><span style="color: #C792EA;">.</span><span style="color: #89DDFF;">user</span><span style="color: #C792EA;">.</span><span style="color: #89DDFF;">name</span><span style="color: #BFC7D5;"> }}</span><span style="color: #89DDFF;">&lt;/</span><span style="color: #FF5572;">span</span><span style="color: #89DDFF;">&gt;</span></div><div class='line line-remove line-has-background' style='background-color: #ef535033'><span style="color:#f07178; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number">-</span><span style="color: #BFC7D5;"> </span><span style="color: #89DDFF;">&lt;</span><span style="color: #FF5572;">small</span><span style="color: #89DDFF;"> </span><span style="color: #FFCB6B;">class</span><span style="color: #89DDFF;">=</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #C3E88D;">ml-2 text-sm text-gray-600</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #89DDFF;">&gt;</span><span style="color: #BFC7D5;">{{ </span><span style="color: #89DDFF;">new</span><span style="color: #BFC7D5;"> </span><span style="color: #FFCB6B;">Date</span><span style="color: #BFC7D5;">(chirp</span><span style="color: #C792EA;">.</span><span style="color: #89DDFF;">created_at</span><span style="color: #BFC7D5;">)</span><span style="color: #C792EA;">.</span><span style="color: #82AAFF;">toLocaleString</span><span style="color: #BFC7D5;">() }}</span><span style="color: #89DDFF;">&lt;/</span><span style="color: #FF5572;">small</span><span style="color: #89DDFF;">&gt;</span></div><div class='line line-add line-has-background' style='background-color: #99b76d23'><span style="color:#C3E88D; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number">+</span><span style="color: #BFC7D5;"> </span><span style="color: #89DDFF;">&lt;</span><span style="color: #FF5572;">small</span><span style="color: #89DDFF;"> </span><span style="color: #FFCB6B;">class</span><span style="color: #89DDFF;">=</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #C3E88D;">ml-2 text-sm text-gray-600</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #89DDFF;">&gt;</span><span style="color: #BFC7D5;">{{ </span><span style="color: #82AAFF;">dayjs</span><span style="color: #BFC7D5;">(chirp</span><span style="color: #C792EA;">.</span><span style="color: #89DDFF;">created_at</span><span style="color: #BFC7D5;">)</span><span style="color: #C792EA;">.</span><span style="color: #82AAFF;">fromNow</span><span style="color: #BFC7D5;">() }}</span><span style="color: #89DDFF;">&lt;/</span><span style="color: #FF5572;">small</span><span style="color: #89DDFF;">&gt;</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span style="color: #BFC7D5;"> </span><span style="color: #89DDFF;">&lt;/</span><span style="color: #FF5572;">div</span><span style="color: #89DDFF;">&gt;</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span style="color: #BFC7D5;"> </span><span style="color: #89DDFF;">&lt;/</span><span style="color: #FF5572;">div</span><span style="color: #89DDFF;">&gt;</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span style="color: #BFC7D5;"> </span><span style="color: #89DDFF;">&lt;</span><span style="color: #FF5572;">p</span><span style="color: #89DDFF;"> </span><span style="color: #FFCB6B;">class</span><span style="color: #89DDFF;">=</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #C3E88D;">mt-4 text-lg text-gray-900</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #89DDFF;">&gt;</span><span style="color: #BFC7D5;">{{ chirp</span><span style="color: #C792EA;">.</span><span style="color: #89DDFF;">message</span><span style="color: #BFC7D5;"> }}</span><span style="color: #89DDFF;">&lt;/</span><span style="color: #FF5572;">p</span><span style="color: #89DDFF;">&gt;</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span style="color: #BFC7D5;"> </span><span style="color: #89DDFF;">&lt;/</span><span style="color: #FF5572;">div</span><span style="color: #89DDFF;">&gt;</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span style="color: #BFC7D5;"> </span><span style="color: #89DDFF;">&lt;/</span><span style="color: #FF5572;">div</span><span style="color: #89DDFF;">&gt;</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span style="color: #89DDFF;">&lt;/</span><span style="color: #FF5572;">template</span><span style="color: #89DDFF;">&gt;</span></div></code></pre> </div> <div class="code-container" data-tab="React"> <div class="code-container-filename">resources/js/Components/Chirp.jsx</div> <pre><code data-theme="olaolu-palenight" data-lang="javascript" class='torchlight has-add-lines has-remove-lines has-diff-lines' style='background-color: #292D3E; --theme-selection-background: #7580B850;'><!-- Syntax highlighted by torchlight.dev --><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span style="color: #C792EA;">import</span><span style="color: #BFC7D5;"> React </span><span style="color: #C792EA;">from</span><span style="color: #BFC7D5;"> </span><span style="color: #D9F5DD;">&#39;</span><span style="color: #C3E88D;">react</span><span style="color: #D9F5DD;">&#39;</span><span style="color: #BFC7D5;">;</span></div><div class='line line-add line-has-background' style='background-color: #99b76d23'><span style="color:#C3E88D; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number">+</span><span style="color: #C792EA;">import</span><span style="color: #BFC7D5;"> dayjs </span><span style="color: #C792EA;">from</span><span style="color: #BFC7D5;"> </span><span style="color: #D9F5DD;">&#39;</span><span style="color: #C3E88D;">dayjs</span><span style="color: #D9F5DD;">&#39;</span><span style="color: #BFC7D5;">;</span></div><div class='line line-add line-has-background' style='background-color: #99b76d23'><span style="color:#C3E88D; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number">+</span><span style="color: #C792EA;">import</span><span style="color: #BFC7D5;"> relativeTime </span><span style="color: #C792EA;">from</span><span style="color: #BFC7D5;"> </span><span style="color: #D9F5DD;">&#39;</span><span style="color: #C3E88D;">dayjs/plugin/relativeTime</span><span style="color: #D9F5DD;">&#39;</span><span style="color: #BFC7D5;">;</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span>&nbsp;</div><div class='line line-add line-has-background' style='background-color: #99b76d23'><span style="color:#C3E88D; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number">+</span><span style="color: #BFC7D5;">dayjs</span><span style="color: #C792EA;">.</span><span style="color: #82AAFF;">extend</span><span style="color: #BFC7D5;">(relativeTime);</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span>&nbsp;</div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span style="color: #C792EA;">export</span><span style="color: #BFC7D5;"> </span><span style="color: #C792EA;">default</span><span style="color: #BFC7D5;"> </span><span style="color: #C792EA;">function</span><span style="color: #BFC7D5;"> </span><span style="color: #82AAFF;">Chirp</span><span style="color: #D9F5DD;">(</span><span style="color: #BFC7D5;">{ </span><span style="color: #7986E7;">chirp</span><span style="color: #BFC7D5;"> }</span><span style="color: #D9F5DD;">)</span><span style="color: #BFC7D5;"> {</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span style="color: #BFC7D5;"> </span><span style="color: #C792EA;">return</span><span style="color: #BFC7D5;"> (</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span style="color: #BFC7D5;"> </span><span style="color: #89DDFF;">&lt;</span><span style="color: #FF5572;">div</span><span style="color: #89DDFF;"> </span><span style="color: #FFCB6B;">className</span><span style="color: #C792EA;">=</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #C3E88D;">p-6 flex space-x-2</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #89DDFF;">&gt;</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span style="color: #BFC7D5;"> </span><span style="color: #89DDFF;">&lt;</span><span style="color: #FF5572;">svg</span><span style="color: #89DDFF;"> </span><span style="color: #FFCB6B;">xmlns</span><span style="color: #C792EA;">=</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #C3E88D;">http://www.w3.org/2000/svg</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #89DDFF;"> </span><span style="color: #FFCB6B;">className</span><span style="color: #C792EA;">=</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #C3E88D;">h-6 w-6 text-gray-600 -scale-x-100</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #89DDFF;"> </span><span style="color: #FFCB6B;">fill</span><span style="color: #C792EA;">=</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #C3E88D;">none</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #89DDFF;"> </span><span style="color: #FFCB6B;">viewBox</span><span style="color: #C792EA;">=</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #C3E88D;">0 0 24 24</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #89DDFF;"> </span><span style="color: #FFCB6B;">stroke</span><span style="color: #C792EA;">=</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #C3E88D;">currentColor</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #89DDFF;"> </span><span style="color: #FFCB6B;">strokeWidth</span><span style="color: #C792EA;">=</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #C3E88D;">2</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #89DDFF;">&gt;</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span style="color: #BFC7D5;"> </span><span style="color: #89DDFF;">&lt;</span><span style="color: #FF5572;">path</span><span style="color: #89DDFF;"> </span><span style="color: #FFCB6B;">strokeLinecap</span><span style="color: #C792EA;">=</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #C3E88D;">round</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #89DDFF;"> </span><span style="color: #FFCB6B;">strokeLinejoin</span><span style="color: #C792EA;">=</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #C3E88D;">round</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #89DDFF;"> </span><span style="color: #FFCB6B;">d</span><span style="color: #C792EA;">=</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #C3E88D;">M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #89DDFF;"> /&gt;</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span style="color: #BFC7D5;"> </span><span style="color: #89DDFF;">&lt;/</span><span style="color: #FF5572;">svg</span><span style="color: #89DDFF;">&gt;</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span style="color: #BFC7D5;"> </span><span style="color: #89DDFF;">&lt;</span><span style="color: #FF5572;">div</span><span style="color: #89DDFF;"> </span><span style="color: #FFCB6B;">className</span><span style="color: #C792EA;">=</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #C3E88D;">flex-1</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #89DDFF;">&gt;</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span style="color: #BFC7D5;"> </span><span style="color: #89DDFF;">&lt;</span><span style="color: #FF5572;">div</span><span style="color: #89DDFF;"> </span><span style="color: #FFCB6B;">className</span><span style="color: #C792EA;">=</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #C3E88D;">flex justify-between items-center</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #89DDFF;">&gt;</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span style="color: #BFC7D5;"> </span><span style="color: #89DDFF;">&lt;</span><span style="color: #FF5572;">div</span><span style="color: #89DDFF;">&gt;</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span style="color: #BFC7D5;"> </span><span style="color: #89DDFF;">&lt;</span><span style="color: #FF5572;">span</span><span style="color: #89DDFF;"> </span><span style="color: #FFCB6B;">className</span><span style="color: #C792EA;">=</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #C3E88D;">text-gray-800</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #89DDFF;">&gt;</span><span style="color: #D3423E;">{</span><span style="color: #BFC7D5;">chirp</span><span style="color: #C792EA;">.</span><span style="color: #89DDFF;">user</span><span style="color: #C792EA;">.</span><span style="color: #89DDFF;">name</span><span style="color: #D3423E;">}</span><span style="color: #89DDFF;">&lt;/</span><span style="color: #FF5572;">span</span><span style="color: #89DDFF;">&gt;</span></div><div class='line line-remove line-has-background' style='background-color: #ef535033'><span style="color:#f07178; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number">-</span><span style="color: #BFC7D5;"> </span><span style="color: #89DDFF;">&lt;</span><span style="color: #FF5572;">small</span><span style="color: #89DDFF;"> </span><span style="color: #FFCB6B;">className</span><span style="color: #C792EA;">=</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #C3E88D;">ml-2 text-sm text-gray-600</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #89DDFF;">&gt;</span><span style="color: #D3423E;">{</span><span style="color: #89DDFF;">new</span><span style="color: #BFC7D5;"> </span><span style="color: #FFCB6B;">Date</span><span style="color: #BFC7D5;">(chirp</span><span style="color: #C792EA;">.</span><span style="color: #89DDFF;">created_at</span><span style="color: #BFC7D5;">)</span><span style="color: #C792EA;">.</span><span style="color: #82AAFF;">toLocaleString</span><span style="color: #BFC7D5;">()</span><span style="color: #D3423E;">}</span><span style="color: #89DDFF;">&lt;/</span><span style="color: #FF5572;">small</span><span style="color: #89DDFF;">&gt;</span></div><div class='line line-add line-has-background' style='background-color: #99b76d23'><span style="color:#C3E88D; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number">+</span><span style="color: #BFC7D5;"> </span><span style="color: #89DDFF;">&lt;</span><span style="color: #FF5572;">small</span><span style="color: #89DDFF;"> </span><span style="color: #FFCB6B;">className</span><span style="color: #C792EA;">=</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #C3E88D;">ml-2 text-sm text-gray-600</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #89DDFF;">&gt;</span><span style="color: #D3423E;">{</span><span style="color: #82AAFF;">dayjs</span><span style="color: #BFC7D5;">(chirp</span><span style="color: #C792EA;">.</span><span style="color: #89DDFF;">created_at</span><span style="color: #BFC7D5;">)</span><span style="color: #C792EA;">.</span><span style="color: #82AAFF;">fromNow</span><span style="color: #BFC7D5;">()</span><span style="color: #D3423E;">}</span><span style="color: #89DDFF;">&lt;/</span><span style="color: #FF5572;">small</span><span style="color: #89DDFF;">&gt;</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span style="color: #BFC7D5;"> </span><span style="color: #89DDFF;">&lt;/</span><span style="color: #FF5572;">div</span><span style="color: #89DDFF;">&gt;</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span style="color: #BFC7D5;"> </span><span style="color: #89DDFF;">&lt;/</span><span style="color: #FF5572;">div</span><span style="color: #89DDFF;">&gt;</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span style="color: #BFC7D5;"> </span><span style="color: #89DDFF;">&lt;</span><span style="color: #FF5572;">p</span><span style="color: #89DDFF;"> </span><span style="color: #FFCB6B;">className</span><span style="color: #C792EA;">=</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #C3E88D;">mt-4 text-lg text-gray-900</span><span style="color: #D9F5DD;">&quot;</span><span style="color: #89DDFF;">&gt;</span><span style="color: #D3423E;">{</span><span style="color: #BFC7D5;">chirp</span><span style="color: #C792EA;">.</span><span style="color: #89DDFF;">message</span><span style="color: #D3423E;">}</span><span style="color: #89DDFF;">&lt;/</span><span style="color: #FF5572;">p</span><span style="color: #89DDFF;">&gt;</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span style="color: #BFC7D5;"> </span><span style="color: #89DDFF;">&lt;/</span><span style="color: #FF5572;">div</span><span style="color: #89DDFF;">&gt;</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span style="color: #BFC7D5;"> </span><span style="color: #89DDFF;">&lt;/</span><span style="color: #FF5572;">div</span><span style="color: #89DDFF;">&gt;</span></div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span style="color: #BFC7D5;"> );</span></div><div class='line hidden'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span>&nbsp;</div><div class='line'><span style="color:#4c5374; text-align: right; -webkit-user-select: none; user-select: none;" class="line-number"> </span><span style="color: #BFC7D5;">}</span></div></code></pre> </div> </div> </div> <p>Take a look in the browser to see your relative dates.</p> <img src="/img/screenshots/chirp-index-dates.png" alt="Chirp listing with relative dates" class="rounded-lg border dark:border-none shadow-lg" /> <p>Feel free to Chirp some more, or even register another account and start a conversation!</p> <p><a href="/inertia/editing-chirps">Continue to allow editing of Chirps...</a></p><script> function setTab(tab, group, save) { save = typeof save === 'undefined' ? true : save document .querySelectorAll(`.tabbed-code[data-group="${group}"] .tabbed-code-nav-button`) .forEach(el => el.classList.remove('active')) document .querySelectorAll(`.tabbed-code[data-group="${group}"] .code-container`) .forEach(el => el.classList.remove('active')) document .querySelectorAll(`.tabbed-code[data-group="${group}"] [data-tab="${tab}"]`) .forEach(el => el.classList.add('active')) if (save) { saveTab(tab, group) } } function getTabs() { try { return JSON.parse(localStorage.tabs) } catch { return {} } } function saveTab(tab, group) { localStorage.tabs = JSON.stringify({ ...getTabs(), [group]: tab, }) } function restoreTabs() { Object.entries(getTabs()).forEach(([group, tab]) => setTab(tab, group, false)) } restoreTabs() </script> </div> <script> // Set the active navigation state... Array.from(document.querySelectorAll('#header a, #sidebar a')).forEach(link => { if (link.hostname === location.hostname && (link.pathname === location.pathname || (link.pathname === '/introduction' && location.pathname === '/')) ) { link.classList.add('active') if (link.parentNode.tagName === 'LI') { link.parentNode.parentNode.parentNode.classList.add('sub--on') } } }) // Make the navigation headings expandable... Array.from(document.querySelectorAll('.docs_sidebar h2')).forEach(el => { if (el.children.length > 1) { return } el.addEventListener('click', (e) => { const active = el.parentNode.classList.contains('sub--on'); [...document.querySelectorAll('.docs_sidebar ul li')].forEach(el => el.classList.remove('sub--on')); if (! active) { el.parentNode.classList.add('sub--on'); } }) }) // Highlight the active section in the table of contents... function setActiveTableOfContents () { const links = Array.from(document.querySelectorAll('.table-of-contents a')) const lastVisible = links .slice() .reverse() .find(link => { const el = document.querySelector(link.hash) return el.getBoundingClientRect().top <= 56; }) ?? links[0] links.forEach(link => { if (link === lastVisible) { link.classList.add('active') } else { link.classList.remove('active') } }) } setActiveTableOfContents() window.addEventListener('scroll', setActiveTableOfContents, { passive: true }) </script> </div> </section> </section> </div> </section> </div> <footer class="relative mt-12 pt-12 bg-gradient-to-b from-gray-50 to-white dark:from-dark-800 dark:to-dark-700"> <div class="max-w-screen-2xl mx-auto w-full px-8"> <div> <a href="https://laravel.com" class="inline-flex"> <img class="h-14" src="/img/logo.min.svg" alt="Laravel" loading="lazy"> </a> </div> <div class="mt-6 sm:mt-12"> <p class="max-w-sm text-xs text-gray-700 sm:text-sm dark:text-gray-500">Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experience to be truly fulfilling. Laravel attempts to take the pain out of development by easing common tasks used in most web projects.</p> <ul class="mt-6 flex items-center space-x-3"> <li> <a href="https://twitter.com/laravelphp"> <img id="footer__twitter_dark" class="hidden dark:inline-block w-6 h-6" src="/img/social/twitter.dark.min.svg" alt="Twitter" loading="lazy" width="24" height="20"> <img id="footer__twitter" class="inline-block dark:hidden w-6 h-6" src="/img/social/twitter.min.svg" alt="Twitter" loading="lazy" width="24" height="20"> </a> </li> <li> <a href="https://github.com/laravel"> <img id="footer__github_dark" class="hidden dark:inline-block w-6 h-6" src="/img/social/github.dark.min.svg" alt="GitHub" loading="lazy" width="24" height="24"> <img id="footer__github" class="inline-block dark:hidden w-6 h-6" src="/img/social/github.min.svg" alt="GitHub" loading="lazy" width="24" height="24"> </a> </li> <li> <a href="https://discord.gg/mPZNm7A"> <img id="footer__discord_dark" class="hidden dark:inline-block w-6 h-6" src="/img/social/discord.dark.min.svg" alt="Discord" loading="lazy" width="21" height="24"> <img id="footer__discord" class="inline-block dark:hidden w-6 h-6" src="/img/social/discord.min.svg" alt="Discord" loading="lazy" width="21" height="24"> </a> </li> <li> <a href="https://www.youtube.com/laravelphp"> <img id="footer__youtube_dark" class="hidden dark:inline-block w-6 h-6" src="/img/social/youtube.dark.min.svg" alt="YouTube" loading="lazy" width="169" height="150"> <img id="footer__youtube" class="inline-block dark:hidden w-6 h-6" src="/img/social/youtube.min.svg" alt="YouTube" loading="lazy" width="169" height="150"> </a> </li> </ul> </div> <div class="mt-10 border-t pt-6 pb-16 border-gray-200 dark:border-dark-500"> <p class="text-xs text-gray-700 dark:text-gray-400"> Laravel is a Trademark of Laravel Holdings Inc.<br /> Copyright &copy; Laravel Holdings Inc. </p> <p class="mt-6 text-xs text-gray-700 dark:text-gray-400"> Code highlighting provided by <a href="https://torchlight.dev">Torchlight</a> </p> </div> </div> </footer> </div> </body> </html>

Pages: 1 2 3 4 5 6 7 8 9 10