Skip to content

Instantly share code, notes, and snippets.

View tabacitu's full-sized avatar

Cristian Tăbăcitu tabacitu

View GitHub Profile
@tabacitu
tabacitu / BanHistoryOperation.php
Created June 15, 2023 11:26
Ban Operation Example
<?php
namespace App\Http\Controllers\Admin\Operations;
use Illuminate\Support\Facades\Route;
use Backpack\CRUD\app\Http\Controllers\Operations\Concerns\HasForm;
trait BanHistoryOperation
{
use HasForm;
@tabacitu
tabacitu / example.js
Created January 9, 2023 06:17
Example for using the CrudField JS API
crud.field('owners').subfield('owner_id').onChange(function(subfield) {
// TODO: do an AJAX call to an API you control;
// the easiest would be to make a call to the FetchOperation on the same CrudController
let ownerId = subfield.value;
let theValueYouWantToSet = 'something';
crud.field('owners').subfield('nick', subfield.rowNumber).input.value = theValueYouWantToSet;
});
@tabacitu
tabacitu / install-extensions.sh
Created December 28, 2022 08:04
VSCode Settings Tabacitu
code --install-extension absszero.vscode-laravel-goto --force &
code --install-extension amiralizadeh9480.laravel-extra-intellisense --force &
code --install-extension austenc.laravel-blade-spacer --force &
code --install-extension beyondcode.tinkerwell --force &
code --install-extension bmewburn.vscode-intelephense-client --force &
code --install-extension cierra.livewire-vscode --force &
code --install-extension codingyu.laravel-goto-view --force &
code --install-extension emmanuelbeziat.vscode-great-icons --force &
code --install-extension Equinusocio.vsc-community-material-theme --force &
code --install-extension faelv.composer-companion --force &
@tabacitu
tabacitu / todo.md
Created November 3, 2022 16:58
New Backpack field checklist

New field checklist:

  • does the value get saved to the database?
  • does the value need to be casted to something in the Model? is it mandatory? should it support both?
  • can the dev increase/decrease the size using Bootstrap classes?
  • does resizing also work with Fluent field syntax? eg. ->size(6)?
  • does it support ->disabled() and ->readonly()
  • does it support ->default()?
  • has all jQuery been removed in favor of vanilla Javascript?
  • have the CSS and JS dependencies been loaded with @loadOnce?
  • have the CSS and JS dependencies been pushed to proper stacks (after_scripts and after_styles)
@tabacitu
tabacitu / ProductCrudController.php
Last active April 6, 2022 06:42
Test JS Library for working with Backpack fields - v0.7.0-alpha
<?php
//...
protected function setupCreateOperation()
{
// ..
Widget::add()->type('script')->content('assets/js/product-form.js');
@tabacitu
tabacitu / .php-cs-fixer.dist.php
Created September 3, 2021 06:27
PHP-CS-Fixer Configuration File for the Laravel Code Style
<?php
/**
-----------------------------------------------------
Enforce the Laravel Code Style using PHP CS Fixer 3.x
-----------------------------------------------------
Credits go to Laravel Shift & Andreas Elia.
https://gist.github.com/laravel-shift/cab527923ed2a109dda047b97d53c200
@tabacitu
tabacitu / README.md
Last active May 28, 2021 14:48
Awesome Protocol Handlers - Open your Code Editor when Clicking Specific Links

How do you make sublime:// or vscode:// links actually open files in that editor?

Rephrased: you'd expect an URL like subl://open/?url=file:///etc/passwd&line=10&column=2 to open in... Sublime Text. Right? Well that doesn't happen by default, because that protocol doesn't exist, you need a new protocol handler. This article is here to help you do just that.

Unfortunately... there's never been a single source, where you can learn how to do that no matter what OS or editor you use. Until now. Please help us make this the source of information on this topic, we're all tired of searching for this 😀

Windows Mac OS Linux
Visual Studio Code ??? ??? ???
Sublime Text ??? ??? ???
@tabacitu
tabacitu / howto.md
Last active December 16, 2020 18:47
How to Deploy a Laravel+Backpack project on Laravel Vapor

Note: HUGE thanks to @mwisner, he's the one who figured out the solution here, and put together the first solution here. This is just a rephrasing of his solution, as a step-by-step guide that I think will apply to most Backpack projects.

How to deploy a Laravel+Backpack project on Vapor

Step 1. Follow the Vapor docs to install vapor, vapor-core and maybe even vapor-ui. Normally you do that by running vapor init.


@tabacitu
tabacitu / app\Http\Controllers\Admin\InvoiceCrudController.php
Last active December 31, 2020 08:55
Invoice Manager example - with repeatable field used to create and edit InvoiceItems
<?php
namespace App\Http\Controllers\Admin;
use App\Http\Requests\InvoiceRequest;
use Backpack\CRUD\app\Http\Controllers\CrudController;
use Backpack\CRUD\app\Library\CrudPanel\CrudPanelFacade as CRUD;
/**
* Class InvoiceCrudController
@tabacitu
tabacitu / ssh.sql
Created December 29, 2019 10:20
MySQL Dump Large Table Entries In Chunks
## This process can be used to export a huge DB table. I've used it to export a 24GB table,
## containing 146 million records, into chunks of 25 million records, each chunk taking up aprox 500mb each.
##
## Of course, USERNAME, DATABASENAME and TABLENAME need to be replaced with actual values.
## First thing when it's run, it'll ask for that user's password.
##
## COMMAND BREAKDOWN:
## mysqldump - u [username] -p [databasename] [tablename]
## --no-create-info # don't include CREATE and DROP statements in the dump
## --where="" # filter the dumped rows