Conditional logic with the CASE expression in SQL
CASE is SQLs answer to other programming languages IF-ELSE statement. If you need to test a condition and return a value CASE is the expression you need.
Read more [www.helenanderson.co.nz]
Posts tagged with tutorial
CASE is SQLs answer to other programming languages IF-ELSE statement. If you need to test a condition and return a value CASE is the expression you need.
Read more [www.helenanderson.co.nz]
Kent C. Dodds guides us through creating our first function on Netlify.
Luckily for us, almost exactly one year ago from the time I'm writing this, Netlify took the complexity of AWS Lambda functions and made it super simple.
Read more [kentcdodds.com]
Join 9,500+ smart developers
Get my monthly newsletter with what I learn from running Spatie, building Oh Dear, and maintaining 300+ open source packages. Practical takes on Laravel, PHP, and AI that you can actually use.
No spam. Unsubscribe anytime. You can also follow me on X.
"Freek publishes a super resourceful and practical newsletter. A must for anyone in the Laravel space"
Lorna Jane gives a good overview of the tools available when working on an API.
As Web Developers, we need to know how to work with HTTP from every angle. I gave a 2-hour tutorial at PHP UK that included some of my most trusted tools - but it was sold out and a bunch of people asked me if there was video (there wasn't, tutorials make little sense when videoed). Instead, I thought I'd try to set out a self-study version of the workshop (I rarely teach these days so I'm unlikely to deliver it anywhere else).
Read more [lornajane.net]
Want to upgrade to the PHP release? Here are some instructions written down by Colin O' Dell.
PHP 7.3 has been released, bringing some great new features to the language such as trailing commas in function calls, throwing errors when JSON parsing fails, array_key_first() / array_key_last() functions, and much more! Here's a brief guide on how to install PHP 7.3 on Linux, Windows, and OS X:
Nick Basile, UX instructor at Lambda school, write a good practical tutorial on creating custom Nova actions.
In my last post, we started building a simple CRM using Laravel Nova. It was pretty complete when we left it, but I think we can add a few more features and explore the rest of what Nova has to offer. In this walkthrough, we'll take a look at how to use Nova's Actions and authorization.
Read more [nick-basile.com]
My buddy Frederick Vanbrabant, who is currently looking for a new opportunity, recorded a cool video course on how to build a PHP framework using some popular components. Here's the playlist that contains all the episodes.
Over at Laravel News Povilas Korop wrote a nice tutorial on how to use our medialibrary (we released a new major version a couple of days ago).
By default, the Laravel registration form contains only the name, email, and password, but often it’s useful to allow the user to upload a photo or an avatar. In this tutorial we will show you an easy way to add it, using Spatie’s Media Library package.
https://laravel-news.com/uploading-avatar-images
It's a good tutorial but there's a few things not mentioned. At the end of the post you'll see this line of code:
Auth::user()->getMedia('avatars')->first()->getUrl('thumb');
That can be written a bit shorter as :
Auth::user()->getFirstMediaUrl('avatars', 'thumb');
The new v7 of the medialibrary has a new feature called "single file collections", which is just perfect for this example. Take a look at the docs: https://docs.spatie.be/laravel-medialibrary/v7/working-with-media-collections/defining-media-collections#single-file-collections
Today I accidentally committed a multi GB file to the git repo of the project I was working on and pushed it. Damn! Because of that big file cloning the repo again would take a long long time. Removing the file locally and pushing again would not solve the problem as that big file is in Git's history.
So I took a few moments to Google around and learned that that there actually is a git command that can rewrite history: filter-branch. This is how I removed that big file from history:
git filter-branch --tree-filter 'rm path/to/your/bigfile' HEAD
git push origin master --force
Both commands took a while to complete, but after that I had a light repo again.
If you need to do this, be sure to keep a copy of your repo around in case something goes wrong.
Here's an old, but still seemingly still correct blogpost by Dalibor Nasevic with some more info on the subject.
Few weeks ago I froze gems on my blog and ended up with a very big repository. So, I wanted to clean up the mess and remove permanently gems folder from the repository. git rm wasn't doing the job well, it only removes the folder from the working tree and the repository still contains the objects of this folder. After a quick search, I found that git-filter-branch was the command I was looking for.
https://dalibornasevic.com/posts/2-permanently-remove-files-and-folders-from-a-git-repository
Povilas Korop, creator of Laravel Daily and Quick Admin Panel, wrote an extensive guide on how to integrate Stripe into a Laravel application.
Stripe is one of the most popular payment merchants for web, but information about Laravel integration is pretty fragmented, so I decided to write a really long tutorial about this topic.We will cover:
- General logic how Stripe works
- Simple one-time payment integration
- Testing and production environment setup
- Saving transaction data for future reference
- Recurring payments with Laravel Cashier
- Getting invoices data and PDF download
https://quickadminpanel.com/blog/stripe-payments-in-laravel-the-ultimate-guide/
Welcome to part 3 of a series on how to test a Vue component. Here's the table of contents of the series: Starting out with tests The first test and snapshot testing Creating an instance of a component (you're here) More tests and faking time Jest awesomeness and a skeleton to get started Creating…
On the sitepoint blog Bruno Skvorc explains some of the inner works of the PHP version of snake created by Andrew Carter.
At a recent conference in Bulgaria, there was a hackathon for which Andrew Carter created a PHP console version of the popular “snake” game.I thought it was a really interesting concept, and since Andrew has a history of using PHP for weird things, I figured I’d demystify and explain how it was done.
https://www.sitepoint.com/howd-they-do-it-phpsnake-detecting-keypresses/
Over at Sitepoint, Younes Rafie wrote a tutorial on how to create a custom mail driver in Laravel 5.3. In the post he shows some code that can log all email to the database.
One of the many goodies Laravel offers is mailing. You can easily configure and send emails through multiple popular services. ... Laravel also provides a good starting point for sending mails during the development phase using the log driver, and in production using smtp, sparkpost, mailgun, etc. This seems fine in most cases, but it can’t cover all the available services! In this tutorial, we’re going to learn how to extend the existing mail driver system to add our own.
https://www.sitepoint.com/mail-logging-in-laravel-5-3-extending-the-mail-driver/
Over at Laravel News Eric L. Barnes posted a new tutorial on how he used our Analytics package to create a list of most popular posts. Great stuff!
Here on Laravel News, I wanted to generate a list of the most popular posts for the past seven days and display the results from most popular to least popular.To solve this problem I thought of two solutions. The first is to build my own tracking system so I could keep a count and then use it for ordering. However, that could generate a huge amount of data and it seemed like a solution that an analytics tracking service could handle.
As I was fumbling through the Google Analytics API I found a Laravel Analytics package by Spatie.be that allows you to easily retrieve data from your Google Analytics account and it seemed like the best way to solve this problem. Let’s look at how I used it to generate a list of popular posts here on Laravel News.
https://laravel-news.com/2016/09/most-popular-list-laravel-google-analytics/
In a new post on his site, Christoph Rumpel explains how you can quickly build a Facebook chatbot with PHP.
The chatbot topic is huge right now. Finally there is something quite new again and nobody knows what's happening next. This is the perfect time to start experimenting with chatbots and to build your own one right now. Give me 10 minutes of your time and I will give you your first chatbot!
http://christoph-rumpel.com/2016/08/build-a-php-chatbot-in-10-minutes/
In a post on his site Mattias Geniar shares how to write for loops in Bash.
Let me first start by saying something embarrassing. For the first 4 or 5 years of my Linux career -- which is nearing 10 years of professional experience -- I never used loops in Bash scripts. Or at the command line.The thing is, I was a very fast mouse-clicker. And a very fast copy/paster. And a good search & replacer in vim and other text editors. Quite often, that got me to a working solution faster than working out the quirky syntax, testing, bugfixing, ... of loops in Bash.
And, to be completely honest, if you're managing just a couple of servers, I think you can get away with not using loops in Bash. But, once you master it, you'll wonder why you haven't learned Bash for-loops sooner.
Mohamed Said has a new tutorial on his blog where he shows a very nice why to conditionally add some instructions to a query.
http://themsaid.github.io/laravel-query-conditions-20160425/
Very neat! Love that if-macro.
Christopher Pitt posted a tutorial on creating composer plugins on the Sitepoint blog.
Composer is the sharpest tool in the toolbox of the modern PHP developer. The days of manual dependency management are in the distant past, and in their place we have wonderful things like Semver.http://www.sitepoint.com/drunk-with-the-power-of-composer-plugins/...
Recent changes have made it much easier to develop Composer plugins.
Eric L. Barnes, the curator of Laravel News, recently launched his new website called dotdev. It aims to be a resource for developers who want to read quality reviews and tutorials amongst other things.
Although the site in general doesn't focus on Laravel, Eric wrote a good introductory post for people who are new to the framework. Unlike most beginner level articles, it focuses on creating a real world application.
My goal with this is to create a guide for those just learning the framework. It is setup to take you from the very beginning of an idea into a real deployable application. ... I am attempting to go through the process of creating a new application just as I would in a real world environment. In fact, the code and idea is taken from a project that I built.
https://dotdev.co/tutorials/step-by-step-guide-to-building-your-first-laravel-application/
For the first batch of posts on the site I made a playlist for coding late at night. Do you have something to share that would interest the readers of dotdev? Read these guidelines on guest posting first, and thenemail Eric.
At Spatie we're constantly improving our application template called Blender. We love using packages to pull in functionality. Creating and using packages has many benefits. Though we try to create public packages that benefit the community, there are some packages that are very specific to Blender.…