Skip to content

Commit

Permalink
Issue history
Browse files Browse the repository at this point in the history
  • Loading branch information
rmnpawar committed Sep 23, 2021
1 parent f99d618 commit ab7c17b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
24 changes: 24 additions & 0 deletions app/Http/Controllers/ConsumableController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace App\Http\Controllers;

use App\Consumable;
use App\ConsumableRequest;
use App\Service\ConsumableService;
use Illuminate\Http\Request;

Expand All @@ -25,5 +26,28 @@ public function availableConsumables($id)
return ConsumableService::availableConsumables($id);
}

public function issueHistory(Request $request)
{
$query = ConsumableRequest::query();

if ($request->has('asset_id')) {
$query->where('asset_id', $request->get('asset_id'));
}

if ($request->has('sub_category_id')) {
$query->where('sub_category_id', $request->get('sub_category_id'));
}

if ($request->has('consumable_id')) {
$query->where('consumable_id', $request->get('consumable_id'));
}

if ($request->has('section_id')) {
$query->where('section_id', $request->get('section_id'));
}

$issues = $query->where('status',3)->get()->map->format();

return response()->json($issues, 200);
}
}
1 change: 1 addition & 0 deletions routes/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@
Route::group(['prefix' => '/consumables'], function() {
Route::get('/', 'ConsumableController@index');
Route::post('/', 'ConsumableController@store');
Route::get('/history', 'ConsumableController@issueHistory');
Route::get('/for_id/{id}', 'ConsumableController@availableConsumables');
});

Expand Down

0 comments on commit ab7c17b

Please sign in to comment.