Skip to content

Instantly share code, notes, and snippets.

View sentiasa's full-sized avatar
👊
Focused

sentiasa

👊
Focused
View GitHub Profile
@sentiasa
sentiasa / app.js
Last active February 5, 2024 23:12
Vite setup for Laravel, Inertia, Vue, Tailwind
import 'vite/dynamic-import-polyfill';
import '../css/app.css';
import { createApp, h } from 'vue'
import { App, plugin } from '@inertiajs/inertia-vue3'
let asyncViews = () => {
return import.meta.glob('./Pages/**/*.vue');
}
const app = createApp({
@sentiasa
sentiasa / RetryFailedJobsViaHorizon.php
Last active March 26, 2024 09:16
Command for retrying failed horizon jobs
<?php
use Laravel\Horizon\Contracts\JobRepository;
use Laravel\Horizon\Jobs\RetryFailedJob;
class RetryFailedJobsViaHorizon extends Command
{
protected $signature = 'horizon:retry-failed-jobs';
protected $description = 'Retry failed jobs via horizon';
@sentiasa
sentiasa / laravel-query-too-many-placeholder.php
Last active March 6, 2023 01:48
Laravel - Query +100k placeholders in Laravel using `whereIn()`
<?php
$transactionIds = Transaction::pluck('id'); // +100k transaction ids
$maxAtOneTime = 5000;
$total = count($transactionIds);
$pages = ceil($total / $maxAtOneTime);
$transactions = collect();
@sentiasa
sentiasa / LaravelBulkUpdate.php
Last active March 15, 2021 11:26
Laravel Bulk/Mass Update
<?php
$vat = 0.20;
$transactions = Transaction::get();
foreach ($transactions->chunk(5000) as $chunk) {
$cases = [];
$ids = [];
$params = [];
@sentiasa
sentiasa / error-handling-mixin.js
Last active June 6, 2023 02:00
Laravel Ajax Error Hadling
export default {
methods: {
handleAjaxError(err) {
let errorText = err.response.data.message;
if (err.response.status === 422) {
errorText = this.convertLaravelErrorBagToString(err.response.data.errors);
}
// Here errorText variable should be ready to show all the error message in a string format,
// which I could simply display it.