public function showProfile($id) { $user = User::find($id); $user_id = $user->getId(); return view('profile', ['user' => $user]); }
use Doctrine\ORM\Mapping as ORM; /** * @ORM\Entity * @ORM\Table(name="posts") */ class Post { /** * @ORM\Id * @ORM\Column(type="integer") * @ORM\GeneratedValue(strategy="AUTO") */ private $id; /** * Get the ID of the current post. * * @return int */ public function getId() { return $this->id; } // Other methods and properties... }This code defines an entity class for a `posts` table, and includes a `getId` method that returns the ID of the current post object. Package/Library: Symfony Doctrine ORM