Open in app

Sign In

Write

Sign In

Rudashi
Rudashi

Home

About

Pinned

Laravel Stringable for JavaScript

Laravel has a great helper for strings. It’s called Fluent Strings. I present to you a new JS Stringable service inspired by Laravel Stringable class. Install the package to use it in your project. Installation npm install stringable-laravel

Laravel

1 min read

Laravel Stringable for JavaScript
Laravel Stringable for JavaScript
Laravel

1 min read


Pinned

Useful JS code snippets

In this article, you will find some of the most frequently used functions. 1. Password Generator const generatePassword = (length = 8) => { let CharacterSet = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()[]{}'; let password = ''; for (let i = 0; i < length; i++) { password += CharacterSet.charAt(Math.floor(Math.random() * CharacterSet.length)); } return password; };

JavaScript

1 min read

Useful JS code snippets
Useful JS code snippets
JavaScript

1 min read


Nov 18, 2020

JS —How to reset all values in a Javascript object

There are many ways to “reset” an object’s value in JavaScript. In this article, I will show you my approach to this case. 1. Default Object (not elegant) let item = { discount : true, percentage : false, qty : true, unit_price …

JavaScript

1 min read

JS — How to reset all values in an Javascript object
JS — How to reset all values in an Javascript object
JavaScript

1 min read


Nov 12, 2020

Laravel — Eloquent Model History

Wouldn’t it be cool if there was a history of the model in our project? Yes of course! You only need to add the HasHistory Trait and the HasHistoryInterface Interface to the choosen model. You will receive the history of actions performed on a given model in an easily accessible way: created updated deleted restored A user is assigned to each action, if logged in. This means that you can receive full information that a specific user has performed on tracked models.

Laravel Framework

1 min read

Laravel — Eloquent Model History
Laravel — Eloquent Model History
Laravel Framework

1 min read


Nov 7, 2020

Laravel — Logging Query Events

When creating an API, it is sometimes necessary to know if our code is not doing any unnecessary SQL queries. These few lines of code allow queries to be written to the /storage/logs/query.log use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\File; use Illuminate\Database\Events\QueryExecuted; private function queryListener(): void { DB::listen(function (QueryExecuted $q) { File::append( storage_path('/logs/query.log'), $q->sql.' ['.implode(', ', $q->bindings).']'.PHP_EOL ); }); }

Laravel

1 min read

Laravel

1 min read


Oct 28, 2020

Laravel — Deeply nested value

Quick Trick to anyone who had the same dilemma as me. How to get value from collection with one-to-many relationship ? The solution is really simple. Use Dot notation ! Post::with('users:id')->get()->pluck('users.*.id')->collapse(); Simple and elegant.

Laravel

1 min read

Laravel

1 min read

Rudashi

Rudashi

Full-Stack Developer

Help

Status

Writers

Blog

Careers

Privacy

Terms

About

Text to speech

Teams