1. Go to this page and download the library: Download guardian360/repository 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/ */
guardian360 / repository example snippets
namespace App\Repositories;
use App\User;
use Guardian360\Repository\AbstractRepository as Repository;
class UserRepository extends Repository
{
/**
* Specify the model's class name.
*
* @return string
*/
public function model()
{
return User::class;
}
}
namespace App;
use Illuminate\Database\Eloquent\Model
class User extends Model
{
//
}
namespace App\Http\Controllers;
use App\Repositories\UserRepository;
class UserController extends Controller
{
/**
* @var \App\Repositories\UserRepository
*/
protected $users;
/**
* @return void
*/
public function __construct(UserRepository $users)
{
$this->users = $users;
}
/**
* Display a listing of the users.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
return response()->json($this->users->all());
}
}