updated routes and browser links

This commit is contained in:
2020-07-21 01:42:28 -05:00
parent 8c885636de
commit b9af1cb074
3 changed files with 50 additions and 41 deletions

View File

@@ -27,65 +27,49 @@ class SupplyChainController extends Controller
/**
* Display the supply chain dashboard
* Should contain a section for open contracts, closed contracts, and expired contracts.
*/
public function displaySupplyChainDashboard() {
$contracts = SupplyChainContract::where([
$openContracts = SupplyChainContract::where([
'state' => 'open',
])->get();
return view('supplychain.dashboard.main')->with('contracts', $contracts);
$closedContracts = SupplyChainContract::where([
'state' => 'closed',
])->get();
$completedContracts = SupplyChainContract::where([
'state' => 'completed',
])->get();
return view('supplychain.dashboard.main')->with('openContracts', $openContracts)
->with('closedContracts', $closedContracts)
->with('completedContracts', $completedContracts);
}
/**
* Show the user's open contracts
* Display my supply chain contracts dashboard
* Should contain a section for open contracts, closed contracts, and expired contracts
*/
public function displayMyOpenContractsDashboard() {
$contracts = SupplyChainContract::where([
public function displayMySupplyChainDashboard() {
$openContracts = SupplyChainContract::where([
'issuer_id' => auth()->user()->getId(),
'state' => 'open',
])->get();
return view('supplychain.dashboard.main')->with('contracts', $contracts);
}
/**
* Show the user's closed contracts
*/
public function displayMyClosedContractsDashboard() {
$contracts = SupplyChainContract::where([
$closedContracts = SupplyChainContract::where([
'issuer_id' => auth()->user()->getId(),
'state' => 'closed',
])->get();
return view('supplychain.dashboard.main')->with('contracts', $contracts);
}
/**
* Show the past contracts bidded on
*/
public function displayPastContractsDashboard() {
$contracts = array();
$acceptedBids = SupplyChainBid::where([
'bid_type' => 'accepted',
$completedContracts = SupplyChainContract::where([
'issuer_id' => auth()->user()->getId(),
'state' => 'completed',
])->get();
foreach($acceptedBids as $bid) {
$contracts = null;
$temp = SupplyChainContract::where([
'state' => 'closed',
])->get()->toArray();
$temp2 = SupplyChainContract::where([
'state' => 'completed',
])->get()->toArray();
array_push($contracts, $temp);
array_push($contracts, $temp2);
}
return view('supplychain.dashboard.past')->with('contracts', $contracts);
return view('supplychain.dashboard.main')->with('openContracts', $openContracts)
->with('closedContracts', $closedContracts)
->with('completedContracts', $completedContracts);
}
/**
@@ -126,7 +110,12 @@ class SupplyChainController extends Controller
* Display the delete contract page
*/
public function displayDeleteSupplyChainContract() {
return view('supplychain.forms.delete');
$contracts = SupplyChainContract::where([
'issuer_id' => auth()->user()->getId(),
'state' => 'open',
])->get();
return view('supplychain.forms.delete')->with('contracts', $contracts);
}
/**
@@ -186,9 +175,22 @@ class SupplyChainController extends Controller
//If the count is greater than 0, the user owns the contract.
//Proceed with ending the contract
if($count > 0) {
SupplyChainContract::where([
])->update([
]);
SupplyChainBid::where([
])->update([
]);
return redirect('/supplychain/dashboard')->with('success', 'Contract ended, and mails sent to the winning bidder.');
} else {
//If the count is zero, then redirect with error messsage
return redirect('/supplychain/dashboard')->with('error', '')
}
return redirect('/supplychain/dashboard')->with('success', 'Contract ended, and mails sent to the winning bidder.');

View File

@@ -13,6 +13,12 @@
<p>Dashboard</p>
</a>
</li>
<li class="nav-item">
<a href="/supplychain/my/dashboard" class="nav-link">
<i class="far fa-circle nav-icon"></i>
<p>My Dashboard</p>
</a>
</li>
<li class="nav-item">
<a href="/supplychain/contracts/new" class="nav-link">
<i class="far fa-circle nav-icon"></i>

View File

@@ -177,6 +177,7 @@ Route::group(['middleware' => ['auth']], function(){
* Supply Chain Contracts Controller display pages
*/
Route::get('/supplychain/dashboard', 'Contracts\SupplyChainController@displaySupplyChainDashboard');
Route::get('/supplychain/my/dashboard', 'Contracts\SupplyChainController@displayMySupplyChainDashboard');
Route::get('/supplychain/contracts/new', 'Contracts\SupplyChainController@displayNewSupplyChainContract');
Route::post('/supplychain/contracts/new', 'Contracts\SupplyChainController@storeNewSupplyChainContract');
Route::get('/supplychain/contracts/delete', 'Contracts\SupplyChainController@displayDeleteSupplyChainContract');