Skip to content

Instantly share code, notes, and snippets.

@Log1x
Log1x / PostSearch.php
Last active June 27, 2024 07:59
Post Search component example using Acorn v4 and Livewire 3
<?php
namespace App\Livewire;
use Livewire\Attributes\Url;
use Livewire\Component;
use WP_Query;
class PostSearch extends Component
{
@Shelob9
Shelob9 / vite.config.js
Created July 22, 2022 16:18
Code for Laravel vite React fast refresh with tailwind https://twitter.com/Josh412/status/1547628986695446530
import { defineConfig } from 'vite';
import laravel from 'laravel-vite-plugin';
export default defineConfig({
plugins: [
laravel({
input: 'resources/js/app.jsx',
refresh: [
'resources/js/app.jsx',
'front-end-client/src/**',
'resources/components/react.blade.php',
@sebastiaanluca
sebastiaanluca / CarbonImmutableCaster.php
Last active March 24, 2024 14:39
Lazy Laravel Harvest API service
<?php
declare(strict_types=1);
namespace App\DataTransferObjects;
use Carbon\CarbonImmutable;
use Spatie\DataTransferObject\Caster;
class CarbonImmutableCaster implements Caster
@sibelius
sibelius / webpack.tailwind.js
Created July 30, 2021 11:45
webpack tailwind production config
const webpackCommonConfig = require("./webpack.config");
const { merge } = require('webpack-merge');
const TerserPlugin = require('terser-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const { trimEnd } = require('lodash');
module.exports = merge(webpackCommonConfig, {
mode: 'production',
devtool: 'source-map',
optimization: {
@wmandai
wmandai / AppServiceProvider.php
Created June 23, 2021 21:21 — forked from greenspace10/AppServiceProvider.php
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]);
});
@rummykhan
rummykhan / Octane-Apache.conf
Last active February 3, 2024 20:52
Apache Configuration for Octane
#### Enable Apache Proxy related modules
sudo a2enmod proxy
sudo a2enmod proxy_http
sudo a2enmod proxy_ajp
sudo a2enmod rewrite
sudo a2enmod deflate
sudo a2enmod headers
sudo a2enmod proxy_balancer
sudo a2enmod proxy_connect
@troccoli
troccoli / CookieConsent.php
Created April 30, 2021 15:09
Cookie consent livewire component
<?php
namespace App\Http\Livewire;
use Livewire\Component;
class CookieConsent extends Component
{
public bool $askForConsent;
@Balakrishnan-flycart
Balakrishnan-flycart / Woo Discount Rules v2 - Get discount details against product.php
Last active March 2, 2023 04:44
Woo Discount Rules v2 - Get discount details against product
/**
* Get the discount details of given product with custom price
* @param $price float/integer
* @param $product object (Product object Example: wc_get_product($product_id))
* @param $quantity int
* @param $custom_price float/integer (0 for calculate discount from product price)
* @param $return_details string (Default value 'discounted_price' accepted values = 'discounted_price','all')
* @param $manual_request boolean (Default value false: pass this as true for get discount even if there is no item in cart)
* @param $is_cart boolean (Default value true)
* @return array|float|int - is product has no discounts, returns $price;else return array of discount details based on $return_details
@david-mart
david-mart / icon-url-generator.js
Last active May 23, 2020 22:04
icon-url-generator.js
import Vue from 'vue'
import LocationIcon from './LocationIcon'
// create a constructor from a Vue component
const LocationIconConstructor = Vue.extend(LocationIcon)
export const getColoredIconUrl = (fillColor, strokeColor) => {
// create a Vue element with required props
const iconComponent = new LocationIconConstructor({ propsData: { fillColor, strokeColor } })
// mount the component shadow DOM
<template>
<svg
width="28"
height="28"
viewBox="0 0 28 28"
>
<defs>
<circle id="my-location-a" cx="14" cy="14" r="8" />
</defs>
<g fill="none" fill-rule="evenodd">