Skip to content

Instantly share code, notes, and snippets.

View mithicher's full-sized avatar

Mithicher mithicher

View GitHub Profile
@MrPunyapal
MrPunyapal / ExportCSV.php
Last active December 31, 2023 07:29
PHP Function to Export Products as CSV (without saving it in server)
<?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');
@jreviews
jreviews / htmx-loading-states-extension.md
Last active April 1, 2024 22:22
htmx loading states extension

htmx loading states extension

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.

Using the extension

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:

@fotrino
fotrino / CreateComment.php
Created September 28, 2021 14:35
@mentions with Alpine.js, Livewire & Tributeq
<?php
namespace App\Http\Livewire;
use Livewire\Component;
use App\Models\User;
class CreateComment extends Component
{
public $mentionables;

Pass Alpine.js Bound Attributes To Blade Component

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>
@Braunson
Braunson / pivot-tables.md
Last active May 15, 2024 08:12
Laravel 8.x - Diving into Pivot Tables

Laravel 6 - Diving Into Pivot Tables

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!

What is a pivot table?

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.

@alvinveroy
alvinveroy / digitalocean-headlesschrome.MD
Created February 21, 2019 13:26
Installing headless chrome and chromeless on digitalocean.
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
@simonhamp
simonhamp / AppServiceProvider.php
Last active November 1, 2024 18:28
A pageable Collection implementation for Laravel
<?php
namespace App\Providers;
use Illuminate\Support\Collection;
use Illuminate\Pagination\LengthAwarePaginator;
class AppServiceProvider extends ServiceProvider
{
public function boot()