- 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 | |
namespace App\Providers; | |
use Illuminate\Support\Collection; | |
use Illuminate\Pagination\LengthAwarePaginator; | |
class AppServiceProvider extends ServiceProvider | |
{ | |
public function boot() |
sudo apt-get update
sudo apt-get install -y libappindicator1 fonts-liberation
cd /tmp
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo dpkg -i google-chrome*.deb
In case there was an error
sudo apt-get -f install
Pivot tables can be confusing and a little hard to wrap your head around at first. In this quick article we are going to dive into what a pivot table is, how to create one and finally how to use the pivot table. Let's dive in!
A pivot table is used to connect relationships between two tables. Laravel provides a Many To Many
relationship where you can use a pivot table.
If you need to pass a bound Alpine.js attribute to a Laravel Blade component, you can prefix the attribute name with two colons instead of a single colon to tell Blade to not evaluate the attribute as a PHP expression.
<div x-data="{ isActive: true }">
<x-some-blade-component ::is-active="isActive" />
</div>
<?php | |
namespace App\Http\Livewire; | |
use Livewire\Component; | |
use App\Models\User; | |
class CreateComment extends Component | |
{ | |
public $mentionables; |
The loading-states
extension allows you to easily manage loading states while a request is in flight, including disabling elements, and adding and removing CSS classes.
Add the hx-ext="loading-states"
attribute to the body tag or to any parent element containing your htmx attributes.
Add the following class to your stylesheet to make sure elements are hidden by default:
<?php | |
function exportCSV() | |
{ | |
header('Content-type: text/csv'); | |
header('Content-Disposition: attachment; filename=products.csv'); | |
header('Pragma: no-cache'); | |
header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); | |
header('Expires: 0'); |