Posts tagged with tutorial

Improving our Laravel Nova CRM

nick-basile.com

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]

Join thousands of developers

Every two weeks, I share practical tips, tutorials, and behind-the-scenes insights from maintaining 300+ open source packages.

No spam. Unsubscribe anytime. You can also follow me on X.

Uploading avatar Images with Spatie’s medialibrary

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

Read more

How to remove a big file wrongly committed to a Git repo

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

Read more

Handling Stripe payments in Laravel

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/

Read more

Testing a Vue component part 3: Creating an instance

by Freek Van der Herten – 4 minute read

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…

Read more

Creating a multiplayer snake game in PHP

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/

Read more

Creating a mail driver in Laravel

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/

Read more

How to create a most popular list with Laravel and Google Analytics

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/

Read more

Build a Facebook chatbot in 10 minutes with PHP

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/

Read more

The Bash For Loop, The First Step in Automation on Linux

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.

https://ma.ttias.be/bash-loop-first-step-automation-linux/

Read more

A step by step guide to building your first Laravel application

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.

Read more

How to run your own npm repository server

by Freek Van der Herten – 1 minute read

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.…

Read more