1. Go to this page and download the library: Download caffeinated/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/ */
caffeinated / repository example snippets
namespace App\Models;
use Illuminate\Database\Eloquent\Model
class Book extends Model
{
//
}
namespace App\Repositories;
use App\Models\Book;
use Caffeinated\Repository\Repositories\EloquentRepository;
class BookRepository extends EloquentRepository
{
/**
* @var Model
*/
public $model = Book::class;
/**
* @var array
*/
public $tag = ['book'];
}
namespace App\Http\Controllers;
use App\Repositories\BookRepository;
class BookController extends Controller
{
/**
* @var BookRepository
*/
protected $book;
/**
* Create a new BookController instance.
*
* @param BookRepository $book
*/
public function __construct(BookRepository $book)
{
$this->book = $book;
}
/**
* Display a listing of all books.
*
* @return Response
*/
public function index()
{
$books = $this->book->findAll();
return view('books.index', compact('books'));
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.