model changes for accepted bids and contracts
This commit is contained in:
@@ -28,12 +28,12 @@ class ContractAdminController extends Controller
|
||||
|
||||
$contracts = Contract::where(['date', '>=', $today])->get();
|
||||
|
||||
return view('contracts/admin/contractpanel');
|
||||
return view('contracts.admin.contractpanel');
|
||||
}
|
||||
|
||||
public function displayNewContract() {
|
||||
|
||||
return view('contracts/admin/newcontract');
|
||||
return view('contracts.admin.newcontract');
|
||||
}
|
||||
|
||||
public function storeNewContract() {
|
||||
@@ -42,6 +42,11 @@ class ContractAdminController extends Controller
|
||||
}
|
||||
|
||||
public function storeAcceptContract(Request $request) {
|
||||
$this->validate($request, [
|
||||
'contract_id',
|
||||
'character_id',
|
||||
'bid_amount',
|
||||
]);
|
||||
|
||||
return redirect('/contracts/admin/display');
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ use Illuminate\Database\Eloquent\Model;
|
||||
class AcceptedBid extends Model
|
||||
{
|
||||
// Table Name
|
||||
public $table = 'accepted_bid';
|
||||
public $table = 'accepted_bids';
|
||||
|
||||
//Timestamps
|
||||
public $timestamps = true;
|
||||
@@ -20,6 +20,10 @@ class AcceptedBid extends Model
|
||||
protected $fillable = [
|
||||
'contract_id',
|
||||
'bid_id',
|
||||
'amount',
|
||||
'bid_amount',
|
||||
];
|
||||
|
||||
public function Contract() {
|
||||
return $this->belongsTo(Contract::class);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,9 +23,13 @@ class Contract extends Model
|
||||
'body',
|
||||
];
|
||||
|
||||
protected $guarded = [];
|
||||
|
||||
//One-to-Many relationship for the bids on a contract
|
||||
public function Bids() {
|
||||
return $this->hasMany('App\Models\Contracts\Bid', 'contract_id', 'id');
|
||||
}
|
||||
|
||||
//One-to-One relationship for the accepted bid.
|
||||
public function AcceptedBid() {
|
||||
return $this->hasOne('App\Models\Contracts\AcceptedBid', 'contract_id', 'id');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,12 +36,12 @@ class CreateContractsTable extends Migration
|
||||
});
|
||||
}
|
||||
|
||||
if(!Schema::hasTable('accepted_bid')) {
|
||||
Schema::create('accepted_bid', function(Blueprint $table) {
|
||||
if(!Schema::hasTable('accepted_bids')) {
|
||||
Schema::create('accepted_bids', function(Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('contract_id');
|
||||
$table->integer('bid_id');
|
||||
$table->decimal('amount');
|
||||
$table->decimal('bid_amount');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
@@ -56,6 +56,6 @@ class CreateContractsTable extends Migration
|
||||
{
|
||||
Schema::dropIfExists('contracts');
|
||||
Schema::dropIfExists('contract_bids');
|
||||
Schema::dropIfExists('contract_bid_accepted');
|
||||
Schema::dropIfExists('accepted_bids');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user