Skip to content

Instantly share code, notes, and snippets.

@nickdavies791
nickdavies791 / .env.testing
Created February 15, 2019 09:44
Laravel 5.7, Travis CI and Forge Testing and Deployment
APP_NAME=Laravel
APP_ENV=testing
APP_KEY= // key here
APP_DEBUG=true
@nickdavies791
nickdavies791 / Asset.php
Last active March 28, 2019 08:50
A few snippets from Asset Manager
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Asset extends Model
{
/**
* The attributes that are mass assignable.
@nickdavies791
nickdavies791 / PagesController.php
Last active April 1, 2019 08:50
Using the __invoke method for dynamic view rendering in Laravel
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class PagesController extends Controller
{
/**
* Return the requested view.
@nickdavies791
nickdavies791 / phpunit.xml
Created April 1, 2019 10:05
Useful snippet in PHPUnit to show which line caused the test to fail
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false">
@nickdavies791
nickdavies791 / Orders.sql
Created October 25, 2019 14:48
Returns unsigned purchase orders over given date
----------------------------------------
/**
*
* Returns unsigned POs over x days old
*
* ORDDAT (Order date) <= 'xxx'
* APPFLG (Signed) < 3 (No/Partly)
* CLEFLG (Closed) <> 2 (No)
* FLGSIG (Signature) = 3 (To be signed)
*
@nickdavies791
nickdavies791 / VAT.sql
Created October 25, 2019 14:49
Fetches invoice data for Malta VAT Return
----------------------------------------
/**
*
* Returns Malta VAT Information.
*
*/
----------------------------------------
SELECT
poh.POHNUM_0 AS order_number,
#########################################################
##
## Uploads a file to a given folder and renames.
##
#########################################################
Funprog UPLOAD_FILE_AND_RENAME(TEMPDIR, FILDIR, FILNAM, NEWNAM)
Variable Char TEMPDIR, FILDIR, FILNAM, NEWNAM
Local Integer COPYSTA
Local Integer MOVESTA
----------------------------------------
/**
*
* Returns number of purchase orders
* raised this period per company.
*
*/
----------------------------------------
WITH
orders_by_company (company, order_count)
@nickdavies791
nickdavies791 / suppliers_with_first_orders.sql
Created February 10, 2020 16:17
A list of suppliers with the date of their first order
----------------------------------------
/**
*
* All suppliers that have had an order
* raised for them.
*
*/
----------------------------------------
WITH order_list AS (
SELECT
@nickdavies791
nickdavies791 / mailing_list.sql
Last active February 21, 2020 09:03
Concatenates all email addresses of active users from table into mailing list
WITH
email_list (concatenated_emails)
AS
(
SELECT
ADDEML_0 + ';'
FROM
AUTILIS
WHERE
ENAFLG_0 = 2