PHP code example of salipropham / laravel-mvcsp

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

    

salipropham / laravel-mvcsp example snippets


public function index(Request $request)
{
    $srvDummy = service(DummyService::class);    
    if($request->get('key')){
        $srvDummy->loveU();
    } else {
        $srvDummy->willLoveU;
    }
    
    // something or nothing...

}


public function index(Request $request)
{

    // something or nothing...
    
    $prsFoo = presenter(FooPresenter::class);

    return view('example', $prsFoo);
}

class LovePresenter extends Presenter
{

    /**
     * Keep or not original data that has passed on init
     * @var bool
     */
    protected $keepOrigData = true;
 
    public function transform()
    {
        // logic here and only here
        
        $this->mydata = 'transformed data';
    }
}

presenter($name, $original_data)
//or
$prsFoo->setOriginalData($original_data)

$data = $prsFoo->parse();
// or a static method
$data = FooPresenter::parse();

$ php artisan make:service ServiceName

$ php artisan make:presenter PresenterName