1. Go to this page and download the library: Download larachimp/mango-repo 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/ */
larachimp / mango-repo example snippets
'providers' => [
// Other service providers...
LaraChimp\PineAnnotations\PineAnnotationsServiceProvider::class,
LaraChimp\MangoRepo\MangoRepoServiceProvider::class,
],
namespace App\Repositories;
use LaraChimp\MangoRepo\Repositories\EloquentRepository;
class Posts extends EloquentRepository
{
/**
* The target Eloquent Model.
*/
const TARGET = \App\Models\Post::class;
}
namespace App\Repositories;
use LaraChimp\MangoRepo\Annotations\EloquentModel;
use LaraChimp\MangoRepo\Repositories\EloquentRepository;
/**
* @EloquentModel(target="App\Models\Post")
*/
class Posts extends EloquentRepository
{
//
}
namespace App\Http\Controllers;
use App\Repositories\Posts;
class PostController extends Controller
{
/**
* Posts repository instance.
*
* @var Posts
*/
protected $posts;
public function __construct(Posts $posts)
{
$this->posts = $posts;
}
public function index()
{
$allPosts = $this->posts->all();
//
}
}
namespace App\Http\Controllers;
use App\Repositories\Posts;
class PostController extends Controller
{
public function index()
{
$posts = app()->make(Posts::class)->all();
//
}
}
namespace LaraChimp\MangoRepo\Tests\Fixtures\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Builder;
class User extends Model
{
//...
/**
* Apply an is active scope filter to the model.
*
* @param Builder $query
*
* @return Builder
*/
public function scopeActive($query)
{
return $query->where('is_active', true);
}
}
namespace Acme\Company;
use LaraChimp\MangoRepo\Contracts\RepositoryInterface;
class MyCompanyRepo implements RepositoryInterface
{
public function all($columns = ['*'])
{
// ...
}
// ...
}
namespace Acme\Company;
use LaraChimp\MangoRepo\Concerns\IsRepositorable;
use LaraChimp\MangoRepo\Contracts\RepositoryInterface;
class MyCompanyRepo implements RepositoryInterface
{
use IsRepositorable;
// ...
}
namespace Acme\Company;
use LaraChimp\MangoRepo\Concerns;
use LaraChimp\MangoRepo\Contracts\RepositoryInterface;
class MyCompanyRepo implements RepositoryInterface
{
use Concerns\IsRepositorable,
Concerns\IsRepositoryBootable,
Concerns\IsRepositoryScopable;
// ...
}