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

View File

@@ -13,6 +13,12 @@
<p>Dashboard</p> <p>Dashboard</p>
</a> </a>
</li> </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"> <li class="nav-item">
<a href="/supplychain/contracts/new" class="nav-link"> <a href="/supplychain/contracts/new" class="nav-link">
<i class="far fa-circle nav-icon"></i> <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 * Supply Chain Contracts Controller display pages
*/ */
Route::get('/supplychain/dashboard', 'Contracts\SupplyChainController@displaySupplyChainDashboard'); Route::get('/supplychain/dashboard', 'Contracts\SupplyChainController@displaySupplyChainDashboard');
Route::get('/supplychain/my/dashboard', 'Contracts\SupplyChainController@displayMySupplyChainDashboard');
Route::get('/supplychain/contracts/new', 'Contracts\SupplyChainController@displayNewSupplyChainContract'); Route::get('/supplychain/contracts/new', 'Contracts\SupplyChainController@displayNewSupplyChainContract');
Route::post('/supplychain/contracts/new', 'Contracts\SupplyChainController@storeNewSupplyChainContract'); Route::post('/supplychain/contracts/new', 'Contracts\SupplyChainController@storeNewSupplyChainContract');
Route::get('/supplychain/contracts/delete', 'Contracts\SupplyChainController@displayDeleteSupplyChainContract'); Route::get('/supplychain/contracts/delete', 'Contracts\SupplyChainController@displayDeleteSupplyChainContract');