| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- <?php
-
- namespace App\Http\Controllers\v3\Api;
-
- use Illuminate\Http\Request;
- use App\Http\Controllers\v3\Api\BaseController;
-
- use Config;
- use File;
- use Carbon\Carbon;
-
- use App\LatestModel\Staff;
- use App\LatestModel\StaffDetail;
- use App\LatestModel\Module\Form;
- use App\LatestModel\Module\FormStatus;
- use App\LatestModel\Module\Subscriber;
- use App\LatestModel\Module\WorkOrder;
- use App\LatestModel\Module\Docket;
- use App\LatestModel\Module\PackageDetail;
- use App\LatestModel\Module\Company;
- use App\LatestModel\Module\Coverage;
- use App\LatestModel\Module\Product;
-
- class CoverageController extends BaseController
- {
- /**
- * Get coverage
- *
- * @return json
- */
-
- public function displayCoverageData($type)
- {
- $i=0;
- $curr = Carbon::now()->getTimestamp();
- $nested_data = array();
-
- $coverage = Coverage::where('Type', $type)->orderBy('created_at','DESC')->get();
- if(!empty($coverage)){
- foreach ($coverage as $a) {
- $i++; $n1 = '';
-
- $reg_time = $a->created_at;
- $expiry_date = $reg_time->addDays(3);
- $expiry_date = $expiry_date->getTimestamp();
-
- if($curr < $expiry_date) {
- $n1 = "New/";
- }
-
- array_push($nested_data, array(
- 'index' => $n1.$i,
- 'address' => $a->building_name,
- // 'street' => $a->street,
- 'city' => $a->city,
- 'state' => $a->state,
- 'postcode' => $a->postcode,
- 'status_building' => $a->status_building,
- 'action' => $a->_id
- ));
- }
- }
- return \DataTables::of($nested_data)->make(true);
- }
-
- /**
- * Delete coverage list
- *
- * @return json
- */
- public function requestDeleteCoverage(Request $request)
- {
- $coverage = Coverage::where('_id',$request->id)->first();
-
- if(!empty($coverage)){
- $coverage->delete();
- return $this->sendResponse($coverage, 'Successfully delete coverage');
- }else {
- return $this->sendError('Record coverage not found!', '');
- }
- }
-
- }
|