Skip to content

Instantly share code, notes, and snippets.

View DollEunAnn's full-sized avatar
🏠
Working Where The WIFI Is

DollEunAnn

🏠
Working Where The WIFI Is
View GitHub Profile
@nasrulhazim
nasrulhazim / table.blade.php
Created February 18, 2018 12:20
Laravel: Reusable Blade Table
<div class="table-responsive">
<table class="table table-sm table-transparent table-hover"
id="{{ $table_id or 'table-id' }}">
<thead>
{{ $thead ?? '' }}
</thead>
<tbody>
{{ $tbody ?? '' }}
</tbody>
<tfoot>
@omurphy27
omurphy27 / laravel-eager-passing-parameters.php
Created December 28, 2016 23:24
Laravel Eloquent Eager Loading - Passing Parameters and Data to With Related Queries and Models
<?php
// must first define the relationships between your models
// see here: https://laravel.com/docs/5.3/eloquent-relationships#eager-loading
$result = Topic::where( 'slug', $slug )->approved()->with([
'comments' => function( $query ) use ( $data ) {
$query->take( $data['limit'] )
->skip( $data['limit'] * ( $data['page'] - 1 ) )
->with('user.profile')
@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);
});
/*