1. Go to this page and download the library: Download abdallhsamy/helpers 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/ */
abdallhsamy / helpers example snippets
namespace App\Models;
use Illuminate\Foundation\Auth\User as Authenticatable;
use AbdallhSamy\Helpers\Traits\Models\{ActivityLogTrait, ModelFilters, ModelSearch};
class User extends Authenticatable
{
use ActivityLogTrait, ModelFilters, ModelSearch;
protected $filterItems = [];
protected $searchItems = [];
...
namespace App\Http\Controllers\API\V1;
use App\Models\User;
use App\Http\Controllers\Controller;
use App\Http\Requests\User\UserCollection;
use AbdallhSamy\Helpers\{Contracts\EnhancedQueryInterface, Traits\Controllers\EnhancedQuery};
class UserAPIController extends Controller implements EnhancedQueryInterface
{
use EnhancedQuery;
private $model;
public function __construct()
{
$this->model = User::latest();
}
/**
* must be implemented
*/
public function collection($users)
{
return new UserCollection($users);
}
/**
* Display a listing of the resource.
* @param Request $request
* mixed
* @return ResourceCollection
*/
public function index(Request $request)
{
return $this->query($request->all());
}
...