Skip to content

Instantly share code, notes, and snippets.

View ionutmilica's full-sized avatar

Ionut Milica ionutmilica

  • Romania
View GitHub Profile
@ionutmilica
ionutmilica / AuthService.php
Last active September 5, 2017 16:41
Using Laravel 5.5 render for exceptions
<?php
class AuthService {
// ----
public function issueToken(array $credentials)
{
$token = $this->apiGuard()->attempt($credentials);
throw_if(!$token, InvalidCredentials::class);
@ionutmilica
ionutmilica / app.js
Created August 24, 2017 12:13
Laravel Mix in Express (node) apps
const path = require('path');
const { mixFn } = require('./mix');
// mixFn will parse and store the manifest file internally
// it returns a new
const mix = mixFn(path.join(__dirname, 'public')); // where laravel-mix generates the manifest and hot files
console.log(mix('/css/app.css')); // /css/app.css?id=2995d68b12d2d1326355
console.log(mix('/js/js.css')); // /js/app.js?id=87e01f645f82f2f01ab3
@ionutmilica
ionutmilica / knex-paginator.js
Last active June 6, 2019 13:18
Simple paginator function for knex
module.exports = (knex) => {
return async (query, options) => {
const perPage = options.perPage || 10;
let page = options.page || 1;
const countQuery = knex.count('* as total').from(query.clone().as('inner'));
if (page < 1) {
page = 1;
}