PHP code example of niiknow / laratt

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

    

niiknow / laratt example snippets



namespace App\Http\Controllers\Api\V1;

use App\Http\Controllers\Controller;
use App\Models;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Niiknow\Laratt\RequestQueryBuilder;

class DonationController extends Controller
{
    /**
     * Method return donor transaction history
     *
     * @param Request  $request
     */
    public function index(Request $request)
    {
        $user  = \Auth::user();
        $query = \App\Models\Donation::select(
            [
                'donations.id',
                'donations.amount',
                'donations.recurrence_period',
                'donations.created_at',
                'donations.txn_id',
                'donations.txn_type',
                'projects.name as name'
            ]
        )->Where('donor_id', $user->id)
         ->leftJoin('projects', 'donations.project_id', '=', 'projects.id');

        $qb = new RequestQueryBuilder($query);

        return $qb->applyRequest($request);
    }
}

php artisan vendor:publish --provider="Niiknow\Laratt\LarattServiceProvider"