From 5564b09c3bc552a28d4c9a9c180f6bf7abc093fe Mon Sep 17 00:00:00 2001 From: drkthunder02 Date: Sat, 27 Apr 2019 03:23:21 -0500 Subject: [PATCH] contract blades --- app/Http/Controllers/ContractController.php | 34 +++++- app/Models/Contracts/Contract.php | 1 + ...19_04_24_000001_create_contracts_table.php | 1 + .../contracts/admin/contractpanel.blade.php | 3 + .../contracts/admin/newcontract.blade.php | 10 +- .../views/contracts/allcontracts.blade.php | 55 ++++++++- resources/views/contracts/enterbid.blade.php | 3 +- .../contracts/privatecontracts.blade.php | 68 +++++++---- .../views/contracts/publiccontracts.blade.php | 107 +++++++++++++----- 9 files changed, 222 insertions(+), 60 deletions(-) diff --git a/app/Http/Controllers/ContractController.php b/app/Http/Controllers/ContractController.php index 140adbde8..367c670d5 100644 --- a/app/Http/Controllers/ContractController.php +++ b/app/Http/Controllers/ContractController.php @@ -63,7 +63,8 @@ class ContractController extends Controller $data = array(); //Fetch all of the current contracts from the database - $contracts = Contract::where(['end_date', '>=', $today])->get(); + $contracts = Contract::where(['end_date', '>=', $today]) + ->where(['type' => 'public'])->get(); //Check if no contracts were pulled from the database if($contracts != null) { @@ -96,11 +97,26 @@ class ContractController extends Controller $today = Carbon::now(); //Fetch all of the current contracts from the database - $contracts = Contract::where(['end_date', '>=', $today])->get(); + $contracts = Contract::where(['end_date', '>=', $today]) + ->where(['type' => 'private'])->get(); return view ('contracts.privatecontracts')->with('contracts', $contracts); } + /** + * Controller function to display a page to allow a bid + * + */ + public function displayBid(Request $request) { + $this->validate($request, [ + 'contract_id', + ]); + + $contractId = $request->contract_id; + + return view('contracts.enterbid')->with('contractId', $contractId); + } + /** * Controller function to store a new bid */ @@ -140,4 +156,18 @@ class ContractController extends Controller return redirect('contracts/display/public')->with('success', 'Bid deleted.'); } + + /** + * Controller function to display modify bid page + */ + public function displayModifyBid(Request $request) { + + } + + /** + * Controller function to modify a bid + */ + public function modifyBid(Request $request) { + + } } diff --git a/app/Models/Contracts/Contract.php b/app/Models/Contracts/Contract.php index dfb03ebaf..999f7ad37 100644 --- a/app/Models/Contracts/Contract.php +++ b/app/Models/Contracts/Contract.php @@ -19,6 +19,7 @@ class Contract extends Model */ protected $fillable = [ 'title', + 'type', 'end_date', 'body', 'final_cost', diff --git a/database/migrations/2019_04_24_000001_create_contracts_table.php b/database/migrations/2019_04_24_000001_create_contracts_table.php index 734604b00..83e74101c 100644 --- a/database/migrations/2019_04_24_000001_create_contracts_table.php +++ b/database/migrations/2019_04_24_000001_create_contracts_table.php @@ -17,6 +17,7 @@ class CreateContractsTable extends Migration Schema::create('contracts', function(Blueprint $table) { $table->increments('contract_id')->unique(); $table->string('title'); + $table->string('type'); $table->date('end_date'); $table->text('body'); $table->boolean('finished'); diff --git a/resources/views/contracts/admin/contractpanel.blade.php b/resources/views/contracts/admin/contractpanel.blade.php index 851266b70..b4d21f96e 100644 --- a/resources/views/contracts/admin/contractpanel.blade.php +++ b/resources/views/contracts/admin/contractpanel.blade.php @@ -14,6 +14,9 @@

{{ $contract['title'] }}

+

+ Type: {{ $contract['type'] }} +

{!! Form::open(['action' => 'ContractAdminController@deleteContract', 'method' => 'POST']) !!} {{ Form::hidden('contract_id', $contract['contract_id']) }} diff --git a/resources/views/contracts/admin/newcontract.blade.php b/resources/views/contracts/admin/newcontract.blade.php index 83b11217b..5aa2f0355 100644 --- a/resources/views/contracts/admin/newcontract.blade.php +++ b/resources/views/contracts/admin/newcontract.blade.php @@ -18,13 +18,19 @@ {{ Form::text('name', '', ['class' => 'form-control', 'placeholder' => 'Some Name']) }}

- {{ Form::label('description', 'Description') }} - {{ Form::textarea('description', '', ['class' => 'form-control']) }} + {{ Form::label('body', 'Description') }} + {{ Form::textarea('body', '', ['class' => 'form-control']) }}
{{ Form::label('date', 'End Date') }} {{ Form::text('date', '', ['class' => 'form-control', 'placeholder' => '4/24/2019']) }}
+
+ {{ Form::label('type', 'Public Contract') }} + {{ Form::radio('type', 'public', true) }} + {{ Form::label('type', 'Private Contract') }} + {{ Form::radio('type', 'private', false) }} +
{{ Form::submit('Submit', ['class' => 'btn btn-primary']) }} {!! Form::close() !!} diff --git a/resources/views/contracts/allcontracts.blade.php b/resources/views/contracts/allcontracts.blade.php index 07092f6df..193e8acdb 100644 --- a/resources/views/contracts/allcontracts.blade.php +++ b/resources/views/contracts/allcontracts.blade.php @@ -1,4 +1,57 @@ @extends('layouts.b4') @section('content') - +
+

All Contracts

+
+
+@if($contracts != null) +@foreach($contracts as $contract) +
+
+
+
+
+

+ {{ $contract['title'] }} +

+

+ Type: {{ $contract['type'] }} +

+

+ {!! Form::open(['action' => 'ContractController@displayBid', 'method' => 'POST']) !!} + {{ Form::hidden('contract_id', $contract['contract_id']) }} + {{ Form::submit('Bid', ['class' => 'btn btn-primary']) }} + {!! Form::close() !!} +

+
+
+
+ End Date: {{ $contract['end_date'] }} +
+ +
+ {{ $contract['body'] }} +
+
+
+
+
+
+
+
+@endforeach +@else +
+
+
+
+
+ No Contracts Issued +
+
+
+
+
+
+
@endsection \ No newline at end of file diff --git a/resources/views/contracts/enterbid.blade.php b/resources/views/contracts/enterbid.blade.php index 4bef0898a..bb15a8908 100644 --- a/resources/views/contracts/enterbid.blade.php +++ b/resources/views/contracts/enterbid.blade.php @@ -1,7 +1,7 @@ @extends('layouts.b4') @section('content')
-

Test Page - Enter Bid

+

Bid on Contract


@@ -16,6 +16,7 @@
{{ Form::label('bid', 'Bid') }} {{ Form::text('bid', '', ['class' => 'form-control', 'placeholder' => '1.0B']) }} + {{ Form::hidden('contract_id', $contractId) }}
{{ Form::submit('Submit', ['class' => 'btn btn-primary']) }} {!! Form::close() !!} diff --git a/resources/views/contracts/privatecontracts.blade.php b/resources/views/contracts/privatecontracts.blade.php index 7cbceca7a..dd49e963a 100644 --- a/resources/views/contracts/privatecontracts.blade.php +++ b/resources/views/contracts/privatecontracts.blade.php @@ -4,31 +4,53 @@

Test Page


+@if($contracts != null)
-
-
-
- New Contracts -
-
- - - - - - - - - - - - - - - -
NumberNameItemsEnd Date
1Name2 Nags24-04-2019
+
+
+
+
+

+ {{ $contract['title'] }} +

+

+ Type: Private +

+

+ {!! Form::open(['action' => 'ContractController@displayBid', 'method' => 'POST']) !!} + {{ Form::hidden('contract_id', $contract['contract_id']) }} + {{ Form::submit('Bid', ['class' => 'btn btn-primary']) }} + {!! Form::close() !!} +

+
+
+
+ End Date: {{ $contract['end_date'] }} +
+ +
+ {{ $contract['body'] }} +
+
+
+
-
+
+@else +
+
+
+
+
+ No Contracts Issued +
+
+
+
+
+
+
+@endif @endsection \ No newline at end of file diff --git a/resources/views/contracts/publiccontracts.blade.php b/resources/views/contracts/publiccontracts.blade.php index 96bce36ef..899f14a13 100644 --- a/resources/views/contracts/publiccontracts.blade.php +++ b/resources/views/contracts/publiccontracts.blade.php @@ -4,42 +4,87 @@

Test Page


+@if($contracts != null)
-
-
-
- New Contracts -
-
- - - - - - - - - - - - - - - -
NumberNameItemsEnd Date
1Name2 Nags24-04-2019
+
+
+
+
+

+ {{ $contract['title'] }} +

+

+ Type: Public +

+

+ {!! Form::open(['action' => 'ContractController@displayBid', 'method' => 'POST']) !!} + {{ Form::hidden('contract_id', $contract['contract_id']) }} + {{ Form::submit('Bid', ['class' => 'btn btn-primary']) }} + {!! Form::close() !!} +

+
+
+
+ End Date: {{ $contract['end_date'] }} +
+ +
+ {{ $contract['body'] }} +
+
+
+ + @if($data['bids'] != null) + + + + + + + @foreach($data['bids'] as $bid) + + + + @if(auth()->user()->character_id == $bid['character_id']) + {{ Form::open(['action' => 'ContractController@displayModifyBid', 'method' => 'POST']) }} + {{ Form::hidden('id', $bid['id']) }} + {{ Form::hidden('contract_id', $bid['contract_id']) }} + {{ Form::submit('Modify Bid', ['class' => 'btn btn-primary']) }} + {!! Form::close() !!} + + {{ Form::open(['action' => 'ContractController@deleteBid', 'method' => 'POST']) }} + {{ Form::hidden('id', $bid['id']) }} + {{ Form::hidden('contract_id', $bid['contract_id']) }} + {{ Form::submit('Delete Bid', ['class' => 'btn btn-primary']) }} + {!! Form::close() !!} + @endif + + @endforeach + +
CorporationAmount
{{ $bid['corporation_name'] }}{{ $bid['bid_amount'] }}
+ @else + No Bids have been entered. + @endif +
+
+
-
-
+
+@else
-
-
- Current Top Bid -
-
- Some corporation and the price +
+
+
+
+ No Contracts Issued +
+
+
+
+
-
+@endif @endsection \ No newline at end of file