1. Go to this page and download the library: Download ebalo/easycrud 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/ */
ebalo / easycrud example snippets
namespace App\Http\Controllers;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
// ...
class CategoryController extends Controller
{
// Validation rules array, inherited from the EasyCRUD trait
protected array $rules = [
"name" => " to create
"categories-index" // Redirect if validation and creation ends successfully
);
}
public function update(Request $request, Category $category): RedirectResponse
{
return $this->easyUpdate(
$request, // Request to validate
$category, // Model to update
"categories-index" // Redirect if validation and creation ends successfully
);
}
public function destroy(Category $category): RedirectResponse
{
return $this->easyDelete(
$category, // Model to update
"categories-index" // Redirect if validation and creation ends successfully
);
}
// ...
}
namespace App\Http\Controllers;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
// ...
class CategoryController extends Controller
{
// Validation rules array, inherited from the EasyCRUD trait
protected array $rules = [
"name" => "to create
"create", // Creation function
"categories-index" // Redirect if validation and creation ends successfully
);
}
// ...
}
namespace App\Http\Controllers;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
// ...
class CategoryController extends Controller
{
// Note the that $rules now is marked as private
private array $rules = [
"name" => " // Request to validate
$this->rules, // Array of validation rules
Category::class, // Model to create
"categories-index" // Redirect if validation and creation ends successfully
);
}
public function update(Request $request, Category $category): RedirectResponse
{
return easyUpdate(
$this, // Instance of the caller class
$request, // Request to validate
$this->rules, // Array of validation rules
$category, // Model to update
"categories-index" // Redirect if validation and creation ends successfully
);
}
public function destroy(Category $category): RedirectResponse
{
return easyDelete(
$category, // Model to delete
"categories-index" // Redirect if validation and creation ends successfully
);
}
}
namespace App\Http\Controllers;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
// ...
class CategoryController extends Controller
{
// Validation rules array, inherited from the EasyCRUD trait
protected array $rules = [
"name" => "est to validate
$this->rules, // Array of validation rules
Category::class, // Model to create
"create", // Creation function
"categories-index" // Redirect if validation and creation ends successfully
);
}
// ...
}
use App\Http\Controllers\CategoryController;
// ...
CRUD(
"categories", // Route path prefix
CategoryController::class, // Controller class to call
"category", // Route name prefix
"category" // Parameter name for the routes that
use App\Http\Controllers\CategoryController;
// ...
CRUD(
"categories", // Route path prefix
CategoryController::class, // Controller class to call
"categories", // Route name prefix
"category", // Parameter name for the routes that "delete" => true // Don't register the deletion endpoints
]
);
// ...