PHP code example of pros / base

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

    

pros / base example snippets


use Illuminate\Routing\Controller as BaseController;

class Controller extends BaseController
{
    // this line is to register json response convenient methods
    use ResponseTemplateTrait;

    pubic function __construct(
        protected Service $service
    ){}

    public function index(Request $request) 
    {
        $param1 = $request->get('param1');
        $data = $this->service->methodName($param1)

        // this method comes from ResponseTemplateTrait
        // it also contains jsonError and jsonSuccessNoContent methods
        return $this->jsonSuccess($data);
    }
}

class Repostory extends BaseRepository 
{
    public funtion paramExists($param) : boolean
    {
        // $this can represents for Model, Eloquent, QueryBuilder
        // so feel free to use this as you desired
        // you also can use $this->model for same purpose. 
        return $this->where('a' = $param)->exists();
    }
}