Skip to content

Instantly share code, notes, and snippets.

View driesvints's full-sized avatar

Dries Vints driesvints

View GitHub Profile
@driesvints
driesvints / laravel-weekly-23-quick-tip.php
Last active October 23, 2018 07:52
Laravel Weekly #23 - Quick Tip
<?php
# Create a list with numbers ranging from 10 to 20.
Form::selectRange('number', 10, 20);
# Create a list with years ranging from 1900 to 2000.
Form::selectYear('year', 1900, 2000);
# Creates a list with month names.
Form::selectMonth('month');
@driesvints
driesvints / laravel-weekly-24-quick-tip.php
Created September 24, 2013 08:22
Laravel Weekly #24 - Quick Tip
<?php
// Redirect to a named 'home' route.
return Redirect::home();
// Refresh the current URI.
return Redirect::refresh();
@driesvints
driesvints / laravel-weekly-25-quick-tip.php
Last active March 28, 2019 13:52
Laravel Weekly #25 Quick Tip
<?php
// Get an array of all files in a directory.
$files = File::files('path_to_dir');
// Get all of the files from the given directory (recursive).
$files = File::allFiles('path_to_dir');
// Get all of the directories within a given directory.
$files = File::directory('path_to_dir');
@driesvints
driesvints / new-relic-deployment-notifications-in-envoyer.md
Last active October 26, 2020 14:17
Setup New Relic deployment notifications in Envoyer

While Envoyer comes with Slack and Hipchat notifications out of the box we'll have to setup New Relic notifications ourselves. Luckily it's as easy as adding a deployment hook. Here's how to:

  1. Add a new hook after the "Activate New Release" hook.
  2. Add the following curl command as the script:
curl -H "x-api-key:REPLACE_WITH_YOUR_API_KEY" -d "deployment[app_name]=REPLACE_WITH_YOUR_APP_NAME" https://api.newrelic.com/deployments.xml

And that's it! Envoyer will now let New Relic know each time a deployment's made. You can be sure the deployment succeeded because it happens after the new release has been made active.

<?php
use Illuminate\Contracts\Validation\Rule;
class ValidPaymentToken implements Rule;
{
/**
* @var \CreditCardGateway
*/
private $gateway;
<?php
use Illuminate\Contracts\Validation\Rule;
class ValidPaymentToken implements Rule;
{
private $gateway;
private $param1;
private $param2;
@driesvints
driesvints / SearchThreads.php
Last active November 6, 2024 14:28
Invokable query object
<?php
namespace App\Queries;
use App\Models\Thread;
use Illuminate\Contracts\Pagination\Paginator;
class SearchThreads
{
public function __construct()
@driesvints
driesvints / SearchThreads.php
Created July 3, 2017 07:37
Multiple method query objects
<?php
namespace App\Queries;
use App\Models\Thread;
use Illuminate\Contracts\Pagination\Paginator;
class SearchThreads
{
public function __construct()
@component('mail::button', ['color' => 'green'])
Button text
@endcomponent