Touching Parents Timestamps with “$touches” in Laravel

When you’d need to update updated_at field of parent model, you can just use $touches of Laravel eloquent. Let’s assume, you have Posts and each Post has multiple Comments.Then it’s one to many relationship between Post and Comments.If a user added a comment for the post, we should update updated_at of the post as well.We …

How to use Laravel Task Scheduler on Windows 10

Creating and running Laravel’s scheduled tasks is pretty straightforward on Linux. All you have to do is to create a cronjob which looks something like * * * * * php /path-to-your-project/artisan schedule:run >> /dev/null 2>&1 and it will call your Laravel command scheduler every minute to execute due tasks. However, Windows doesn’t have cron jobs. The closest equivalent to cron on Windows platform is Windows task …

Laravel Polymorphic Relationships

A polymorphic relationship allows the target model to belong to more than one type of model using a single association. One To One (Polymorphic) Table Structure A one-to-one polymorphic relation is similar to a simple one-to-one relation; however, the target model can belong to more than one type of model on a single association. For …

Ngrok for webhook testing.

When you develop your web applications, you will have situation to test 3rd party API integration in the local development environment. The tricky problem here is most of 3rd party APIs are callback based. In a word, most of 3rd party APIs send data/status as callbacks/webhook to original client. However when you wants to test …

Laravel logging

Laravel provides rich logging functionality. We can post messages to third party chatting platforms like slack using Laravel logging functionality. All of the configuration for your application’s logging system is housed in the config/logging.php configuration file. This file allows you to configure your application’s log channels, so be sure to review each of the available channels and …

Laravel – Soft Deleting

In addition to actually removing records from your database, Eloquent can also “soft delete” models. When models are soft deleted, they are not actually removed from your database. Instead, a deleted_at attribute is set on the model and inserted into the database. If a model has a non-null deleted_at value, the model has been soft deleted. To enable soft …