This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static function mergeJson($to, $from, $matchBy, $key) | |
| { | |
| $to = json_decode(file_get_contents(storage_path($to))); | |
| $from = json_decode(file_get_contents(storage_path($from))); | |
| $values = []; | |
| foreach($from as $object) { | |
| $values[$object->{$matchBy}] = $object->{$key}; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| implode(array, key = null, glue = ', ') { | |
| if(key) { | |
| array = array.map(function(element) { | |
| return element[key]; | |
| }) | |
| } | |
| return array.join(glue); | |
| }, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Get the portion of a string between two given strings. | |
| * | |
| * @param string $subject | |
| * @param string $start | |
| * @param string $end | |
| * @param bool $insensitive | |
| * @param bool $innerOnly | |
| * @param bool $inverse | |
| * |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| class SimpleXMLExtended extends SimpleXMLElement | |
| { | |
| // Inspired by: https://stackoverflow.com/questions/6260224/how-to-write-cdata-using-simplexmlelement/6260295 | |
| public function addCDATA($string) | |
| { | |
| $node = dom_import_simplexml($this); | |
| $nodeOwner = $node->ownerDocument; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static function testRename() | |
| { | |
| self::batchRename('s3', 'documents', function ($file) { | |
| return str_replace('%20', '-', $file); | |
| }); | |
| } | |
| public static function batchRename($disk, $directory, $callback) | |
| { | |
| $disk = \Illuminate\Support\Facades\Storage::disk($disk); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| namespace App\Engines; | |
| use Illuminate\Support\Collection; | |
| use Laravel\Scout\Engines\AlgoliaEngine; | |
| class AdvancedAlgoliaEngine extends AlgoliaEngine | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| namespace App\Http\Middleware; | |
| use Closure; | |
| class CorsHeaders | |
| { | |
| /** | |
| * Handle an incoming request. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| namespace App\Traits; | |
| trait LockColumns | |
| { | |
| /** | |
| * Cast locked_columns as a JSON column | |
| * | |
| * @return void |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| if(! class_exists(\LodeApp\PHPUnit\Console::class)) { | |
| function console($vars, $dump = true) { | |
| dump($vars); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public function scopeBySaleType($query, type) | |
| { | |
| $query->whereHas('sales', function ($query) use ($type) { | |
| $query->where('id', function ($sub) { | |
| $sub->from('sales') | |
| ->selectRaw('max(id)') | |
| ->whereColumn('sales.inventory_id', 'inventories.id'); | |
| })->where('type', $type); | |
| }); | |
| } |
OlderNewer