Skip to content

Instantly share code, notes, and snippets.

<?php
function getFilePath($disk, $filename)
{
$config = config("filesystems.disks.$disk");
$url = app('filesystem')->disk($disk)->url($filename); // get the file url
$root = array_get($config, 'root');
// for other disks without root ex."cloud"
if (!$root){

Dont

  • hash the id on either boot::retrieved or getIdAttribute() because delete() & forceDelete() wont work as they create a new query which will keep getting the same hashed id

  • use Route::bind in the service provider as its applying the bind globally.

Maybe

  • save the hashed id to the db same as UUID but if u r using mysql, indexing will suffer

position sticky

for normal usage

parent shouldnt have

  • height
  • overflow

for flex, the direct parent should have "try without first"

  • align-self: flex-start;
<div class="item">ABC</div>
@keyframes spin {
    0% {
        transform: translate(0, 0) scale(1) rotateY(0deg);
    }
@ctf0
ctf0 / ScrollingLettersAnimation.js
Last active September 10, 2018 21:34
random char
/**
* demo1.js
* http://www.codrops.com
* https://github.com/codrops/ScrollingLettersAnimation
*
* Licensed under the MIT license.
* http://www.opensource.org/licenses/mit-license.php
*
* Copyright 2018, Codrops
* http://www.codrops.com
@ctf0
ctf0 / vue tips.md
Last active December 10, 2019 03:28

Js

  • clones
// to clone an object
this.x = Object.assign({}, this.y)

// to clone an array
this.x = this.y.slice(0)
<?php
namespace App\Traits;
use Fico7489\Laravel\Pivot\Traits\PivotEventTrait;
use OwenIt\Auditing\Auditable;
/**
* https://gist.github.com/AbbyJanke/4d245b22dbcec277c207f033f37dae3b.
*/
<?php

protected function groupSimilarByFunc($array, $fieldName, $similarity, $ignore_pattern = null)
{
    $crntLocale  = LaravelLocalization::getCurrentLocale();
    $list        = [];

    foreach ($array as $one) {
        $field = $one->$fieldName();
@ctf0
ctf0 / cron.bat
Last active November 8, 2020 13:38
laravel cron on windows
:loop
php artisan schedule:run 1>> NUL 2>&1
timeout /t 60 /nobreak > NUL
goto loop
<?php
namespace App\Exports;
use Maatwebsite\Excel\Events\AfterSheet;
use Maatwebsite\Excel\Concerns\Exportable;
use Maatwebsite\Excel\Concerns\WithEvents;
use Maatwebsite\Excel\Events\BeforeExport;
use Maatwebsite\Excel\Concerns\WithMapping;
use Maatwebsite\Excel\Concerns\WithHeadings;