Browsed by
Month: December 2017

Laravel: Package Generator

Laravel: Package Generator

Assalamualaikum / Hi, It’s been a long time, I wan to update my Laravel Package Generator and now it’s officially updated with version 2.0.2. Lots of experience, study case, observation, setting up things in Laravel package. Now I believe, it’s ready to speed up your Laravel Package Development. So, what the Packager do? Basically it creates a basic skeleton of Laravel package which consist of: Service Provider Facade README – with Installation instruction, License Term ready! Other details you need…

Read More Read More

Laravel: Blueprint Macro

Laravel: Blueprint Macro

Next, the thing that I want to share is how I create Blueprint Macro. Similar to my previous posts on Response and Route. But this time, we going to add more functionality to Blueprint which used in migrations. Update your user migration file: Now your code will be much cleaner. Feel free to fork and contribute to Blueprint Macro.

Laravel: Route Macro

Laravel: Route Macro

Here I want to show, how to extend existing route – get, post, etc. for your application. I’m going to create a new route Route::setting(‘module’), which will create all necessary route setup. Now register this new macro in your AppServiceProvider, in register() method. Then, you can start use the new route. To use this new route, you need a controller. So run php artisan make:controller Settings/ApplicationSettingController -r Then you may add in routes/web.php to register a new route setting. In…

Read More Read More

Laravel: Response Macro

Laravel: Response Macro

It’s quite straightforward to extend a class functionality with Macro. This time I show how to extend the Response class in Laravel. Create a class in app/Macros/Http called Response.php and add the content as following: Then register the Macro in AppServiceProvider Now you may test your new responses:

Laravel: Create Hashed ID for A Resource Using Observer

Laravel: Create Hashed ID for A Resource Using Observer

Install hashids/hashsids package Create a wrapper for hashids Create a helper for hashids Create a config file for hashids Create a migration, which add a hashslug field Create a helper to get slug name of the given class name (optional) Create an observer for hashids which monitor on creating new record – if there’s a hashslug column and it’s null, do create hashed id for the record. Register the observer to model in boot() method in your app/Providers/AppServiceProvider.php Now let’s…

Read More Read More

Migrate from WordPress to Laravel – Part 1

Migrate from WordPress to Laravel – Part 1

Assalamualaikum / Hi, I’ve been using WordPress, since 2012 – 5 years, of service. I think it’s time to migrate to another platform – Laravel. I’ve been reading how murze.be did. Basically, I got the idea how he did. But, as my sense of explorer, want to learn something new, I read few more articles, packages available out there for migrate from WordPress to Laravel. I ended up with my own solution. The idea – use the WordPress REST API….

Read More Read More

Laravel: MoneyPHP Wrapper and Helper

Laravel: MoneyPHP Wrapper and Helper

I’ve created a simple MoneyPHP wrapper to simplify my day to day work dealing with MoneyPHP. and a currency configuration – where you can specify the label for display use, and swift_code for MoneyPHP usage: And I’ve create a helper in my app/Support/helpers.php, to simplify the usage of the MoneyPHP Wrapper. A simple usage as following: money()->toHuman(10000) – use it for display it to end user. money()->toMachine(10000) – use it for create the right format before use in database or…

Read More Read More

Laravel: Managing Frontend from Backend

Laravel: Managing Frontend from Backend

Assalamualaikum / Hi, A simple user case: How can you setup your frontend from the backend? Means, how you going to display a view, from a value set in database. For instance, you have a reference table in database named statuses. In the table, you have id,label,name. How do you use values from database to create view – in term of management and usability?