Created
July 9, 2020 00:40
-
-
Save NandoKstroNet/0c6f68547b2fb16b46d5d38362255ddb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Controller; | |
use App\Entity\Order; | |
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; | |
use Symfony\Component\Routing\Annotation\Route; | |
use App\Entity\User; | |
class DefaultController extends AbstractController | |
{ | |
/** | |
* @Route("/", name="default") | |
*/ | |
public function index() | |
{ | |
$name = 'Nanderson Castro'; | |
$user = $this->getDoctrine()->getRepository(User::class)->find(1); | |
dump($user->getOrder()->toArray()); | |
$order = $this->getDoctrine()->getRepository(Order::class)->find(2); | |
dump($order->getUser()->getFirstName()); | |
// $order = new Order(); | |
// $order->setReference('CODIGO_COMPRA_DOIS'); | |
// $order->setItems('ITEMS'); | |
// $order->setUser($user); | |
// | |
// $order->setCreatedAt(new \DateTime('now', new \DateTimeZone('America/Sao_Paulo'))); | |
// $order->setUpdatedAt(new \DateTime('now', new \DateTimeZone('America/Sao_Paulo'))); | |
// | |
// $this->getDoctrine()->getManager()->persist($order); | |
// $this->getDoctrine()->getManager()->flush(); | |
return $this->render('index.html.twig', compact('name', 'user')); | |
} | |
/** | |
* @Route("/product/{slug}", name="product_single") | |
*/ | |
public function product($slug) | |
{ | |
return $this->render('single.html.twig', compact('slug')); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment