PHP code example of mveabraham / repository-generator
1. Go to this page and download the library: Download mveabraham/repository-generator 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/ */
mveabraham / repository-generator example snippets
namespace App\Http\Controllers;
use App\Repositories\PostRepository;
class PostController extends Controller {
private $postRepository;
public function __construct(PostRepository $postRepository)
{
$this->postRepository = $postRepository;
}
public function index() {
return response()->json($this->postRepository->getAll());
}
}
public function exists(string $key, $value, $withTrashed = false)
public function getByAttribute(string $attr_name, $attr_value, $relations = [], $withTrashed = false, $selects = [])
public function getPaginate(int $n, $relations = [], $withTrashed = false, $selects = []);
public function store(Array $inputs)
public function getById($id, $relations = [], $withTrashed = false, $selects = [])
public function search($key, $value, $relations = [], $withTrashed = false, $selects = [])
public function getAll($relations = [], $withTrashed = false, $selects = [])
public function countAll($withTrashed = false)
public function getAllSelectable($key)
public function update($id, Array $inputs)
public function destroy($id)
public function destroyAll()
public function forceDelete($id)
public function restore($id)