PHP code example of ingruz / yodo

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

    

ingruz / yodo example snippets



use Ingruz\Yodo\Base\Controller;

class PostController extends Controller {}

Route::resource('posts', PostController::class);


use Ingruz\Yodo\Base\Repository;

class PostRepository extends Repository {}

static $queryParamsHandlers = [
    'writer' => 'writer_id',
    'commentedByUser' => 'comments.user_id'
];

// ...

public function getQueryParams($requestParams) {
    $queryParams = parent::getQueryParams($requestParams);

    $queryParams['after'] = function($query, $params) {
        return $query->whereHas('comments', function($q) use($params) {
            $q->where('created_by', '>=', $params['after']);
        });
    };
    
    $queryParams['special'] = App\Resolvers\Post\SpecialParamResolver::class;

    return $queryParams;
}

static $rules = [
    'title' => '

static $rules = [
    'create' => [
        'date' => 'date
    ]
];

static $rules = [
    'save' => [
        'title' => ' ]
];

public function boot() {
    Post::created(function($model) {
        app('notifier')->notifyNewPost($model); // pseudo-code
    });
}


use League\Fractal;

class PostTransformer extends Fractal\TransformerAbstract
{
    public function transform(Post $post)
    {
        return [
            ...
        ];
    }
}

'providers' => [
    // ...

    Ingruz\Yodo\YodoServiceProvider::class
]