PHP code example of josanangel / service-repository-manager
1. Go to this page and download the library: Download josanangel/service-repository-manager 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/ */
josanangel / service-repository-manager example snippets
namespace App\Repositories;
class UserRepository
{
public function __construct()
{
}
}
namespace App\Repositories;
class UserRepository
{
protected $model;
/**
* TODO: initialize $this->model to your model in order to repository works successfully
* ... e.g.: $this->model = User::class;
*/
public function __construct()
{
}
public function all()
{
return $this->model->all();
}
public function create($data)
{
return $this->model->create($data);
}
public function find($id)
{
return $this->model->find($id);
}
public function update($id, $data)
{
return $this->model->where("id",$id)->update($data);
}
public function delete($id)
{
return $this->model->where("id",$id)->delete();
}
}
namespace App\Services;
class UserService
{
public function __construct()
{
}
}
namespace App\Services;
class UserService
{
protected AuthService $authService;
public function __construct(AuthService $authService)
{
$this->authService = $authService;
}
}
namespace App\Services;
class AuthService
{
public function __construct()
{
}
}
namespace App\Repositories;
class AuthRepository
{
public function __construct()
{
}
}
namespace App\Services;
class AuthService
{
public function __construct()
{
}
}
namespace App\Services;
class MapService
{
public function __construct()
{
}
}
namespace App\Services;
use App\Repositories\AuthRepository;
class UserService
{
protected AuthRepository $authRepository;
protected AuthService $authService;
protected MapService $mapService;
public function __construct(AuthRepository $authRepository, AuthService $authService, MapService $mapService)
{
$this->authRepository = $authRepository;
$this->authService = $authService;
$this->mapService = $mapService;
}
}
namespace App\Repositories;
class UserRepository
{
protected $model;
public function __construct()
{
}
public function index()
{
$this->model->all();
}
public function store($data)
{
$this->model->create($data);
}
public function show($id)
{
$this->model->findById($id);
}
public function update($id, $data)
{
$this->model->where("id",$id)->update($data);
}
public function destroy($id)
{
$this->model->where("id",$id)->delete();
}
}
namespace App\Services;
use App\Repositories\UserRepository;
class UserService
{
protected UserRepository $userRepository;
public function __construct(UserRepository $userRepository)
{
$this->userRepository = $userRepository;
}
}