PHP code example of masuresh124 / simple-crud-builder
1. Go to this page and download the library: Download masuresh124/simple-crud-builder 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/ */
masuresh124 / simple-crud-builder example snippets
javascript
use Masuresh124\SimpleCrudBuilder\FormBuilder\Form;
class ProductForm extends Form
{
public function createForm($entity)
{
$this->add(self::TEXT, 'name', ['is;
}
}
bash
/**
* Package Service Providers...
*/
Masuresh124\SimpleCrudBuilder\Providers\SimpleCrudProvider::class,
javascript
namespace App\Http\Controllers;
use App\Forms\ProductForm;
use App\Models\Product;
use Illuminate\Http\Request;
use Masuresh124\SimpleCrudBuilder\FormBuilder\FormBuilder;
class ProductController extends Controller
{
public function index()
{
$data = Product::all();
return view('product-list', compact('data'));
}
public function create()
{
$entity = new Product();
return $this->process($entity);
}
public function store(Request $request)
{
$entity = new Product();
return $this->process($entity);
}
public function edit(Product $product)
{
return $this->process($product);
}
public function update(Request $request, Product $product)
{
return $this->process($product);
}
/**
* This common function handles all the actions
*
* @param Product Model $entity
* @return \Illuminate\Http\Response
*/
public function process(Product $entity)
{ /**
* @param Product Model $entity
* @param ProductForm::class
* @param Form blade name 'product'
*/
return FormBuilder::createFormSimpleBuilder($entity, ProductForm::class, 'product');
}
}