Fatal error: Call to a member function getId() on null : <p>I have a error saying that,</p>

<pre><code>Fatal error: Call to a member function getId() on null on line 63
</code></pre>

<p>but how can i check the element, here is my code</p>

<pre><code>54 public function edit($id) {
55  $form_group = $this-&gt;dm-&gt;find(Form_Group::class, $id);
56  if (empty($form_group)) {
57      $this-&gt;app-&gt;flash('error', 'Invalid record selected.');
58      $this-&gt;app-&gt;redirect($this-&gt;app-&gt;urlFor('form-group-list'));
59      die;
60  }
61
62  $record_company = $form_group-&gt;getCompany();
63  $enabled_modules = Common_Helper::get_enabled_modules($record_company-&gt;getId());
</code></pre>
