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
use App\Models\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' => 'body', 'label' => 'Body', 'type' => 'textarea'],
['name' => 'category_id', 'label' => 'Category', 'type' => 'select', 'relationship' => 'category'],
];
}
}
use App\Http\Controllers\PostController;
Route::resource('posts', PostController::class);
use App\Models\Post;
use Achillesp\CrudForms\CrudForms;
class PostController extends Controller
{
use CrudForms;
public function __construct(Post $post)
{
$this->model = $post;
}
}