Category Archives: PHP

Eloquent to access another DB

Reference:

  1. https://stackoverflow.com/questions/31847054/how-to-use-multiple-databases-in-laravel

Join in CodeIgniter

 

Get table column names in laravel

Add this function in eloquent model:

 

Get JSON data from request

 

Tinymce config for Laravel File Manager

 

Middleware for localization

Creating a middleware file

Add middleware to app/Http/Kernel.php

Apply middleware in route.php

Middleware

Note

  1. Constructor of a controller will be execute before route, middleware and session.

Reference

  1. https://laravel.com/docs/5.4/middleware

Model Trait for Laravel

Trait

Usage

 

Socket in PHP

Server:

Client:

Commands:

php server.php
php client.php

Reference:

  1. https://www.php.net/manual/en/function.socket-read.php
  2. https://xyz.cinc.biz/2016/12/php-socket-client.html
  3. socket_create() not found
    https://blog.johnsonlu.org/freebsdinstall-php-sockets-so/