laravel

Handling Timestamp Column Changes in Laravel Migrations with PostgreSQL

Handling Timestamp Column Changes in Laravel Migrations with PostgreSQL

When working with Laravel migrations, developers may encounter issues when trying to change a column's type to timestamp, especially in a PostgreSQL environment. The problem arises from Laravel's reliance on Doctrine DBAL, which doesn’t natively support the timestamp type. The Problem: When using the change() method in Laravel migrations, a DoctrineDBALException may be thrown, stating that the timestamp type is unknown. This is because Doctrine DBAL does not support certain native database types, like timestamp, out of the box. The Workaround: To address this issue, a practical solution is to avoid using change() and instead, drop the column and recreate…
Read More
Implementing Infinite Scroll with Laravel and Vue.js 3

Implementing Infinite Scroll with Laravel and Vue.js 3

Infinite scroll is a more modern alternative to traditional pagination, providing a seamless user experience. In this blog post, we’ll implement infinite scroll in a Vue.js 3 application using Laravel as the backend. Prerequisites Basic knowledge of Laravel and Vue.js 3. A Laravel project with an API to paginate data (e.g., User model). Section 1: Setting Up the Basic Vue.js 3 Component for Infinite Scroll Step 1: Create the Backend API Create a simple API in your Laravel application to return paginated data: routes/api.php use AppModelsUser; use IlluminateHttpRequest; Route::get('/users', function (Request $request) { return User::paginate(10); }); Enter fullscreen mode Exit…
Read More
Laravel Maps : Leaflet et Google Maps

Laravel Maps : Leaflet et Google Maps

Cartes LaravelCe package vous permet d'utiliser facilement leaflet.js ou Google Maps pour créer une carte dans votre projet laravel. Installation Vous pouvez installer le package via composer : composer require larswiegers/laravel-maps Si vous souhaitez personnaliser davantage les vues de la carte, vous pouvez publier les vues : php artisan vendor:publish --provider="LarswiegersLaravelMapsLaravelMapsServiceProvider" Hôtes de tuiles Openstreetmap :Openstreetmap est une bibliothèque de tuiles créative créée par des bénévoles. Aucune configuration n'est nécessaire pour l'utiliser car il s'agit de l'hôte de tuiles par défaut pour cette bibliothèque. Vous trouverez plus d'informations ici : openstreetmap.org Usage : // Leaflet // A basic map is…
Read More
Passing query parameters through import.meta.url to vue with Laravel Vite

Passing query parameters through import.meta.url to vue with Laravel Vite

import.meta.url. For JavaScript modules, you can use the import.meta object to access its own meta information. import.meta - JavaScript | MDN Therefore, <script type="module" src="app.js?someURLInfo=5"></script> Enter fullscreen mode Exit fullscreen mode At this time, app.js module is able to get its own URL with query parameters and hash through import.meta.url.In other words, You can pass values via query parameters like new URL(import.meta.url).searchParams.get('someURLInfo') // '5'; Enter fullscreen mode Exit fullscreen mode Using with Laravel Vite Normally you would use @vite directive to load js file like @vite('resources/js/app.js') Enter fullscreen mode Exit fullscreen mode so to pass a value through query parameter,…
Read More
How to Solve ‘Class NumberFormatter not found’ in Laravel

How to Solve ‘Class NumberFormatter not found’ in Laravel

The error Class 'NumberFormatter' not found in Laravel typically occurs when the intl extension is not installed or enabled in your PHP environment. The NumberFormatter class is part of the intl (Internationalization) extension. Check PHP Extension Make sure that the intl extension is installed and enabled.For Ubuntu/Debian: sudo apt-get install php-intl Enter fullscreen mode Exit fullscreen mode For CentOS/RHEL: sudo yum install php-intl Enter fullscreen mode Exit fullscreen mode For Windows:Open your php.ini file.Uncomment the line ;extension=intl by removing the semicolon (;). Restart Your Web Server After installing or enabling the intl extension, restart your web server to apply the…
Read More
Why is unserializing an object in PHP a bad idea?

Why is unserializing an object in PHP a bad idea?

Serializing in PHP is a way of converting a PHP object into a string. This string can be used in various ways, such as storing it in a database or passing it to another function. The PHP documentation says this is handy when passing PHP values around without losing their type and structure. But I have never had that problem before. Maybe I’m not seeing it. <?php $test = new User(); $test->name = "Denzyl"; echo serialize($test); /// Output: O:4:"User":1:{s:4:"name";s:6:"Denzyl";} Enter fullscreen mode Exit fullscreen mode So, let's digest the string. The o stands for Object, and the following number is…
Read More
No widgets found. Go to Widget page and add the widget in Offcanvas Sidebar Widget Area.