Rename user_bids table to bids
This commit is contained in:
@@ -13,7 +13,7 @@ class CreateBidsTable extends Migration
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('user_bids', function (Blueprint $table) {
|
||||
Schema::create('bids', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->unsignedInteger('user_id');
|
||||
$table->string('flight_id', \App\Models\Flight::ID_MAX_LENGTH);
|
||||
@@ -31,6 +31,6 @@ class CreateBidsTable extends Migration
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('user_bids');
|
||||
Schema::dropIfExists('bids');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -313,7 +313,7 @@ flight_fields:
|
||||
name: cost index
|
||||
value: 100
|
||||
|
||||
user_bids:
|
||||
bids:
|
||||
- id: 100
|
||||
user_id: 1
|
||||
flight_id: flightid_1
|
||||
|
||||
@@ -177,16 +177,17 @@ class FlightController extends BaseController
|
||||
}
|
||||
|
||||
$time = new Time($flight->flight_time);
|
||||
|
||||
$flight->hours = $time->hours;
|
||||
$flight->minutes = $time->minutes;
|
||||
|
||||
$avail_subfleets = $this->getAvailSubfleets($flight);
|
||||
return view('admin.flights.edit', [
|
||||
'flight' => $flight,
|
||||
'airlines' => $this->airlineRepo->selectBoxList(),
|
||||
'airports' => $this->airportRepo->selectBoxList(),
|
||||
'alt_airports' => $this->airportRepo->selectBoxList(true),
|
||||
'avail_fares' => $this->getAvailFares($flight),
|
||||
'avail_subfleets' => $avail_subfleets,
|
||||
'avail_subfleets' => $this->getAvailSubfleets($flight),
|
||||
'flight_types' => FlightType::select(true),
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ use App\Http\Resources\Pirep as PirepResource;
|
||||
use App\Http\Resources\Subfleet as SubfleetResource;
|
||||
use App\Http\Resources\User as UserResource;
|
||||
use App\Models\Enums\PirepState;
|
||||
use App\Models\UserBid;
|
||||
use App\Models\Bid;
|
||||
use App\Repositories\Criteria\WhereCriteria;
|
||||
use App\Repositories\FlightRepository;
|
||||
use App\Repositories\PirepRepository;
|
||||
@@ -111,7 +111,7 @@ class UserController extends RestController
|
||||
|
||||
if ($request->isMethod('DELETE')) {
|
||||
if($request->filled('bid_id')) {
|
||||
$bid = UserBid::findOrFail($request->input('bid_id'));
|
||||
$bid = Bid::findOrFail($request->input('bid_id'));
|
||||
$flight_id = $bid->flight_id;
|
||||
} else {
|
||||
$flight_id = $request->input('flight_id');
|
||||
@@ -122,7 +122,7 @@ class UserController extends RestController
|
||||
}
|
||||
|
||||
# Return the flights they currently have bids on
|
||||
$bids = UserBid::where(['user_id' => $user->id])->get();
|
||||
$bids = Bid::where(['user_id' => $user->id])->get();
|
||||
return BidResource::collection($bids);
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
namespace App\Http\Controllers\Frontend;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\UserBid;
|
||||
use App\Models\Bid;
|
||||
use App\Repositories\AirlineRepository;
|
||||
use App\Repositories\AirportRepository;
|
||||
use App\Repositories\Criteria\WhereCriteria;
|
||||
@@ -65,7 +65,7 @@ class FlightController extends Controller
|
||||
|
||||
$flights = $this->flightRepo->paginate();
|
||||
|
||||
$saved_flights = UserBid::where('user_id', Auth::id())
|
||||
$saved_flights = Bid::where('user_id', Auth::id())
|
||||
->pluck('flight_id')->toArray();
|
||||
|
||||
return $this->view('flights.index', [
|
||||
@@ -86,7 +86,7 @@ class FlightController extends Controller
|
||||
{
|
||||
$flights = $this->flightRepo->searchCriteria($request)->paginate();
|
||||
|
||||
$saved_flights = UserBid::where('user_id', Auth::id())
|
||||
$saved_flights = Bid::where('user_id', Auth::id())
|
||||
->pluck('flight_id')->toArray();
|
||||
|
||||
return $this->view('flights.index', [
|
||||
|
||||
@@ -5,9 +5,9 @@ namespace App\Models;
|
||||
/**
|
||||
* @package App\Models
|
||||
*/
|
||||
class UserBid extends BaseModel
|
||||
class Bid extends BaseModel
|
||||
{
|
||||
public $table = 'user_bids';
|
||||
public $table = 'bids';
|
||||
|
||||
public $fillable = [
|
||||
'user_id',
|
||||
@@ -153,7 +153,7 @@ class User extends Authenticatable
|
||||
|
||||
public function bids()
|
||||
{
|
||||
return $this->hasMany(UserBid::class, 'user_id');
|
||||
return $this->hasMany(Bid::class, 'user_id');
|
||||
}
|
||||
|
||||
public function pireps()
|
||||
|
||||
@@ -6,7 +6,7 @@ use App\Exceptions\BidExists;
|
||||
use App\Models\Flight;
|
||||
use App\Models\Subfleet;
|
||||
use App\Models\User;
|
||||
use App\Models\UserBid;
|
||||
use App\Models\Bid;
|
||||
use App\Repositories\FlightRepository;
|
||||
use App\Repositories\NavdataRepository;
|
||||
use Log;
|
||||
@@ -102,7 +102,7 @@ class FlightService extends BaseService
|
||||
public function deleteFlight(Flight $flight)
|
||||
{
|
||||
$where = ['flight_id' => $flight->id];
|
||||
UserBid::where($where)->delete();
|
||||
Bid::where($where)->delete();
|
||||
$flight->delete();
|
||||
}
|
||||
|
||||
@@ -136,7 +136,7 @@ class FlightService extends BaseService
|
||||
* Allow a user to bid on a flight. Check settings and all that good stuff
|
||||
* @param Flight $flight
|
||||
* @param User $user
|
||||
* @return UserBid|null
|
||||
* @return Bid|null
|
||||
* @throws \App\Exceptions\BidExists
|
||||
*/
|
||||
public function addBid(Flight $flight, User $user)
|
||||
@@ -149,7 +149,7 @@ class FlightService extends BaseService
|
||||
|
||||
# See if we're allowed to have multiple bids or not
|
||||
if (!setting('bids.allow_multiple_bids')) {
|
||||
$user_bids = UserBid::where(['user_id' => $user->id])->first();
|
||||
$user_bids = Bid::where(['user_id' => $user->id])->first();
|
||||
if ($user_bids) {
|
||||
Log::info('User "' . $user->id . '" already has bids, skipping');
|
||||
throw new BidExists();
|
||||
@@ -162,12 +162,12 @@ class FlightService extends BaseService
|
||||
'flight_id' => $flight->id
|
||||
];
|
||||
|
||||
$user_bid = UserBid::where($bid_data)->first();
|
||||
$user_bid = Bid::where($bid_data)->first();
|
||||
if ($user_bid) {
|
||||
return $user_bid;
|
||||
}
|
||||
|
||||
$user_bid = UserBid::create($bid_data);
|
||||
$user_bid = Bid::create($bid_data);
|
||||
|
||||
$flight->has_bid = true;
|
||||
$flight->save();
|
||||
@@ -182,7 +182,7 @@ class FlightService extends BaseService
|
||||
*/
|
||||
public function removeBid(Flight $flight, User $user)
|
||||
{
|
||||
$user_bid = UserBid::where([
|
||||
$user_bid = Bid::where([
|
||||
'flight_id' => $flight->id, 'user_id' => $user->id
|
||||
])->first();
|
||||
|
||||
@@ -191,7 +191,7 @@ class FlightService extends BaseService
|
||||
}
|
||||
|
||||
# Only flip the flag if there are no bids left for this flight
|
||||
if (!UserBid::where('flight_id', $flight->id)->exists()) {
|
||||
if (!Bid::where('flight_id', $flight->id)->exists()) {
|
||||
$flight->has_bid = false;
|
||||
$flight->save();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user