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 / .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 / 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 / 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 / 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 / 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 / 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;