This is the first of a series of posts I will write that go back to basics and introduce the fundamentals of PHP. In this article I’m going to start with the PHP if statement.
Sometimes you need to get data out of your Laravel app so it can be analysed. There are many ways of doing this, such as exporting rows from the database, or using a package such as Laravel Excel, but this example will utilise Laravel Resource Collections.
I would like to introduce a new Laravel package I have been working on for a little while called Bulma Blade UI. It offers a set of reusable Blade components with the Bulma html structure and CSS classes, as well as basic authentication views for use with Laravel Fortify, ready to go with minimal setup.
I recently discovered that you can test an artisan console command very easily in Laravel 8 and make assertions on the output. In this example we are going to make a console command to import some products into our database from a csv file and then test they are all added as expected.
Laravel 8 introduced new class based model factories and if you have an existing project you can use the legacy factories package to keep using the old factories. I have tended to keep the factories as they were and continue development, but after working on a fresh Laravel 8 project and using the new class based syntax I decided to go back and update the factories in the older Laravel apps. This article explains how I went about refactoring the factories to classes.