find by id symfony 4 code example
Example 1: symfony findby
$repository = $this->getDoctrine()->getRepository(Product::class);
$product = $repository->find($id);
$product = $repository->findOneBy(['name' => 'Keyboard']);
$product = $repository->findOneBy([
'name' => 'Keyboard',
'price' => 1999,
]);
$products = $repository->findBy(
['name' => 'Keyboard'],
['price' => 'ASC']
);
$products = $repository->findAll();
Example 2: symfony findoneby
$service = $repository->findBy(array('name' => 'Registration'),array('name' => 'ASC'),1 ,0)[0];