1. Go to this page and download the library: Download henrygodev/laranest 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/ */
henrygodev / laranest example snippets
class ProductController extends Controller
{
public function index(): JsonResponse { ... }
public function store(StoreProductRequest $request): JsonResponse { ... }
public function show(Product $product): JsonResponse { ... }
public function update(UpdateProductRequest $request, Product $product): JsonResponse { ... }
public function destroy(Product $product): JsonResponse { ... }
}
class ProductController extends Controller
{
public function index() { ... }
public function create() { ... }
public function store(StoreProductRequest $request) { ... }
public function show(Product $model) { ... }
public function edit(Product $model) { ... }
public function update(UpdateProductRequest $request, Product $model) { ... }
public function destroy(Product $model) { ... }
}
class ProductService
{
public function getAll(): mixed { ... }
public function findById(int $id): Product { ... }
public function create(array $data): Product { ... }
public function update(int $id, array $data): Product { ... }
public function delete(int $id): void { ... }
}
class ProductController extends Controller
{
public function __construct(protected ProductService $service) {}
public function index(): JsonResponse
{
return response()->json($this->service->getAll());
}
public function store(StoreProductRequest $request): JsonResponse
{
return response()->json($this->service->create($request->validated()), 201);
}
// ...
}
// stubs/laravel-module/model.stub
namespace {{ namespace }};
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
class {{ class }} extends Model
{
use SoftDeletes;
protected $guarded = [];
}