PHP code example of soda-framework / reports

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

    

soda-framework / reports example snippets


#!php
Themes\Snackable\Components\SubscriptionReport.php


    namespace Themes\Snackable\Components;

    use Soda;
    use Illuminate\Http\Request;
    use Soda\Reports\Foundation\AbstractReporter;
    use Themes\Snackable\Controllers\PageController;
    use Zofe\Rapyd\Facades\DataGrid;

    class SubscriptionReport extends AbstractReporter{

        public function query(Request $request)
        {
            $query = Soda::model(PageController::$subscription_block)->select('name','email','dob','created_at');

            return $query;
        }

        public function run(Request $request)
        {
            $grid = DataGrid::source($this->query($request));
            $grid->add('name', 'Name');
            $grid->add('email', 'Email');
            $grid->add('dob', 'Date of Birth');
            $grid->add('created_at', 'Date Subscribed');

            $grid->paginate(20)->getGrid($this->getGridView());

            return view($this->getView(), ['report' => $this->report, 'grid' => $grid]);
        }
    }