PHP code example of zhiephie / lushi

1. Go to this page and download the library: Download zhiephie/lushi library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

zhiephie / lushi example snippets


use Lushi\Models\Country;

Province::all(); // Get information about all provinces.

Province::find(11); // Get information about the ID 11.

Province::where('name', 'like', '%JAWA%')->get(); // Get information about all provinces that contain the character "JAVA".



namespace App\Models;

use Lushi\Models\Province as LushiProvince;

class Province extends LushiProvince
{
    public function users()
    {
        return $this->hasMany(User::class);
    }
}



namespace App\Models;

use Lushi\Models\Province as LushiProvince;

class Province extends LushiProvince
{
    protected $map = [
        'id' => 'province_code',
    ];
}

use App\Models\Province;

Province::find(11)->province_code;