updated routes and browser links
This commit is contained in:
@@ -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([
|
||||||
|
'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() {
|
public function displayMySupplyChainDashboard() {
|
||||||
$contracts = SupplyChainContract::where([
|
$openContracts = SupplyChainContract::where([
|
||||||
'issuer_id' => auth()->user()->getId(),
|
'issuer_id' => auth()->user()->getId(),
|
||||||
'state' => 'open',
|
'state' => 'open',
|
||||||
])->get();
|
])->get();
|
||||||
|
|
||||||
return view('supplychain.dashboard.main')->with('contracts', $contracts);
|
$closedContracts = SupplyChainContract::where([
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Show the user's closed contracts
|
|
||||||
*/
|
|
||||||
public function displayMyClosedContractsDashboard() {
|
|
||||||
$contracts = SupplyChainContract::where([
|
|
||||||
'issuer_id' => auth()->user()->getId(),
|
'issuer_id' => auth()->user()->getId(),
|
||||||
'state' => 'closed',
|
'state' => 'closed',
|
||||||
])->get();
|
])->get();
|
||||||
|
|
||||||
return view('supplychain.dashboard.main')->with('contracts', $contracts);
|
$completedContracts = SupplyChainContract::where([
|
||||||
}
|
'issuer_id' => auth()->user()->getId(),
|
||||||
|
'state' => 'completed',
|
||||||
/**
|
|
||||||
* Show the past contracts bidded on
|
|
||||||
*/
|
|
||||||
public function displayPastContractsDashboard() {
|
|
||||||
$contracts = array();
|
|
||||||
|
|
||||||
$acceptedBids = SupplyChainBid::where([
|
|
||||||
'bid_type' => 'accepted',
|
|
||||||
])->get();
|
])->get();
|
||||||
|
|
||||||
foreach($acceptedBids as $bid) {
|
return view('supplychain.dashboard.main')->with('openContracts', $openContracts)
|
||||||
$contracts = null;
|
->with('closedContracts', $closedContracts)
|
||||||
|
->with('completedContracts', $completedContracts);
|
||||||
$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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -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.');
|
||||||
|
|||||||
@@ -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>
|
||||||
|
|||||||
@@ -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');
|
||||||
|
|||||||
Reference in New Issue
Block a user