- https://speakerdeck.com/willroth/50-laravel-tricks-in-50-minutes
- https://www.reddit.com/r/laravel/comments/3to60i/50_laravel_tricks/
- 1. Automatic Model Validation
<?php | |
//dd($request->route()); | |
/* | |
$routes = []; | |
foreach (\Route::getRoutes()->getIterator() as $route){ | |
if (strpos($route->uri, 'api') !== false){ | |
$routes[] = $route->uri; | |
} | |
} |
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Chrome Develooper Panel Disabled</title> | |
</head> | |
<body> | |
<h1>Osman</h1> |
Chrome Ext: https://chrome.google.com/webstore/detail/custom-javascript-for-web/poakhlngfciodnhlhhgnaaelnpjljija
with jquery
$( function (){
$('tr.lista2').find('td:nth-child(2)').each (function() {
var link = $('a',this).attr('onmouseover').replace('return overlib(\'<img src=\\\'//','').replace('\\\' border=0>\')','');
$('a',this).removeAttr('onmouseover').removeAttr('onmouseout');
Source: https://medium.com/@Mahmoud_Zalt/eloquent-relationships-cheat-sheet-5155498c209
One to one ( 1-1 ) |
One to many ( 1-n ) |
Poly one to many ( 1x-n ) |
Many to many ( n-n ) |
Poly many to many ( nx-n ) |
|
---|---|---|---|---|---|
Number of models | 2 only | 2 only | 3 and above | 2 only | 3 and above |
Number of tables | 2 (1/model) | 2 (1/model) | 3+ (1/model) | 3 (1/model + pivot) | 4+ (1/model + pivot) |
Pivot table | - | - | - | required |
<?php | |
Blade::directive('active', function ($expression) { | |
return "<?php echo active_url($expression); ?>"; | |
}); |
/* | |
<a href="posts/2" data-method="delete"> <---- We want to send an HTTP DELETE request | |
- Or, request confirmation in the process - | |
<a href="posts/2" data-method="delete" data-confirm="Are you sure?"> | |
Add this to your view: | |
<script> | |
window.csrfToken = '<?php echo csrf_token(); ?>'; |
/* | |
<a href="posts/2" data-method="delete"> <---- We want to send an HTTP DELETE request | |
- Or, request confirmation in the process - | |
<a href="posts/2" data-method="delete" data-confirm="Are you sure?"> | |
*/ | |
(function() { |
<?php | |
function combinations($arrays, $i = 0) { | |
if (!isset($arrays[$i])) { | |
return array(); | |
} | |
if ($i == count($arrays) - 1) { | |
return $arrays[$i]; | |
} | |
// get combinations from subsequent arrays |