Using the Blade Engine to Remove PHP Blade is a templating engine that allows you to write some front-end friendly code. The last thing that the designer wants to see is PHP wrapped up inside of the views. Looking at Blade components, you’ll quickly appreciate the elegance in the appearance vs the mess that PHP can create when used outside of the backend. Blade templates are compiled into PHP code, but we don’t need to worry about it. As long as we use the correct tags, Laravel/Blade will take care of this for us. .blade.php In order to use the

Organize Your Views Better With Subdirectories There are a couple of more concepts that we should look at before we move on to the blade templating engine. This time, we’ll cover subdirectories and one simple check to see if the view that we’re calling actually exists. Read the previous article on Passing Arguments to Views. Subdirectories Who cares about subdirectories? Why not just shove all of the views under one directory, views? It’s incredibly important for organization. Most of the time, you’ll list your resource name, likes users as a subdirectory of views, and then the 4 CRUD views: create.blade.php edit.blade.php index.blade.php show.blade.php

How to Pass Arguments to Views We know how to grab URL parameters and return them from our route, but how do we pass arguments to the view? Read the previous article to see how to pass arguments via the url. It’s a pretty simple thing to implement. Before we look at our route, let’s create a new blade file in the resources/views/ directory called car.blade.php. <!DOCTYPE html> <html lang=”{{ str_replace(‘_’, ‘-‘, app()->getLocale()) }}”> <head> <meta charset=”utf-8″> <meta name=”viewport” content=”width=device-width, initial-scale=1″> <title>Car</title> <!– Fonts –> <link href=”https://fonts.bunny.net/css2?family=Nunito:wght@400;600;700&display=swap” rel=”stylesheet”> <!– Styles –> <style> /*! normalize.css v8.0.1 | MIT License | github.com/necolas/normalize.css */html{line-height:1.15;-webkit-text-size-adjust:100%}body{margin:0}a{background-color:transparent}[hidden]{display:none}html{font-family:system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto

Pass Parameters to Your Laravel Route We ended our last article talking about basic routing and views. Frequently we need to pass arguments to our route file via URL parameters. If you’re familiar with PHP, you know that to capture an argument like https://example.com/results.php?page=4, we need to use the $_GET global array, i.e. $_GET[‘page’]. Passing a Single Argument In Laravel, we can pass arguments to the route file just as simply. <?php use Illuminate\Support\Facades\Route; Route::get(‘/about/{name}’, function ($name) { return $name; }); To declare a parameter, we need to surround the url parameter with curly braces. In the example above, we are expecting a “name.”

How To Route in Laravel It’s a difficult thing when it comes to thinking how to approach the learning process. I’m not a big fan of learning a specific concept, like Controllers, right away. I believe that you learn the best by moving slowly through the concepts. I’ll try to present these concepts in a strategic order. Hopefully it works for you. The purpose of this article is to see how we would normally get to a specific view. The only view that we have currently is the welcome view. If we wanted to modify what the user sees right now, what

A Visual Guide to Directory Structures Where do you put your files? How does Laravel know? These are a few questions that I normally get from individuals just starting out with Laravel, or really any other framework. Laravel creates a folder structure for you and it expects certain files to appear in specific places. If they’re not there, Laravel will not know what to do. It expects your controllers to be in the Http folder, it expects your models to be in the Models folder, etc. If you’re not familiar with those concepts yet, don’t worry, we’ll cover each of them

Get Ready to Docker Closing down the PHP project today felt a little sad. It’s a series that I’ve been working on for quite some time now and finally felt like I’ve exhausted the subject. I’ll probably continue with some more advanced topics since I don’t want it to end. As I write that, I feel a little better about it now. Let’s continue with my absolute favorite framework, Laravel. We briefly looked at the installation process in the previous article, and to be honest, it’s about as simple as it gets. There are a few different ways to install

Empower Your Web Development Journey Laravel is a PHP framework that gives you the tools you need to create sophisticated web applications, but it also allows you to focus on the application logic. It’s built with modern language features and supports multiple databases out of the box. What is Laravel? Laravel is a PHP framework built on the principle of convention over configuration. It’s a fully open-source, community-driven project that focuses on simplicity and elegance in building web applications. Laravel was created by Taylor Otwell in 2010 and has become one of the most popular PHP frameworks today. Laravel is built on top of the Symfony component

Integrating DataTables the Vue Way Last time we looked at setting up DataTables using the DataTables CDN. If you read the DataTables Vue documentation, that’s not what it states. To be as comprehensive as I possibly can be on this topic, I’ve decided to show this approach as well. To read the CDN approach, check out the article below. https://medium.com/geekculture/laravel-9-x-with-vue-js-and-datatables-b1299d0e6f09 For this article, I figured it would be good to start from scratch. No assumptions made. Let’s install it with a fresh installation of Laravel 10.x. We’ll go through setting up Vue.js and then setting up DataTables with Server Side

Customizing DataTables in Vue/Laravel A request came in that’s not completely out of the norm, but something that stumped me for a few hours. It wasn’t anything revolutionary. It was something that I’ve done before with a different type of implementation, but never like this. The request was, “can we add a dropdown list so that when we select an option, it would only load those items into the DataTables table. We want all of the items to load first and then if we need to narrow it down further, we’d like to have that capability.” Implementing this using Vue/jQuery