Skip to content

Instantly share code, notes, and snippets.

View breizhwave's full-sized avatar

Erwan Pianezza breizhwave

View GitHub Profile
@breizhwave
breizhwave / gist:0725431c5eb07ccddd54acfda5aa06ba
Last active October 13, 2019 16:57
Laravel Nova SearchableSelect linked on index
BelongsTo::make('Product')->rules('required')->hideWhenCreating()->hideWhenUpdating(),
SearchableSelect::make('Product', 'product_id')->resource("products")->loadResourcesOnNew()->displayUsing(function($product) {return $this->product->title ; })->hideFromIndex(),
@breizhwave
breizhwave / listSum.blade.php
Last active January 11, 2021 15:34
add sum in list blade
<script>
// Insert the sum of a column into the columns footer, for the visible
// data on each draw
// var table = $('#crudTable').DataTable();
// $("#wave_total").html( $('#crudTable').column( 3 ).data().sum());
jQuery(document).ready(function($) {
jQuery.fn.dataTable.Api.register( 'sum()', function ( ) {
return this.flatten().reduce( function ( a, b ) {
if ( typeof a === 'string' ) {
a = a.replace(/[^\d.-]/g, '') * 1;
@breizhwave
breizhwave / datatables_logic.blade.php
Created November 1, 2018 07:38 — forked from OwenMelbz/datatables_logic.blade.php
Backpack CRUD - Persistent Filters/Pages/Searches
<!-- DATA TABLES SCRIPT BREIZHWAVE20181009 from https://github.com/Laravel-Backpack/CRUD/issues/1457#issuecomment-404576891 -->
<script src="https://cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js" type="text/javascript"></script>
<script src="https://cdn.datatables.net/1.10.16/js/dataTables.bootstrap.min.js" type="text/javascript"></script>
<script src="https://cdn.datatables.net/responsive/2.2.1/js/dataTables.responsive.min.js"></script>
<script src="https://cdn.datatables.net/responsive/2.2.1/js/responsive.bootstrap.min.js"></script>
<script>
var crud = {
enablePersistance: true,
route: 'DataTables_{{ trim($crud->getRoute(), '/') }}',
@breizhwave
breizhwave / WaveCrudController.php
Created October 10, 2018 19:05
backpack crudcontroller helper
<?php
namespace App\Http\Controllers\Admin;
use Backpack\CRUD\app\Http\Controllers\CrudController;
// VALIDATION: change the requests to match your own file names if you need form validation
use App\Http\Requests\WaveResourceRequest as StoreRequest;
use App\Http\Requests\WaveResourceRequest as UpdateRequest;
class WaveCrudController extends CrudController
<?php
namespace App\Http\Controllers\Admin;
use Backpack\CRUD\app\Http\Controllers\CrudController;
// VALIDATION: change the requests to match your own file names if you need form validation
use App\Http\Requests\WaveResourceRequest as StoreRequest;
use App\Http\Requests\WaveResourceRequest as UpdateRequest;
class WaveCrudController extends CrudController
@breizhwave
breizhwave / ArticleCrudController.php
Created September 12, 2018 08:06
backpack hierachical select for nested items : example for newscrud
$this->crud->addField([ // SELECT
'label' => 'Category',
'type' => 'select2_grouped',//https://github.com/Laravel-Backpack/CRUD/issues/502
'name' => 'category_id',
'entity' => 'category',
'attribute' => 'name',
'model' => "Backpack\NewsCRUD\app\Models\Category",
'group_label_attribute' => 'name',
'group_entity' => 'Children'
]);
@breizhwave
breizhwave / 201801-product-show-get.js
Created January 9, 2018 12:08
woocommerce dynamic gallery : setup image variation on get parameters
jQuery( function( $ ) {
var gallery_container = $('.gallery_container');
var variations = {};
$('.variations select').each(function(){
if($(this).val() != '') {
variations[$(this).attr('id')] = $(this).val();
}});
console.log(count_length(variations))
if( count_length(variations) > 0 ) { // If we have some variation data, show the associated images