added upload

This commit is contained in:
tracer 2022-04-12 19:00:38 +02:00
parent 2dfe0070e2
commit a7dc9bb49b

View File

@ -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]');
}
}