Skip to content

Instantly share code, notes, and snippets.

View ArtMin96's full-sized avatar

Arthur Minasyan ArtMin96

  • Yerevan, Armenia
  • 10:36 (UTC +04:00)
  • X @ArtMin96
View GitHub Profile
@ArtMin96
ArtMin96 / wire-errors.js
Created February 23, 2025 13:19
Add reactive $wire.$errors to show and remove errors without needing a network request
document.addEventListener('livewire:init'), () => {
Livewire.hook('component.init', ({ component }) => {
const errors = {}
component.ephemeral.$errors = Object.assign({}, errors)
component.reactive.$errors = Object.assign({}, errors)
})
Livewire.hook('commit.prepare', ({ component }) => {
delete component.ephemeral.$errors
delete component.reactive.$errors
@ArtMin96
ArtMin96 / alpine-vue.js
Last active February 12, 2025 18:49
Alpine + Vue + Livewire
document.addEventListener('alpine:init', () => {
Alpine.setReactivityEngine({
reactive: Vue.reactive,
effect: Vue.effect,
release: Vue.stop,
raw: Vue.toRaw
})
})
@ArtMin96
ArtMin96 / AppImage.desktop
Last active June 9, 2024 09:54
How to register an AppImage as a desktop application in Linux
1. Download the `.AppImage` file and an icon you would like to register it with
2. Move the `.AppImage` file to the path `/bin`, e.g. `sudo mv ~/Downloads/Vemto.AppImage /bin/`
3. Make it executable with `sudo chmod +x /bin/Vemto.AppImage`
4. Save the icon under `/usr/share/icons/custom/vemto.png` e.g. `sudo mkdir --parents /usr/share/icons/custom && sudo mv ~/Downloads/vemto.png /usr/share/icons/custom/`
5. Create a `.desktop` file under `~/.local/share/applications/vemto.desktop`
6. Paste the following content into it (make sure to remove the comments):
```
[Desktop Entry]
Name=Vemto
@ArtMin96
ArtMin96 / WhereLike.php
Created November 25, 2021 07:29
whereLike macro with relationship
/**
* Searching Eloquent models with Relations
*
* Example Post::whereLike(['name', 'text', 'author.name', 'tags.name'], $searchTerm)->get();
*/
Builder::macro('whereLike', function ($attributes, string $searchTerm) {
$this->where(function (Builder $query) use ($attributes, $searchTerm) {
foreach (\Arr::wrap($attributes) as $attribute) {
$query->when(
str_contains($attribute, '.'),