PHP code example of agog / osmose

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

    

agog / osmose example snippets




namespace App\Http\Filters;

use Agog\Osmose\Library\OsmoseFilter;
use Agog\Osmose\Library\Services\Contracts\OsmoseFilterInterface;

class CharacterFilter extends OsmoseFilter implements OsmoseFilterInterface
{
    /**
     * defines the form elements that are to be sieved
     * @return array
     */
    public function residue() : array
    {
        return [
            //
        ];
    }
}

public function index (CharacterFilter $filter)
{
    $characters = $filter->sieve(Character::class)->get();
}

public function residue () : array
{
    return [
        'character_id' => 'column:id'
    ]
}

public function residue () : array
{
    return [
        'role' => 'relationship:roles,name'
    ]
}

public function residue () : array
{
    return [
        'gender' => function ($query, $value) {

            return $query->where('gender', $value);

        }
    ]
}

public function column () : string
{
    return 'created_at';
}

public function range ()
{
    return 'range';
}

public function limits () : array
{
    return [
        'from'  => 'from',
        'to'    => 'to'
    ];
}

public function bound () : array
{
    return [
        'column:id,1,2,3,4', // will always return records with the IDs defined whenever the route is visited,
        function ($query) {
            return $query->orWhere('id', 5); // adds record where id=5
        }
    ];
}

public function index ()
{
    $characters = osmose(CharacterFilter::class)->get();
}

public function index ()
{
    $characters = osmose(UserSieve::class, Character::class)->get();
}

php artisan vendor:publish --provider="Agog\Osmose\Providers\OsmoseServiceProvider"