From a7dc9bb49bbfc3115fb2e22d65f0d0620643e74a Mon Sep 17 00:00:00 2001 From: tracer Date: Tue, 12 Apr 2022 19:00:38 +0200 Subject: [PATCH] added upload --- .../Admin/ProjectsCrudController.php | 36 +++++++++++-------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/src/Controller/Admin/ProjectsCrudController.php b/src/Controller/Admin/ProjectsCrudController.php index 443df4e..cc20b19 100644 --- a/src/Controller/Admin/ProjectsCrudController.php +++ b/src/Controller/Admin/ProjectsCrudController.php @@ -4,25 +4,31 @@ namespace App\Controller\Admin; use App\Entity\Projects; use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController; +use EasyCorp\Bundle\EasyAdminBundle\Field\IdField; +use EasyCorp\Bundle\EasyAdminBundle\Field\ImageField; +use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; /** * */ class ProjectsCrudController extends AbstractCrudController { - public static function getEntityFqcn(): string - { - return Projects::class; - } - - /* - public function configureFields(string $pageName): iterable - { - return [ - IdField::new('id'), - TextField::new('title'), - TextEditorField::new('description'), - ]; - } - */ + public static function getEntityFqcn(): string + { + return Projects::class; + } + + public function configureFields(string $pageName): iterable + { + yield IdField::new(propertyName: 'id') + ->onlyOnIndex(); + yield TextField::new(propertyName: 'name'); + yield TextField::new(propertyName: 'description'); + yield TextField::new(propertyName: 'description'); + yield ImageField::new(propertyName: 'teaserImage') + ->setBasePath(path: 'uploads/projects') + ->setUploadDir(uploadDirPath: 'public/uploads/projects') + ->setUploadedFileNamePattern(patternOrCallable: '[timestamp]-[slug].[extension]'); + + } }