PHP code example of laravel-admin / crud

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

    

laravel-admin / crud example snippets


protected function getValidationRulesOnStore()
{
        return [
                'title' => '

protected function getPayloadOnStore(array $data)
{
  $payload = $this->getPayloadForStoreDefault($data);

  //    If password is given, lets encrypt it, otherwise remove the password from the payload
  if (!empty($payload['password'])) $payload['password'] = bcrypt($payload['password']);
  else unset($payload['password']);

  return $payload
}

protected function getFieldsForList()
{
   return [
     [
       'id' => 'title',
       'label' => 'Title',
     ],
     [
       'id' => 'created_at',
       'label' => 'Created',
       'formatter' => function($model)
        {
          return $model->created_at->format('Y-m-d');
        }
     ]
  ];
}

php artisan vendor:publish --provider="LaravelAdmin\Crud\CrudServiceProvider::class"

//	Controller
public function show($id)
{
	$model = \App\Models\Page::findOrFail($id);
	$layout = $model->layout()->components();

	return view('page', compact('model','layout'));
}

// View
{!! $layout->render() !!}