Skip to content

Instantly share code, notes, and snippets.

@jarektkaczyk
jarektkaczyk / verbose-fatal-errors-in-artisan.php
Last active June 14, 2019 21:32
always show artisan fatal errors VERBOSE
<?php
// Add this override to your app/Exceptions/Handler.php
/**
* Render an exception to the console.
*
* @param \Symfony\Component\Console\Output\OutputInterface $output
* @param \Exception $e
* @return void
@jarektkaczyk
jarektkaczyk / gist:d0f89852205ec1ab69cb
Last active March 18, 2016 23:06
how to remove given child component from parent's array (including dynamically added elements) ?
<div id="some-id">
<category v-for="category in categories"
:id="category.id"
:name.sync="category.name"
</category>
// we add items to the categories array dynamically
<button @click="categories.push({})">Add categories</button>
</div>
@jarektkaczyk
jarektkaczyk / larave-request-vs-collection-only.php
Last active February 13, 2020 11:16
Laravel Request::only vs Collection (Arr) ::only
<?php
// given input ['name' => 'jarek']
Request::only('name', 'email')
[
"name" => "jarek",
"email" => null, // even if empty in the input, the key will be here
]
@jarektkaczyk
jarektkaczyk / Laravel5.1-sort-collection-by-multiple-integer-fields.php
Created August 18, 2015 12:36
Laravel 5 - how to sort collection by multiple integer fields
<?php
>>> $col = collect(json_decode(json_encode([['id' => 1,'bool' => 0, 'count' => 15], ['id' => 2, 'bool' => 1, 'count' => 20], ['id' => 3, 'bool' => 0, 'count' => 10], ['id' => 4, 'bool' => 1, 'count' => 16]])))
=> Illuminate\Support\Collection {#935
all: [
{#936
+"id": 1
+"bool": 0
+"count": 15
}
@jarektkaczyk
jarektkaczyk / gist:8d3e1f34e6e6c6970173
Last active August 5, 2016 02:06
Laravel5 helpers for tinkering with your app
<?php
/**
* Print query with bindings instead of '?'
*/
function toRaw($query)
{
return vsprintf(str_replace('?', "'%s'", $query->toSql()), $query->getBindings());
}