1. Go to this page and download the library: Download mnshankar/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/ */
mnshankar / 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'));
}
}
public function find($id, $columns = ['*'], $with = []);
public function findBy($attribute, $value, $columns = ['*'], $with = []);
public function findAll($columns = ['*'], $with = []);
public function findWhere($where, $columns = ['*'], $with = []);
public function findWhereBetween($attribute, $values, $columns = ['*'], $with = []);
public function findWhereIn($attribute, $values, $columns = ['*'], $with = []);
public function findWhereNotIn($attribute, $values, $columns = ['*'], $with = []);
public function findOrCreate($attributes);
//RAISES EVENTS 'tag'.entity.creating and 'tag'.entity.created
public function create($attributes);
//RAISES EVENTS 'tag'.entity.updating and 'tag'.entity.updated
public function update($id, $attributes);
//RAISES EVENTS 'tag'.entity.deleting and 'tag'.entity.deleted
public function delete($id);
public function with($relationships);
public function orderBy($column, $direction = 'asc');
//BE CAREFUL WHEN YOU USE PLUCK.. SEMANTICS HAVE CHANGED BETWEEN Laravel 5.0 AND FUTURE VERSIONS
public function pluck($column, $key = null);
public function paginate($perPage = null, $columns = ['*'], $pageName = 'page', $page = null);
public static function __callStatic($method, $parameters);
public function __call($method, $parameters);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.