This file contains 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
SET @count = 0; | |
UPDATE `tablename` SET `tablename`.`id` = @count:= @count + 1; | |
ALTER TABLE `tablename` AUTO_INCREMENT = 1; |
This file contains 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 Themes\Pharmacy4u\Models\Traits; | |
trait InsertIgnoreModelTrait | |
{ | |
public static function insertIgnore($values){ | |
$self = new static(); | |
$query = $self->newBaseQueryBuilder(); | |
if (empty($values)) return true; |
This file contains 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
use Carbon\Carbon; | |
public function getCreatedAtAttribute($value) | |
{ | |
//fixes 0000-00-00 00:00:00 date to return 1970-01-01 09:30:00 instead of -0001-11-30 00:00:00 | |
return Carbon::createFromTimeStamp($value)->toDateTimeString(); | |
} |
This file contains 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
$file_name = 'anything'; | |
$rel_path = 'uploads/' . str_slug($file_name) . '.csv'; | |
$full_path = public_path($rel_path); | |
$f = fopen($full_path, 'w'); | |
$firstLineKeys = false; | |
Model::select('data', 'data2')->chunk(500, function($entries) use ($f, $firstLineKeys) { | |
$array = json_decode(json_encode($entries), true); |
This file contains 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
function scaleObject(object, w_factor, h_factor) | |
{ | |
var scaleX = object.scaleX; | |
var scaleY = object.scaleY; | |
var left = object.left; | |
var top = object.top; | |
var tempScaleX = scaleX * w_factor; | |
var tempScaleY = scaleY * h_factor; | |
var tempLeft = left * w_factor; |
This file contains 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
<style> | |
.wrapper { | |
position: relative; | |
} | |
.sidebar, .content { | |
min-height: 100%; | |
} | |
</style> |
This file contains 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 | |
Str::macro('sentences', function($value, $sentences = 2, $end = '...') | |
{ | |
preg_match('/(.+?(?:(?<![\s.]\p{Lu})[.!?])){1,'.$sentences.'}/u', $value, $matches); | |
if (! isset($matches[0]) || static::length($value) === static::length($matches[0])) { | |
return $value; | |
} |
This file contains 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; | |
use Laravel\Scoute\Builder; | |
use Illuminate\Http\Request; | |
abstract class QueryFilters | |
{ | |
/** |
This file contains 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 | |
$json = <<<EOT | |
{"PASTE_YOUR":"JSON_HERE"} | |
EOT; | |
echo '[' . PHP_EOL; | |
jsonToArray(json_decode($json, true), 1); | |
echo ']'; |
OlderNewer