1. Go to this page and download the library: Download arch/repositories 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/ */
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Arch\Util\Instantiate;
class User extends Model {
use Instantiate;
}
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Canal\UserModuleCanal as UserCanal; // Canal class
class UserController extends Controller
{
private $userModule = null;
public function __construct () {
// instantiate and assign to class member
$this->userModule = new UserCanal;
}
// retrieving all users
public function index () {
dd( $this->userModule->getAllUser() );
}
}
namespace App\Canal;
use App\Repositories\UserRepositories as UserRepo; // ll Repositories class
public function getAllUser () {
$user = new UserRepo; // Instantiate UserRepo object
return $user->all(); // call UserRepo method and pass data back to Controller
}
}
namespace App\Repositories;
use Arch\Repositories\Shareables\BaseShareables as BaseAbstract;
use App\User; // Model tied with this repositories
use DB; // custom database querying
class UserRepositories extends BaseAbstract {
public function __construct() {
// Assign to parent Model for data fetching
$this->model = User::getInstance();
}
// At here we didn't create all() method, basically we didnt
// create any method inside this repositories
// as all the laravel Query method already
// available inside this repositories
// by