Esempio n. 1
0
 /**
  * deletes the company that the user has chosen
  * @param  integer $id company id
  */
 public function delete($id)
 {
     // Load the company
     $company = \App\Company::loadCompany($id);
     // did we pass validation and find the company
     if (empty($company)) {
         return Redirect::route('company');
     }
     $company->active = false;
     $company->save();
     // we will need to find any bills associated with the company
     // make them inactive also
     foreach ($company->bills as $bill) {
         $bill->active = false;
         $bill->save();
     }
     Session::flash('success', ['The company has been deleted successfully, and all associated bills have been removed']);
     return Redirect::route('company');
 }