diff --git a/public/img/sp/melipayamak.png b/public/img/sp/melipayamak.png new file mode 100644 index 0000000..5d69541 Binary files /dev/null and b/public/img/sp/melipayamak.png differ diff --git a/public/img/sp/parspack-logo.png b/public/img/sp/parspack-logo.png new file mode 100644 index 0000000..4181b19 Binary files /dev/null and b/public/img/sp/parspack-logo.png differ diff --git a/public/img/sp/raddata.png b/public/img/sp/raddata.png new file mode 100644 index 0000000..1a943dc Binary files /dev/null and b/public/img/sp/raddata.png differ diff --git a/public/uploaded/ae8df0c4-7d20-45f8-9ba9-1177a1b7185d.webp b/public/uploaded/ae8df0c4-7d20-45f8-9ba9-1177a1b7185d.webp new file mode 100644 index 0000000..2e3915d Binary files /dev/null and b/public/uploaded/ae8df0c4-7d20-45f8-9ba9-1177a1b7185d.webp differ diff --git a/public/uploaded/da1a81e5-f2fc-4f12-81cd-f428e32ccc9e.webp b/public/uploaded/da1a81e5-f2fc-4f12-81cd-f428e32ccc9e.webp new file mode 100644 index 0000000..f720d84 Binary files /dev/null and b/public/uploaded/da1a81e5-f2fc-4f12-81cd-f428e32ccc9e.webp differ diff --git a/public/uploaded/e85efd21-e115-4103-b596-b91583928367.webp b/public/uploaded/e85efd21-e115-4103-b596-b91583928367.webp new file mode 100644 index 0000000..3ec3081 Binary files /dev/null and b/public/uploaded/e85efd21-e115-4103-b596-b91583928367.webp differ diff --git a/src/Controller/GeneralController.php b/src/Controller/GeneralController.php index 0d4b3d4..8fd296b 100644 --- a/src/Controller/GeneralController.php +++ b/src/Controller/GeneralController.php @@ -12,9 +12,11 @@ use Symfony\Component\Routing\Attribute\Route; class GeneralController extends AbstractController { #[Route('/', name: 'app_home')] - public function app_home(): Response + public function app_home(EntityManagerInterface $em): Response { - return $this->render('general/home.html.twig'); + return $this->render('general/home.html.twig', [ + 'posts' => $em->getRepository(Post::class)->findBycat('blog', 3) + ]); } #[Route('/sitemap.xml', name: 'app_sitemap')] @@ -23,8 +25,8 @@ class GeneralController extends AbstractController $response = new Response(); $response->headers->set('Content-Type', 'text/xml'); $posts = $em->getRepository(Post::class)->findAll(); - return $this->render('general/sitemap.html.twig',[ - 'posts'=>$posts - ],$response); + return $this->render('general/sitemap.html.twig', [ + 'posts' => $posts + ], $response); } } diff --git a/src/Entity/Post.php b/src/Entity/Post.php index f946cb6..dc6c1ef 100644 --- a/src/Entity/Post.php +++ b/src/Entity/Post.php @@ -68,6 +68,9 @@ class Post #[ORM\OneToMany(targetEntity: Comment::class, mappedBy: 'post', orphanRemoval: true)] private Collection $comments; + #[ORM\Column(type: Types::TEXT, nullable: true)] + private ?string $intro = null; + public function __construct() { $this->tree = new ArrayCollection(); @@ -276,4 +279,16 @@ class Post return $this; } + + public function getIntro(): ?string + { + return $this->intro; + } + + public function setIntro(?string $intro): static + { + $this->intro = $intro; + + return $this; + } } diff --git a/src/Repository/PostRepository.php b/src/Repository/PostRepository.php index 8c3e9e3..489238b 100644 --- a/src/Repository/PostRepository.php +++ b/src/Repository/PostRepository.php @@ -45,4 +45,16 @@ class PostRepository extends ServiceEntityRepository ->getOneOrNullResult() ; } + public function findBycat($cat='blog' , $count = 3): array + { + return $this->createQueryBuilder('p') + ->innerJoin('p.cat', 'c') + ->where('c.code = :cat') + ->setParameter('cat', $cat) + ->setMaxResults($count) + ->orderBy('p.dateSubmit','DESC') + ->getQuery() + ->getResult() + ; + } } diff --git a/templates/base.html.twig b/templates/base.html.twig index c0746dd..69845aa 100644 --- a/templates/base.html.twig +++ b/templates/base.html.twig @@ -24,7 +24,7 @@