diff --git a/src/Controller/Admin/CommentCrudController.php b/src/Controller/Admin/CommentCrudController.php index 57db8fa..33da48c 100644 --- a/src/Controller/Admin/CommentCrudController.php +++ b/src/Controller/Admin/CommentCrudController.php @@ -5,8 +5,9 @@ use App\Entity\Comment; use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController; use EasyCorp\Bundle\EasyAdminBundle\Field\IdField; -use EasyCorp\Bundle\EasyAdminBundle\Field\TextEditorField; -use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; +use EasyCorp\Bundle\EasyAdminBundle\Field\TextareaField; +use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField; +use EasyCorp\Bundle\EasyAdminBundle\Field\DateTimeField; class CommentCrudController extends AbstractCrudController { @@ -15,14 +16,17 @@ public static function getEntityFqcn(): string return Comment::class; } - /* public function configureFields(string $pageName): iterable { - return [ - IdField::new('id'), - TextField::new('title'), - TextEditorField::new('description'), - ]; + yield IdField::new('id')->onlyOnIndex(); + yield DateTimeField::new('publishedAt')->onlyOnIndex(); + yield TextareaField::new('content')->onlyOnForms(); + yield AssociationField::new('author') + ->setSortProperty('fullName') + ->onlyOnForms(); + yield AssociationField::new('post') + ->setSortProperty('title') + ->onlyOnForms(); + yield DateTimeField::new('publishedAt')->onlyOnForms(); } - */ } diff --git a/src/Entity/Post.php b/src/Entity/Post.php index f090515..4834acc 100644 --- a/src/Entity/Post.php +++ b/src/Entity/Post.php @@ -53,6 +53,11 @@ public function __construct() $this->tags = new ArrayCollection(); } + public function __toString(): string + { + return $this->getTitle(); + } + public function getId(): ?int { return $this->id;