PHP code example of marceauka / laravel-crudable

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

    

marceauka / laravel-crudable example snippets


// After other service providers
Akibatech\Crud\CrudServiceProvider::class

class Post extends Model
{
    use Crudable;
    
    /**
     * @return \Akibatech\Crud\Services\CrudFields
     */
    public function getCrudFields()
    {
        return CrudFields::make([
            // Bind the title attribute to a ure
            FileUploadField::handle('illustration')->withMaxSize(1024 * 1024)->withTypes('jpeg,png'),
            
            // Bind the status attribute to a Radio Field allowing Draft or Live options.
            RadioField::handle('status', '

    public function index()
    {
        $model = App\Post::class;
        
        return view('your-view', compact($model));
    }

    public function create()
    {
        $model = App\Post::class;
        
        return view('your-view', compact($model));
    }
    
    public function store(Request $request)
    {
        $entry = (new App\Post)->crudEntry();
        $validation = $entry->validate($request->all());
        
        if ($validation->passes())
        {
            $validation->save();
        }
        
        // Redirect to the form with the errors if validation fails, or to the index page  
        return $validation->redirect();
    }

// routes/web.php
App\Post::crudRoutes();
bash
php artisan vendor:publish --tag=crud