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');
    }
}

javascript
      <table class="table">
                <thead>
                    <tr>
                        <th scope="col">#</th>
                        <th scope="col">Name</th>
                        <th scope="col">Action</th>
                    </tr>
                </thead>
                <tbody>
                    @foreach ($data as $key => $row)
                        <tr>
                            <th scope="row">{{ $key + 1 }}</th>
                            <td>{{ $row->name }}</td>
                            <td><a href="{{ route('products.edit', ['product' => $row->id]) }}">Edit</a></td>

                        </tr>
                    @endforeach
                </tbody>
            </table>

            <div class="bottom-btn text-right mt-4">
                <a href="{{ route('products.create') }}" class="btn btn-primary">Add</a>
            </div>
bash
        php artisan storage:link