PHP code example of vmorozov / laravel_admin_generator
1. Go to this page and download the library: Download vmorozov/laravel_admin_generator 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/ */
vmorozov / laravel_admin_generator example snippets
namespace App\Http\Controllers\Admin;
use App\Product;
use Vmorozov\LaravelAdminGenerator\App\Controllers\CrudController;
class ProductsController extends CrudController
{
protected $model = Product::class;
protected $url = 'products';
protected $titlePlural = 'Товары';
protected $titleSingular = 'Товар';
}
protected function setup()
{
$this->addDefaultWhereClause('password', '!=', null);
$this->addDefaultOrderByClause('id', 'desc');
}
protected function setup()
{
// without putting entity id to the url
$this->addListItemButton(url('/test_button'), 'test button');
// with putting entity id to the url
$this->addListItemButton(url('/test_button/{id}'), '<i class="fa fa-check" aria-hidden="true"></i> test button', 'btn btn-success', ['target' => '_blank']);
}
namespace App;
use Illuminate\Database\Eloquent\Model;
use Spatie\MediaLibrary\HasMedia\HasMediaTrait;
use Spatie\MediaLibrary\HasMedia\Interfaces\HasMedia;
use Vmorozov\LaravelAdminGenerator\App\Utils\ModelTraits\AdminPanelTrait;
class Product extends Model implements HasMedia
{
use AdminPanelTrait;
use HasMediaTrait;
public $mediaCollections = [
'main_image' => [
'name' => 'Main image',
'single_file' => true
],
'gallery' => [
'name' => 'Gallery'
],
];
// Some other code here
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.