Browsed by
Tag: laravel

Laravel: Observer

Laravel: Observer

Assalamualaikum & Hi, Eloquent models fire several events, allowing you to hook into the following points in a model’s lifecycle: retrieved, creating, created, updating, updated, saving, saved, deleting, deleted, restoring, restored. Events allow you to easily execute code each time a specific model class is saved or updated in the database. Based on events above, we can capture all the events mentioned above either by setup in model’s property called $dispatchesEventsor we can setup an observer to capture all the…

Read More Read More

Manage Routes in Laravel

Manage Routes in Laravel

Assalamualiakum & Hi, It’s obvious, if you’re working on a large application which have a lot of routes needed, you will absolutely need to manage your routes – for me mainly the web and API routes. So here an example how I did – Create a helper to load multiple route in particular directory. The second part basically just specify to which directories to load the routes. This method inspired by Spatie – Laravel Collection Macros. You may use macro…

Read More Read More

HAProxy: Setting Up CORS

HAProxy: Setting Up CORS

Assalamualaikum, It’s been awhile since my last post – quite tight up with business and development – and here we are, just sharing a new thing I learnt – HAProxy. Currently I have a mobile application need to consume my API (Laravel based) – and I have no problem setting up CORS from Laravel. But working on a bit scale up infrastructure, and in HA architecture, need to setup CORS on load balancer, which is HAProxy. Following are the minimal…

Read More Read More

Reset Your Password from API

Reset Your Password from API

As you may know, Laravel provide a scaffold auth, which include reset/forgot password on web applications side. But what if you have a mobile application that need to reset password from the mobile application? In this post, I’ll show you how to reset user’s password from an API in Laravel. UPDATE 02/07/2017: In case you’re looking for App\Transformers\Json, you basically can create a class called Json in app/Transformers directory. In the Json class: Please make sure to composer dumpautoload -o…

Read More Read More

4 Essential Laravel Packages for Your Web Application Development

4 Essential Laravel Packages for Your Web Application Development

Assalamualaikum, Recently I’ve been working with developing Laravel packages for my own use and Laravel’s community. It’s quite fun and interesting how you can separate the modules or features from Laravel’s main application and make it as a package, which later on you can reuse it over and over again. Here are some of the packages I’ve created so far. You may want to try it out, and please do make a report if there’s any issues. Artisan Extended –…

Read More Read More

Laravel: Managing Routes

Laravel: Managing Routes

Assalamualaikum, Recently I’ve meet some of my friends, and clients working with Laravel projects. It’s seems that, Route, managing routes is quiet painful when your application become bigger and you have to handle a lots of routes. So, what’s come out of my mind was, how to manage Laravel’s routes more efficient? I’ve come up with few possible options: Define more map methods in RouteServiceProvider, and call them – but this will make the RouteServiceProvider full with map methods, which…

Read More Read More

How to Use Lumen in Laravel

How to Use Lumen in Laravel

You love the speed of Lumen but you want to have the features of Laravel? No problem, just include Lumen inside Laravel! Below are the steps to include Lumen inside of the Laravel Please ensure to create an empty Laravel and Lumen project because you need to copy some files from Lumen to Laravel Here the working sample of the Lumen in Laravel – Lumen in Laravel

Laravel: How to Create Custom Artisan Command

Laravel: How to Create Custom Artisan Command

There’s only 3 steps required to setting up new Artisan command. 1. Step 1 – Create a new console file 2. Step 2 – Open up `app/Console/Commands/CommandName.php` and update the signature and the description property. 3. Step 3 – Register your new Artisan command in `app/Console/Kernel.php` Now you’re ready with your new artisan command. Check your command with `php artisan`. It should have something like this one. Here the a sample code. Reference Artisan