Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

CoverageController.php 2.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <?php
  2. namespace App\Http\Controllers\v3\Api;
  3. use Illuminate\Http\Request;
  4. use App\Http\Controllers\v3\Api\BaseController;
  5. use Config;
  6. use File;
  7. use Carbon\Carbon;
  8. use App\LatestModel\Staff;
  9. use App\LatestModel\StaffDetail;
  10. use App\LatestModel\Module\Form;
  11. use App\LatestModel\Module\FormStatus;
  12. use App\LatestModel\Module\Subscriber;
  13. use App\LatestModel\Module\WorkOrder;
  14. use App\LatestModel\Module\Docket;
  15. use App\LatestModel\Module\PackageDetail;
  16. use App\LatestModel\Module\Company;
  17. use App\LatestModel\Module\Coverage;
  18. use App\LatestModel\Module\Product;
  19. class CoverageController extends BaseController
  20. {
  21. /**
  22. * Get coverage
  23. *
  24. * @return json
  25. */
  26. public function displayCoverageData($type)
  27. {
  28. $i=0;
  29. $curr = Carbon::now()->getTimestamp();
  30. $nested_data = array();
  31. $coverage = Coverage::where('Type', $type)->orderBy('created_at','DESC')->get();
  32. if(!empty($coverage)){
  33. foreach ($coverage as $a) {
  34. $i++; $n1 = '';
  35. $reg_time = $a->created_at;
  36. $expiry_date = $reg_time->addDays(3);
  37. $expiry_date = $expiry_date->getTimestamp();
  38. if($curr < $expiry_date) {
  39. $n1 = "New/";
  40. }
  41. array_push($nested_data, array(
  42. 'index' => $n1.$i,
  43. 'address' => $a->building_name,
  44. // 'street' => $a->street,
  45. 'city' => $a->city,
  46. 'state' => $a->state,
  47. 'postcode' => $a->postcode,
  48. 'status_building' => $a->status_building,
  49. 'action' => $a->_id
  50. ));
  51. }
  52. }
  53. return \DataTables::of($nested_data)->make(true);
  54. }
  55. /**
  56. * Delete coverage list
  57. *
  58. * @return json
  59. */
  60. public function requestDeleteCoverage(Request $request)
  61. {
  62. $coverage = Coverage::where('_id',$request->id)->first();
  63. if(!empty($coverage)){
  64. $coverage->delete();
  65. return $this->sendResponse($coverage, 'Successfully delete coverage');
  66. }else {
  67. return $this->sendError('Record coverage not found!', '');
  68. }
  69. }
  70. }