1. Go to this page and download the library: Download kraenkvisuell/entriloquent 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/ */
kraenkvisuell / entriloquent example snippets
namespace App\Models;
use Kraenkvisuell\Entriloquent\Entriloquent;
class Product extends Entriloquent
{
// you can add any methods here that make sense, like...
public function getPriceInclVat()
{
return $this->price * (1 + ($this->vat / 100));
}
}
use App\Models\Product;
//returns product entry - will ONLY search in products collection:
$product = Product::find($id);
// also returns product entry, also only searching in products collection:
$product = Product::where('slug', 'awesome-product-1')->first();
// or
$product = Product::firstWhere('slug', 'awesome-product-1');
// works with any fields on the collection:
$product = Product::where('some_custom_field', 'foo bar baz')->first();
// or
$product = Product::firstWhere('some_custom_field', 'foo bar baz');
use App\Models\Product;
//returns collection of product entries:
$products = Product::where('price', '>=', 100);