Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
27 changed files
with
470 additions
and
166 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers\Api; | ||
|
||
use Illuminate\Http\Request; | ||
|
||
use App\Http\Controllers\AppBaseController; | ||
use App\Repositories\UserRepository; | ||
|
||
use App\Models\UserBid; | ||
|
||
use App\Http\Resources\Flight as FlightResource; | ||
use App\Http\Resources\User as UserResource; | ||
use App\Http\Resources\UserBid as UserBidResource; | ||
|
||
|
||
class UserController extends AppBaseController | ||
{ | ||
protected $userRepo; | ||
|
||
public function __construct(UserRepository $userRepo) | ||
{ | ||
$this->userRepo = $userRepo; | ||
} | ||
|
||
/** | ||
* Return the profile for the currently auth'd user | ||
*/ | ||
public function index(Request $request) | ||
{ | ||
UserResource::withoutWrapping(); | ||
return new UserResource($request->user); | ||
} | ||
|
||
/** | ||
* Get the profile for the passed-in user | ||
*/ | ||
public function get($id) | ||
{ | ||
UserResource::withoutWrapping(); | ||
return new UserResource($this->userRepo->find($id)); | ||
} | ||
|
||
/** | ||
* Return all of the bids for the passed-in user | ||
*/ | ||
public function bids($id) | ||
{ | ||
$flights = UserBid::where(['user_id' => $id])->get() | ||
->pluck('flight'); | ||
|
||
return FlightResource::collection($flights); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
namespace App\Http\Resources; | ||
|
||
use Illuminate\Http\Resources\Json\Resource; | ||
|
||
class Aircraft extends Resource | ||
{ | ||
public function toArray($request) | ||
{ | ||
return parent::toArray($request); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
namespace App\Http\Resources; | ||
|
||
use Illuminate\Http\Resources\Json\Resource; | ||
|
||
class Airline extends Resource | ||
{ | ||
public function toArray($request) | ||
{ | ||
return [ | ||
'id' => $this->id, | ||
'icao' => $this->icao, | ||
'iata' => $this->iata, | ||
'name' => $this->name, | ||
'country' => $this->country, | ||
'logo' => $this->logo, | ||
#'active' => $this->active, | ||
#'created_at' => $this->created_at, | ||
#'updated_at' => $this->updated_at, | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
namespace App\Http\Resources; | ||
|
||
use Illuminate\Http\Resources\Json\Resource; | ||
|
||
class Rank extends Resource | ||
{ | ||
/** | ||
* Transform the resource into an array. | ||
* | ||
* @param \Illuminate\Http\Request $request | ||
* @return array | ||
*/ | ||
public function toArray($request) | ||
{ | ||
return [ | ||
'name' => $this->name, | ||
#'auto_approve_acars' => $this->auto_approve_acars, | ||
#'auto_approve_manual' => $this->auto_approve_manual, | ||
#'auto_promote' => $this->auto_promote, | ||
#'created_at' => $this->created_at, | ||
#'updated_at' => $this->updated_at, | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
namespace App\Http\Resources; | ||
|
||
use Illuminate\Http\Resources\Json\Resource; | ||
|
||
class Subfleet extends Resource | ||
{ | ||
public function toArray($request) | ||
{ | ||
return [ | ||
'id' => $this->id, | ||
'airline_id' => $this->airline_id, | ||
'name' => $this->name, | ||
'type' => $this->type, | ||
'fuel_type' => $this->fuel_type, | ||
'cargo_capacity' => $this->cargo_capacity, | ||
'fuel_capacity' => $this->fuel_capacity, | ||
'gross_weight' => $this->gross_weight, | ||
|
||
'aircraft' => Aircraft::collection($this->aircraft), | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
namespace App\Http\Resources; | ||
|
||
use Illuminate\Http\Resources\Json\Resource; | ||
|
||
class User extends Resource | ||
{ | ||
public function toArray($request) | ||
{ | ||
return [ | ||
'id' => $this->id, | ||
'name' => $this->name, | ||
'email' => $this->email, | ||
'apikey' => $this->apikey, | ||
'rank_id' => $this->rank_id, | ||
'home_airport' => $this->home_airport_id, | ||
'curr_airport' => $this->curr_airport_id, | ||
'last_pirep_id' => $this->last_pirep_id, | ||
'flights' => $this->flight, | ||
'flight_time' => $this->flight_time, | ||
'balance' => $this->balance, | ||
'timezone' => $this->timezone, | ||
'active' => $this->active, | ||
|
||
'airline' => Airline::make($this->airline), | ||
'bids' => UserBid::collection($this->bids), | ||
'rank' => Rank::make($this->rank), | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
namespace App\Http\Resources; | ||
|
||
use Illuminate\Http\Resources\Json\Resource; | ||
|
||
class UserBid extends Resource | ||
{ | ||
public function toArray($request) | ||
{ | ||
return [ | ||
'id' => $this->id, | ||
'user_id' => $this->user_id, | ||
'flight_id' => $this->flight_id, | ||
'flight' => Flight::collection($this->whenLoaded('flight')) | ||
#'created_at' => $this->created_at, | ||
#'updated_at' => $this->updated_at, | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.