docker-compose up -d
docker-compose up -d --build
<?php | |
// The issue this solves is to allow the user to upload a document and for us to save the document such that: the document is zip'd, the zip file is given a unique name, the zip file is password protected with a unique password, the password is encrypted for storage in the db table. | |
// The following will allow for creating one codeset to be called for the creation of all Documents. | |
// For the moment, we will need to set up IF statements for the statement that creates an instance of $Document | |
// which will allow for us to create a new entry in the appropriate database table. | |
public function storeInitDocument($request, $id, $theUserID, $ignore, $tableName){ | |
// This function will determine if the User has uploading any documents. If so, the document's properties will be stored, | |
// followed by the storage of the physical document with a unique name. The document will be |
// Create custom method for Query Builder | |
<?php | |
// You can put it the boot method of App\Providers\AppServiceProvider or a service provider of your own. | |
//Usage Model::whereLike('name', ['mike', 'joe'])->get() | |
//Usage Model::whereLike('message.type', ['text', 'sms'])->get(); | |
Builder::macro('whereLike', function ($attributes, $terms) { |
<?php | |
// SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes | |
use Illuminate\Support\Facades\Schema; | |
public function boot() | |
{ | |
Schema::defaultStringLength(191); | |
} |
Common syntax | Shorter and more readable syntax |
---|---|
Session::get('cart') | session('cart') |
$request->session()->get('cart') | session('cart') |
Session::put('cart', $data) | session(['cart' => $data]) |
$request->input('name'), Request::get('name') | $request->name, request('name') |
return Redirect::back() | return back() |
is_null($obj->relation) ? null : $obj->relation->id | optional($obj->relation)->id |
return view('index')->with('title', $title)->with('client', $client) | return view('index', compact('title', 'client')) |
request->has('value') ? request->value : 'default' | request->get('value', 'default') |
// Sorts an array of numbers, using the quicksort algorithm. | |
// Use recursion. | |
// Use the spread operator (...) to clone the original array, arr. | |
// If the length of the array is less than 2, return the cloned array. | |
// Use Math.floor() to calculate the index of the pivot element. | |
// Use Array.prototype.reduce() and Array.prototype.push() to split the array into two subarrays (elements smaller or equal to the pivot and elements greater than it), destructuring the result into two arrays. | |
// Recursively call quickSort() on the created subarrays. | |
const quickSort = arr => { |
// Sorts an array of numbers, using the selection sort algorithm. | |
// Use the spread operator (...) to clone the original array, arr. | |
// Use a for loop to iterate over elements in the array. | |
// Use Array.prototype.slice() and Array.prototype.reduce() to find the index of the minimum element in the subarray to the right of the current index and perform a swap, if necessary. | |
const selectionSort = arr => { | |
const a = [...arr]; | |
for (let i = 0; i < a.length; i++) { | |
const min = a |
// Sorts an array of numbers, using the heapsort algorithm. | |
// Use recursion. | |
// Use the spread operator (...) to clone the original array, arr. | |
// Use closures to declare a variable, l, and a function heapify. | |
// Use a for loop and Math.floor() in combination with heapify to create a max heap from the array. | |
// Use a for loop to repeatedly narrow down the considered range, using heapify and swapping values as necessary in order to sort the cloned array. | |
const heapsort = arr => { | |
const a = [...arr]; |
// Sorts an array of numbers, using the bucket sort algorithm. | |
// Use Math.min(), Math.max() and the spread operator (...) to find the minimum and maximum values of the given array. | |
// Use Array.from() and Math.floor() to create the appropriate number of buckets (empty arrays). | |
// Use Array.prototype.forEach() to populate each bucket with the appropriate elements from the array. | |
// Use Array.prototype.reduce(), the spread operator (...) and Array.prototype.sort() to sort each bucket and append it to the result. | |
const bucketSort = (arr, size = 5) => { | |
const min = Math.min(...arr); | |
const max = Math.max(...arr); |
// Implementation of the Luhn Algorithm used to validate a variety of identification numbers, such as credit card numbers, IMEI numbers, National Provider Identifier numbers etc. | |
// Use String.prototype.split(''), Array.prototype.reverse() and Array.prototype.map() in combination with parseInt() to obtain an array of digits. | |
// Use Array.prototype.splice(0, 1) to obtain the last digit. | |
// Use Array.prototype.reduce() to implement the Luhn Algorithm. | |
// Return true if sum is divisible by 10, false otherwise. | |
const luhnCheck = num => { | |
let arr = (num + '') | |
.split('') |