Skip to content

Instantly share code, notes, and snippets.

@ciamarro
ciamarro / livewire-directive.md
Created March 18, 2020 13:15
@livewire directive for phpstorm
  1. File > Settings > Languages & Frameworks > PHP > Blade
  2. Uncheck use default settings
  3. Directives > +
  4. Name livewire
  5. Prefix <?php '', [
  6. Suffix ])?&gt;
@tillsanders
tillsanders / intro.markdown
Last active June 24, 2021 20:17
Laravel: drag-and-drop repositioning with auto-save of DB entries

Laravel: drag-and-drop repositioning with auto-save of DB entries

Use case: Database entries are represented in a table. By grabbing and moving a row up or down the table, you can change the entries' order/position. The changes are submitted automatically via ajax.

  • Uses jQueryUI (custom download: sortable is needed)
  • newly created elements are added to the top (see route /jobs/create)
@elena-kolevska
elena-kolevska / validators.php
Last active June 24, 2021 14:44
Custom alphabetic validator that allows spaces
<?php
/* app/validators.php */
Validator::extend('alpha_spaces', function($attribute, $value)
{
return preg_match('/^[\pL\s]+$/u', $value);
});
/*
@msurguy
msurguy / DB.sql
Last active August 20, 2023 18:02
Dynamic dropdown in Laravel, let's say you have multiple drop downs (selects), you click on one and the contents of the other need to be dynamically changed. One solution is to dynamically load JSON from the API and change the dropdown dynamically depending on the user choice.
CREATE TABLE `makers` (
`id` int(10) unsigned NOT NULL,
`name` varchar(255) NOT NULL,
`description` varchar(255) NOT NULL,
`created_at` datetime NOT NULL,
`updated_at` datetime NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--