暫無描述

TemplatesController.php 20KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675
  1. <?php
  2. class TemplatesController extends \BaseController
  3. {
  4. /**
  5. * List all templates, grouped by program
  6. */
  7. public function profShow(Template $template)
  8. {
  9. return $this->show($template);
  10. }
  11. public function ProfIndex()
  12. {
  13. $title = 'Rubric List';
  14. $role = Auth::user()->role;
  15. $program_id = DB::table("program_user")
  16. ->where('user_id', Auth::user()->id)
  17. ->lists('program_id')[0];
  18. $school_id = DB::table('programs')
  19. ->where('id', $program_id)
  20. ->lists('school_id')[0];
  21. $templates = Template::orderBy('name')
  22. ->whereNull("school_id")
  23. ->orWhere(function ($query) use (&$school_id) {
  24. $query->where('school_id', $school_id)
  25. ->whereNull('program_id');
  26. })
  27. ->orWhere(function ($query) use (&$program_id, &$school_id) {
  28. $query->where('school_id', $school_id)
  29. ->where('program_id', $program_id);
  30. })
  31. ->get();
  32. return View::make('local.managers.shared.rubric_list', compact('title', 'global_templates', 'schools', 'templates', 'role'));
  33. }
  34. public function index()
  35. {
  36. $title = 'Rubric List';
  37. $global_templates = Template::whereNull('school_id')->whereNull('program_id')->get();
  38. $schools = School::with('programs.templates')
  39. ->orderBy('name')
  40. ->get();
  41. $role = Auth::user()->role;
  42. switch ($role) {
  43. case 1:
  44. $templates = Template::orderBy('name')->get();
  45. break;
  46. case 2:
  47. $templates = Template::orderBy('name')
  48. ->whereNull("school_id")
  49. ->orWhere('school_id', Auth::user()->school_id)
  50. ->get();
  51. break;
  52. case 3:
  53. case 4:
  54. $program_ids = DB::table("program_user")
  55. ->where('user_id', Auth::user()->id)
  56. ->lists('program_id');
  57. $school_ids = DB::table('programs')
  58. ->whereIn('id', $program_ids)
  59. ->lists('school_id');
  60. $templates = Template::orderBy('name')
  61. ->whereNull("school_id")
  62. ->orWhere(function ($query) use (&$school_ids) {
  63. $query->whereIn('school_id', $school_ids)
  64. ->whereNull('program_id');
  65. })
  66. ->orWhere(function ($query) use (&$program_ids, &$school_ids) {
  67. $query->where('school_id', $school_ids)
  68. ->where('program_id', $program_ids);
  69. });
  70. Log::info($templates->toSql());
  71. $templates = $templates->get();
  72. break;
  73. }
  74. Log::info($templates);
  75. //$templates = Template::orderBy('name')->get();
  76. return View::make('local.managers.shared.rubric_list', compact('title', 'global_templates', 'schools', 'templates', 'role'));
  77. }
  78. /*public function schoolCoordinatorIndex()
  79. {
  80. $title = 'Rubric List';
  81. $global_templates = Template::whereNull('school_id')->whereNull('program_id')->get();
  82. $schools = School::with('programs.templates')
  83. ->orderBy('name')
  84. ->get();
  85. $templates = Template::orderBy('name')->get();
  86. return View::make('local.managers.admins.rubric_list', compact('title', 'global_templates', 'schools', 'templates'));
  87. }*/
  88. public function show(Template $template)
  89. {
  90. $title = $template->name;
  91. $template->titles = DB::table('titles')
  92. ->join('template_title', 'template_title.title_id', '=', "titles.id")
  93. ->where('template_id', $template->id)
  94. ->orderBy('position', 'ASC')
  95. ->lists('text');
  96. $template->criteria = DB::table('criteria')
  97. ->join('template_criterion', 'template_criterion.criterion_id', '=', 'criteria.id')
  98. ->where('template_id', $template->id)
  99. ->select('criteria.*', 'criteria.id as criterion_id', 'template_criterion.id as template_criterion_id')
  100. ->orderBy('position')
  101. ->get();
  102. foreach ($template->criteria as $criterion) {
  103. $criterion->scales = DB::table('criterion_scale')
  104. ->join('scales', 'scales.id', '=', 'criterion_scale.scale_id')
  105. ->where('criterion_id', $criterion->criterion_id)
  106. ->orderBy('position')
  107. ->lists('description');
  108. $criterion->outcomes = DB::table('criterion_objective_outcome as cobo')
  109. ->join('outcomes', 'outcomes.id', '=', 'cobo.outcome_id')
  110. ->where('cobo.criterion_id', $criterion->criterion_id)
  111. ->select('outcomes.*')
  112. ->distinct()
  113. ->get();
  114. }
  115. return View::make('local.managers.admins.view_template', compact('template', 'title'));
  116. }
  117. public function onLoadFetch()
  118. {
  119. $json_to_send = [];
  120. $template_id = Input::get('id');
  121. $json_to_send["criteria"] = DB::table("criteria")->join('template_criterion', 'template_criterion.criterion_id', '=', 'criteria.id')
  122. ->where("template_criterion.template_id", '=', $template_id)
  123. ->get();
  124. Log::info($json_to_send["criteria"]);
  125. foreach ($json_to_send['criteria'] as $criteria) {
  126. $json_to_send['scales'][$criteria->criterion_id] = DB::table("scales")
  127. ->join('criterion_scale', 'criterion_scale.scale_id', '=', 'scales.id')
  128. ->where("criterion_scale.criterion_id", '=', $criteria->criterion_id)->orderBy('position', 'ASC')->get();
  129. }
  130. return json_encode($json_to_send);
  131. }
  132. /**
  133. * Show the form for creating a new rubric
  134. *
  135. * @return Response
  136. */
  137. public function newTemplate()
  138. {
  139. $title = "Rubric Builder";
  140. $templates = Template::orderBy('name', 'ASC')->get();
  141. $outcomes = Outcome::where("deactivation_date", '=', null)->orderBy('name', 'ASC')->get();
  142. $criteria = Criterion::orderBy('name', 'ASC')->get();
  143. $schools = School::orderBy('name', 'ASC')->get();
  144. $role = Auth::user()->role;
  145. $templates = NULL;
  146. $programs = NULL;
  147. // Returns templates depending on the type of user
  148. if ($role == 1) {
  149. $templates = Template::orderBy('name', 'ASC')->get();
  150. $programs = Program::orderBy('name', 'ASC')->get();
  151. } elseif ($role == 2) {
  152. $templates = Template::where('school_id', '=', Auth::user()->school->id)->orWhere('school_id', '=', NULL)->orderBy('name', 'ASC')->get();
  153. $programs = Auth::user()->school->programs;
  154. } elseif ($role == 3) {
  155. $templates = Template::where('school_id', '=', Auth::user()->programs[0]->school->id)->orWhere('school_id', '=', NULL)->orderBy('name', 'ASC')->get();
  156. $programs = Auth::user()->programs()->get();
  157. }
  158. return View::make('local.managers.shared.rubrics', compact('title', 'templates', 'outcomes', 'criteria', 'schools', 'programs'));
  159. }
  160. public function newTemplateProf()
  161. {
  162. return $this->newTemplate_new();
  163. }
  164. public function newTemplate_new()
  165. {
  166. $title = "Rubric Builder";
  167. $templates = Template::orderBy('name', 'ASC')->get();
  168. $outcomes = Outcome::where("deactivation_date", '=', null)->orderBy('name', 'ASC')->get();
  169. $schools = School::orderBy('name', 'ASC')->get();
  170. $role = Auth::user()->role;
  171. $templates = NULL;
  172. $programs = NULL;
  173. // Returns templates depending on the type of user
  174. if ($role == 1) {
  175. $templates = Template::orderBy('name', 'ASC')->get();
  176. $programs = Program::orderBy('name', 'ASC')->get();
  177. $criteria = Criterion::orderBy('name', 'ASC')->get();
  178. $school_id_user = NULL;
  179. } else {
  180. if ($role == 2) {
  181. $programs = Auth::user()->school->programs;
  182. $school_id_user = Auth::user()->school_id;
  183. }
  184. if ($role == 3) {
  185. $programs = Auth::user()->programs()->get();
  186. $school_id_user = Auth::user()->programs[0]->school->id;
  187. }
  188. if ($role == 4) {
  189. $programs = Auth::user()->programs()->get();
  190. $school_id_user = Auth::user()->programs[0]->school->id;
  191. }
  192. Log::info(json_encode($school_id_user));
  193. $program_ids = array();
  194. foreach ($programs as $program) {
  195. $program_ids[] = $program->id;
  196. }
  197. $criteria = Criterion::whereHas(
  198. 'programs',
  199. function ($q) use ($program_ids) {
  200. $q->whereIn('program_id', $program_ids);
  201. }
  202. )
  203. ->whereHas(
  204. 'getObjectivesAttribute',
  205. function ($q) {
  206. $q->where('objective_id', '!=', 0);
  207. }
  208. )
  209. ->orderBy('name', 'ASC')->get();
  210. }
  211. // Log::info("aqui".(count($criteria)));
  212. // Log::info(json_encode(count($criteria)));
  213. $templates = Template::where('school_id', '=', $school_id_user)->orWhere('school_id', '=', NULL)
  214. ->orderBy('name', 'ASC')->get();
  215. $criteria_ids = array();
  216. foreach ($criteria as $criterion) {
  217. $criteria_ids[] = $criterion->id;
  218. }
  219. $templates_fuera = Template::whereHas('criteria', function ($q) use ($criteria_ids) {
  220. $q->whereNotIn('criterion_id', $criteria_ids);
  221. })
  222. ->orderBy('name', 'ASC')->get();
  223. $templates_fuera_ids = array();
  224. foreach ($templates_fuera as $tf) {
  225. $templates_fuera_ids[] = $tf->id;
  226. }
  227. // Log::info(json_encode($templates_fuera_ids));
  228. // exit();
  229. $templates_dentro = Template::whereNotIn('id', $templates_fuera_ids)
  230. ->orderBy('name', 'ASC')->get();
  231. // if(!isset($templates_dentro))$templates_dentro=
  232. // var_dump(json_encode($templates_dentro));
  233. // }
  234. $templates_fuera = array();
  235. return View::make('local.managers.shared.rubrics_new', compact('title', 'templates_dentro', 'templates_fuera', 'outcomes', 'criteria', 'schools', 'programs', 'criteria_ids'));
  236. }
  237. public function fetchObjectivesForTemplate()
  238. {
  239. $criteria_ids = Input::get("allCriteria");
  240. $criteria = [];
  241. //Acho im sorry pero no tengo idea porque sale un error que haría eso más eficiente.
  242. foreach ($criteria_ids as $crit_id) {
  243. $crit = Criterion::where('id', $crit_id)->first();
  244. if (!isset($crit)) {
  245. return "NO pa";
  246. }
  247. $crit->all_objectives = Objective::join("criterion_objective_outcome", 'objectives.id', '=', 'criterion_objective_outcome.objective_id')
  248. ->where('criterion_id', $crit->id)
  249. ->select('objectives.*')
  250. ->groupBy('objectives.id')
  251. ->get();
  252. $criteria[] = $crit;
  253. }
  254. return $criteria;
  255. }
  256. /**
  257. * Save a new rubric
  258. *
  259. * @return Response
  260. */
  261. public function create()
  262. {
  263. DB::beginTransaction();
  264. $template = new Template;
  265. $template->name = Input::get('name');
  266. $template->is_visible = Input::get('is_visible');
  267. $template->expected_percentage = Input::get('expected_percentage');
  268. $template->expected_points = Input::get('expected_points');
  269. // If user can set the school (that is, if school_id is not undefined)
  270. // set the school id or set to null
  271. if (is_numeric(Input::get('school_id'))) {
  272. if (Input::get('school_id') != 0)
  273. $template->school_id = Input::get('school_id');
  274. elseif (Input::get('school_id') == 0)
  275. $template->school_id = NULL;
  276. }
  277. // If user can set the program (that is, if program_id is not undefined)
  278. // set the program id or set to null
  279. if (is_numeric(Input::get('program_id'))) {
  280. if (Input::get('program_id') != 0)
  281. $template->program_id = Input::get('program_id');
  282. elseif (Input::get('program_id') == 0)
  283. $template->program_id = NULL;
  284. }
  285. // If the user is any coordinator, set the school id
  286. // If the user is a program coordinator, also set program id
  287. switch (Auth::user()->role) {
  288. case 2:
  289. $template->school_id = Auth::user()->school->id;
  290. break;
  291. //TODO esto yo no lo hice
  292. case 3:
  293. $template->school_id = Auth::user()->programs[0]->school->id;
  294. //Comenté esto porque siempre va a estar el program_id
  295. //TODO
  296. if ($template->program_id == NULL)
  297. $template->program_id = Auth::user()->programs[0]->id;
  298. break;
  299. }
  300. $criteria = Input::get('criteria');
  301. $max_score = Input::get('max_score');
  302. $titles = Input::get('titles');
  303. $template->num_scales = count($titles);
  304. $template->max_score = $max_score;
  305. if ($template->save()) {
  306. $templateId = $template->id;
  307. foreach ($criteria as $index => $criterion_id) {
  308. if (!(DB::insert("insert into template_criterion (`template_id`,`criterion_id`, `position`) values ({$templateId},{$criterion_id}, '{$index}')"))) {
  309. Session::flash('status', 'danger');
  310. Session::flash('message', 'Rubric could not be created.');
  311. DB::rollback();
  312. return;
  313. }
  314. }
  315. foreach ($titles as $index => $text) {
  316. $query = DB::table('titles')
  317. ->where('text', $text)->first();
  318. if ($query) {
  319. $result = DB::insert("insert into `template_title` (`template_id`, `title_id`, `position`) values ({$templateId}, {$query->id}, {$index})");
  320. if (!$result) {
  321. Session::flash('status', 'danger');
  322. Session::flash('message', 'Rubric could not be created.');
  323. DB::rollback();
  324. return;
  325. }
  326. } else {
  327. $result1 = DB::insert("insert into `titles` (`text`) values ('{$text}')");
  328. if (!$result1) {
  329. Session::flash('status', 'danger');
  330. Session::flash('message', 'Rubric could not be created.');
  331. DB::rollback();
  332. return;
  333. }
  334. $query = DB::table('titles')
  335. ->where('text', $text)->first();
  336. $result = DB::insert("insert into `template_title` (`template_id`, `title_id`, `position`) values ({$templateId}, {$query->id}, {$index})");
  337. if (!$result) {
  338. Session::flash('status', 'danger');
  339. Session::flash('message', 'Rubric could not be created.');
  340. DB::rollback();
  341. return;
  342. }
  343. }
  344. }
  345. Session::flash('status', 'success');
  346. Session::flash('message', 'Rubric created. You can now select it from the list.');
  347. DB::commit();
  348. return;
  349. } else {
  350. Session::flash('status', 'danger');
  351. Session::flash('message', 'Rubric could not be created.');
  352. DB::rollback();
  353. return;
  354. }
  355. }
  356. /**
  357. * Return a specific template
  358. *
  359. * @return Template
  360. */
  361. public function fetch()
  362. {
  363. $template_info = [];
  364. $template_info['template'] = Template::find(Input::get('id'));
  365. $template_info['criterion'] = DB::table('criteria')
  366. ->join('template_criterion', 'template_criterion.criterion_id', '=', 'criteria.id')
  367. ->where("template_criterion.template_id", '=', Input::get('id'))
  368. ->get();
  369. Log::info(json_encode($template_info['criterion']));
  370. // Log::info(($temp_crit->program_ids));
  371. foreach ($template_info['criterion'] as $temp_crit) {
  372. $temp_crit->scales = DB::table('scales')
  373. ->join('criterion_scale', 'criterion_scale.scale_id', '=', 'scales.id')
  374. ->where('criterion_scale.criterion_id', '=', $temp_crit->criterion_id)
  375. ->orderBy('position', 'ASC')
  376. ->get();
  377. $temp_crit->program_ids = json_encode(DB::table('program_criterion')
  378. ->where('criterion_id', $temp_crit->id)
  379. ->lists('program_id'));
  380. Log::info("ee" . json_encode($temp_crit->program_ids));
  381. $temp_crit->objectives = DB::table('criterion_objective_outcome')
  382. ->join('objectives', 'objectives.id', '=', 'criterion_objective_outcome.objective_id')
  383. ->where('criterion_id', $temp_crit->id)
  384. ->select('objectives.*')
  385. ->distinct()
  386. ->lists('text');
  387. $outcomeID = DB::table('criterion_objective_outcome')->where('criterion_id', '=', $temp_crit->criterion_id)
  388. ->lists('outcome_id');
  389. $outcomes = DB::table('outcomes')->whereIn('id', $outcomeID)->get();
  390. $outcomeStr = '';
  391. foreach ($outcomes as $key => $outcome) {
  392. $outcomeStr .= $outcome->name . ', ';
  393. }
  394. $outcomeStr = rtrim($outcomeStr, ',');
  395. $temp_crit->outcomes = $outcomeStr;
  396. }
  397. Log::info("ee2" . json_encode($template_info));
  398. $template_info['titles'] = DB::table('titles')
  399. ->join('template_title', 'template_title.title_id', '=', 'titles.id')
  400. ->where('template_id', Input::get('id'))
  401. ->orderBy('position')
  402. ->get();
  403. // Log::info(json_encode($template_info));
  404. return json_encode($template_info);
  405. }
  406. /**
  407. * Update the specified resource in storage.
  408. *
  409. * @return Response
  410. */
  411. public function update()
  412. {
  413. DB::beginTransaction();
  414. $template = Template::find(Input::get('id'));
  415. Log::info(Input::all());
  416. $template->name = Input::get('name');
  417. $template->is_visible = Input::get('is_visible');
  418. $template->expected_percentage = Input::get('expected_percentage');
  419. $template->expected_points = Input::get('expected_points');
  420. // If user can set the school (that is, if school_id is not undefined)
  421. // set the school id or set to null
  422. if (is_numeric(Input::get('school_id'))) {
  423. if (Input::get('school_id') != 0)
  424. $template->school_id = Input::get('school_id');
  425. elseif (Input::get('school_id') == 0)
  426. $template->school_id = NULL;
  427. }
  428. // If user can set the program (that is, if program_id is not undefined)
  429. // set the program id or set to null
  430. if (is_numeric(Input::get('program_id'))) {
  431. if (Input::get('program_id') != 0)
  432. $template->program_id = Input::get('program_id');
  433. elseif (Input::get('program_id') == 0)
  434. $template->program_id = NULL;
  435. }
  436. switch (Auth::user()->role) {
  437. case 2:
  438. $template->school_id = Auth::user()->school->id;
  439. break;
  440. case 3:
  441. $template->school_id = Auth::user()->programs[0]->school->id;
  442. if ($template->program_id == NULL)
  443. $template->program_id = Auth::user()->programs[0]->id;
  444. break;
  445. }
  446. $criteria = Input::get('criteria');
  447. $max_score = Input::get('max_score');
  448. $titles = Input::get('titles');
  449. $template->num_scales = count($titles);
  450. $template->max_score = $max_score;
  451. //$division = $max_score / count($scales[0]);
  452. if ($template->save()) {
  453. $templateId = $template->id;
  454. DB::delete("delete from template_criterion where template_id ={$template->id}");
  455. foreach ($criteria as $index => $criterion_id) {
  456. if (!DB::insert("insert into template_criterion (`template_id`,`criterion_id`, `position`) values ({$templateId},{$criterion_id}, {$index})")) {
  457. Session::flash('status', 'danger');
  458. Session::flash('message', 'Rubric could not be created.');
  459. DB::rollback();
  460. return;
  461. }
  462. }
  463. DB::delete("delete from template_title where template_id = {$template->id}");
  464. foreach ($titles as $index => $text) {
  465. $query = DB::table('titles')
  466. ->where('text', $text)->first();
  467. if ($query) {
  468. $result = DB::insert("insert into `template_title` (`template_id`, `title_id`, `position`) values ({$templateId}, {$query->id}, {$index})");
  469. if (!$result) {
  470. Session::flash('status', 'danger');
  471. Session::flash('message', 'Rubric could not be created.');
  472. DB::rollback();
  473. return;
  474. }
  475. } else {
  476. $result1 = DB::insert("insert into `titles` (`text`) values ('{$text}')");
  477. if (!$result1) {
  478. Session::flash('status', 'danger');
  479. Session::flash('message', 'Rubric could not be created.');
  480. DB::rollback();
  481. return;
  482. }
  483. $query = DB::table('titles')
  484. ->where('text', $text)->first();
  485. $result = DB::insert("insert into `template_title` (`template_id`, `title_id`, `position`) values ({$templateId}, {$query->id}, {$index})");
  486. if (!$result) {
  487. Session::flash('status', 'danger');
  488. Session::flash('message', 'Rubric could not be created.');
  489. DB::rollback();
  490. return;
  491. }
  492. }
  493. }
  494. Session::flash('status', 'success');
  495. Session::flash('message', 'Rubric updated (' . date('m/d/y, h:i:s a') . ').');
  496. DB::commit();
  497. } else {
  498. Session::flash('status', 'danger');
  499. Session::flash('message', 'Rubric could not be updated (' . date('m/d/y, h:i:s a') . ').');
  500. DB::commit();
  501. }
  502. }
  503. /**
  504. * Remove the specified resource from storage.
  505. *
  506. * @return Response
  507. */
  508. public function destroy()
  509. {
  510. $template = Template::find(Input::get('id'));
  511. if ($template->delete()) {
  512. Session::flash('status', 'success');
  513. Session::flash('message', 'Rubric deleted.');
  514. } else {
  515. Session::flash('status', 'danger');
  516. Session::flash('message', 'Rubric could not be deleted.');
  517. }
  518. return;
  519. }
  520. public function printview($id)
  521. {
  522. try {
  523. $template = Template::find($id);
  524. $template->titles = DB::table('titles')
  525. ->join('template_title', 'template_title.title_id', '=', 'titles.id')
  526. ->where("template_id", $template->id)
  527. ->orderBy('position', 'ASC')
  528. ->lists('text');
  529. $template_criterion = DB::table('template_criterion')
  530. ->join('criteria', 'criteria.id', '=', 'template_criterion.criterion_id')
  531. ->where('template_id', $template->id)
  532. ->orderBy('position', 'ASC')
  533. ->get();
  534. foreach ($template_criterion as $single_crit) {
  535. $single_crit->scales = DB::table('criterion_scale')
  536. ->join('scales', 'criterion_scale.scale_id', '=', 'scales.id')
  537. ->where('criterion_id', $single_crit->id)
  538. ->orderBy('position')
  539. ->lists('description');
  540. $single_crit->outcomes = DB::table('outcomes')
  541. ->join('criterion_objective_outcome', 'criterion_objective_outcome.outcome_id', '=', 'outcomes.id')
  542. ->where('criterion_id', $single_crit->id)
  543. ->select('name')
  544. ->distinct()
  545. ->lists('name');
  546. }
  547. $title = $template->name;
  548. if ($template->school_id != NULL)
  549. $school = $template->school->name;
  550. else
  551. $school = 'All Schools';
  552. if ($template->program_id != NULL)
  553. $program = $template->program->name;
  554. else
  555. $program = 'All Programs';
  556. return View::make('local.managers.shared.print_rubric', compact('title', 'template_criterion', 'template', 'school', 'program'));
  557. } catch (Exception $e) {
  558. Session::flash('status', 'danger');
  559. Session::flash('message', $e->getMessage());
  560. return Redirect::back();
  561. }
  562. }
  563. }