PHP code example of lucasbedout / detective

1. Go to this page and download the library: Download lucasbedout/detective 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/ */

    

lucasbedout / detective example snippets

 

use \Detective\Model as Detective;

class YourModel extends Detective 
{
	// Classic eloquent class
}

 

use \Detective\Model as Detective;

class YourModel extends Detective 
{
	public static $relationships = ['relation1', 'relation2'];

	public function relation1() 
	{
		return $this->belongsTo('Relation1');
	}

	public function relation2() 
	{
		return $this->belongsToMany('Relation2');
	}
}



	Route::get('/products', function() {
		$products = Product::filter(Input::all())->get();

		return response()->json($products);
	});
 

$array = ['name' => 'Home*', 'created_at' => '<2015-06-11'];

$products = Product::filter($array)->get(); // Products in the Home% categories, created before the 11/06/2015.


 

$products = Product::filter($data)->groupBy('category_id')->paginate(10);