Skip to content

Instantly share code, notes, and snippets.

@pxlrbt
pxlrbt / Readme.md
Last active September 30, 2022 20:20
Filament Geocoder

Usage

  • Install Geocoder Laravel: https://geocoder-php.org/docs/
  • Publish config php artisan vendor:publish (Look for Geocoder)
  • Setup your Google Geocoding API-Key in config/geocoder.php
<?php
Builder::macro('deferredPaginate', function ($perPage = null, $columns = ['*'], $pageName = 'page', $page = null) {
$model = $this->newModelInstance();
$key = $model->getKeyName();
$table = $model->getTable();
$paginator = $this->clone()
// We don't need them for this query, they'll remain
// on the query that actually gets the records.
@greenspace10
greenspace10 / AppServiceProvider.php
Created June 14, 2021 17:16
Laravel, Livewire, Alpine JS Toast Notifications
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
Component::macro('notify', function ($message, $title = '', $type = 'success') {
$this->dispatchBrowserEvent('notify', ['message' => $message, 'title' => $title, 'type' => $type]);
});
@tanthammar
tanthammar / always-on-top.js
Created May 14, 2021 17:31
JS Get highest z-index, always on top
window.findHighestZ = () => [...document.querySelectorAll('body *')]
.map(elt => parseFloat(getComputedStyle(elt).zIndex))
.reduce((z, highest=Number.MIN_SAFE_INTEGER) =>
isNaN(z) || z < highest ? (isNaN(highest) ? 1 : highest) : z
)
//vanilla
document.getElementById("foo").style.zIndex = window.findHighestZ()
@burnz
burnz / AnyLivewireComponent.php
Created April 22, 2021 06:54 — forked from binaryweavers/AnyLivewireComponent.php
Fluent toaster(alerts) for laravel/livewire using alpinejs and tailwindcss
public function showToasters(){
// default info toaster with timeout
$this->toaster('your message');
// makes it persistent
$this->toaster('your message')->persistent();
// warning toaster with timeout
$this->toaster('your message')->warning();
@rosswintle
rosswintle / AppNavigationMenu.php
Last active September 13, 2023 21:45
Laravel Jetstream Livewire Navigation Menu
<?php
/**
* This class extends the base NavigationClass provided by Jetstream.
* Note that the base class includes the navigation-menu.blade.php
*/
namespace App\Http\Livewire;
class AppNavigationMenu extends \Laravel\Jetstream\Http\Livewire\NavigationMenu
{
@Hailong
Hailong / Index.php
Last active November 25, 2020 01:23
Fix ShipStation plugin for Magento 2.3
<?php
namespace Auctane\Api\Controller\Auctane;
use Exception;
use Magento\Framework\App\CsrfAwareActionInterface;
use Magento\Framework\App\Request\InvalidRequestException;
use Magento\Framework\App\RequestInterface;
class Index extends \Magento\Framework\App\Action\Action implements CsrfAwareActionInterface
{
@santoshachari
santoshachari / Laravel PHP7 LEMP AWS.md
Last active February 20, 2024 10:00
Laravel 5.x on Ubuntu 16.x, PHP 7.x, Nginx 1.9.x

#Steps to install latest Laravel, LEMP on AWS Ubuntu 16.4 version. This tutorial is the improvised verision of this tutorial on Digitalocean based on my experience.

Install PHP 7 on Ubuntu

Run the following commands in sequence.

sudo apt-get install -y language-pack-en-base
sudo LC_ALL=en_US.UTF-8 add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install zip unzip
@h-collector
h-collector / Foo.php
Last active November 1, 2023 16:32
Standalone Laravel Queue + Redis example
<?php
namespace Jobs;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Redis\Database as Redis;
class Foo extends Job
{
use InteractsWithQueue;
@taufik-nurrohman
taufik-nurrohman / php-html-css-js-minifier.php
Last active February 23, 2024 04:30
PHP Function to Minify HTML, CSS and JavaScript
<?php
// Based on <https://github.com/mecha-cms/x.minify>
namespace x\minify\_ { // start namespace
$n = __NAMESPACE__;
\define($n . "\\token_boolean", '\b(?:true|false)\b');
\define($n . "\\token_number", '-?(?:(?:\d+)?\.)?\d+');