PHP code example of achillesp / laravel-crud-forms

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

    

achillesp / laravel-crud-forms example snippets


Route::resource('/posts', 'PostController');

use App\Post;
use Achillesp\CrudForms\CrudForms;

class PostController extends Controller
{
    use CrudForms;

    public function __construct(Post $post)
    {
        $this->model = $post;
    }
}

$this->formFields = [
    ['name' => 'title', 'label' => 'Title', 'type' => 'text'],
    ['name' => 'slug', 'label' => 'Slug', 'type' => 'text'],
    ['name' => 'body', 'label' => 'Enter your content here', 'type' => 'textarea'],
    ['name' => 'publish_on', 'label' => 'Publish Date', 'type' => 'date'],
    ['name' => 'published', 'label' => 'Published', 'type' => 'checkbox'],
    ['name' => 'category_id', 'label' => 'Category', 'type' => 'select', 'relationship' => 'category'],
    ['name' => 'tags', 'label' => 'Tags', 'type' => 'select_multiple', 'relationship' => 'tags'],
];

$this->indexFields = ['title', 'category_id', 'published'];

$this->withTrashed = true;

Route::put('/posts/{post}/restore', ['as' => 'posts.restore', 'uses' => 'PostController@restore']);

$this->validationRules = [
    'title'       => 'dy'        => '  'category_id' => '

$this->validationMessages = [
    'body.

$this->validationAttributes = [
    'title' => 'Post title'
];

php artisan vendor:publish --provider=Achillesp\CrudForms\CrudFormsServiceProvider --tag=config

php artisan vendor:publish --provider=Achillesp\CrudForms\CrudFormsServiceProvider --tag=views