PHP code example of josenildotiago / crud

1. Go to this page and download the library: Download josenildotiago/crud 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/ */

    

josenildotiago / crud example snippets


class ProductController extends Controller
{
    public function index(Request $request): InertiaResponse
    {
        $products = Product::query()
            ->when($request->search, function ($query, $search) {
                $query->where('name', 'like', "%{$search}%")
                      ->orWhere('description', 'like', "%{$search}%");
            })
            ->orderBy('created_at', 'desc')
            ->paginate(10)
            ->withQueryString()
            ->through(fn ($product) => [
                'id' => $product->id,
                'name' => $product->name,
                'description' => $product->description,
                'price' => $product->price,
                'created_at' => $product->created_at->format('d/m/Y H:i'),
                'updated_at' => $product->updated_at->format('d/m/Y H:i'),
            ]);

        return Inertia::render('Product/Index', [
            'products' => $products,
            'filters' => ['search' => $request->search],
        ]);
    }
}



use App\Http\Controllers\ProductController;
use Illuminate\Support\Facades\Route;

Route::middleware(['auth', 'verified'])->group(function () {
    Route::get('/products', [ProductController::class, 'index'])->name('products.index');
    Route::get('/products/create', [ProductController::class, 'create'])->name('products.create');
    Route::post('/products', [ProductController::class, 'store'])->name('products.store');
    Route::get('/products/{product}', [ProductController::class, 'show'])->name('products.show');
    Route::get('/products/{product}/edit', [ProductController::class, 'edit'])->name('products.edit');
    Route::put('/products/{product}', [ProductController::class, 'update'])->name('products.update');
    Route::delete('/products/{product}', [ProductController::class, 'destroy'])->name('products.destroy');
    Route::delete('/products/bulk', [ProductController::class, 'bulkDestroy'])->name('products.bulk-destroy');
});

return [
    'frontend' => 'react', // blade, react, vue
    'inertia' => [
        'enabled' => true,
        'components_path' => 'js/pages',
        'layout_component' => 'Layouts/AppLayout',
    ],
    'api' => [
        'enabled' => true,
        'generate_resources' => true,
        'generate_requests' => true,
    ],
    'theme_integration' => [
        'enabled' => true,
        'auto_install' => true,
        'default_theme' => 'default',
    ]
];
bash
php artisan crud:install-theme-system
bash
php artisan crud:create-theme meu-tema
bash
php artisan getic:install users
bash
# Com API RESTful
php artisan getic:install products --api

# Com relacionamentos automáticos
php artisan getic:install orders --relationship

# Stack específico
php artisan getic:install categories --stack=react

# Com integração de temas
php artisan getic:install posts --theme
bash
# Instalar sistema de temas
php artisan crud:install-theme-system

# Criar novo tema personalizado
php artisan crud:create-theme {nome}

# Gerar CRUD completo
php artisan getic:install {tabela}

# Com API RESTful
php artisan getic:install {tabela} --api

# Com relacionamentos
php artisan getic:install {tabela} --relationship

# Com temas
php artisan getic:install {tabela} --theme
bash
php artisan getic:install products --api --theme
bash
php artisan vendor:publish --provider="Crud\CrudServiceProvider" --tag="config"