-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Update console.php * Fix the previous data saving implementation * Fix planet histories table * Add campaigns and endpoints Added campaign tracking with endpoints and a new endpoint for retrieving planets with active campaigns.
- Loading branch information
Showing
10 changed files
with
204 additions
and
7 deletions.
There are no files selected for viewing
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,36 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers; | ||
|
||
use App\Models\PlanetCampaign; | ||
use Illuminate\Http\Request; | ||
|
||
class PlanetCampaignController extends Controller | ||
{ | ||
public function active(Request $request) { | ||
|
||
$campaigns = PlanetCampaign::where('ended_at', null)->get(); | ||
|
||
return response()->json($campaigns, 200); | ||
|
||
} | ||
|
||
public function index(Request $request) { | ||
|
||
$request->validate([ | ||
'id' => ['integer', 'nullable'] | ||
]); | ||
|
||
$campaignQuery = PlanetCampaign::query(); | ||
|
||
if ($request->has('id')) { | ||
$id = $request->input('id'); | ||
$campaignQuery->where('id', $id); | ||
} | ||
|
||
$campaigns = $campaignQuery->limit(100)->get(); | ||
|
||
return response()->json($campaigns, 200); | ||
|
||
} | ||
} |
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,32 @@ | ||
<?php | ||
|
||
namespace App\Models; | ||
|
||
use Illuminate\Database\Eloquent\Factories\HasFactory; | ||
use Illuminate\Database\Eloquent\Model; | ||
|
||
class PlanetCampaign extends Model | ||
{ | ||
use HasFactory; | ||
|
||
protected $table = 'planet_campaigns'; | ||
|
||
protected $increments = false; | ||
|
||
protected $fillable = [ | ||
'id', | ||
'planetIndex', | ||
'type', | ||
'count', | ||
'warId', | ||
'ended_at' | ||
]; | ||
|
||
protected $hidden = [ | ||
'updated_at' | ||
]; | ||
|
||
public function planet() { | ||
return $this->belongsTo(Planet::class, 'planetIndex', 'index'); | ||
} | ||
} |
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
32 changes: 32 additions & 0 deletions
32
database/migrations/2024_04_04_213034_create_planet_campaigns_table.php
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,32 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Support\Facades\Schema; | ||
|
||
return new class extends Migration | ||
{ | ||
/** | ||
* Run the migrations. | ||
*/ | ||
public function up(): void | ||
{ | ||
Schema::create('planet_campaigns', function (Blueprint $table) { | ||
$table->unsignedBigInteger('id')->nullable()->primary(); | ||
$table->unsignedBigInteger('planetIndex'); | ||
$table->unsignedInteger('type'); | ||
$table->unsignedInteger('count'); | ||
$table->unsignedBigInteger('warId'); | ||
$table->timestamp('ended_at')->nullable()->default(null); | ||
$table->timestamps(); | ||
}); | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
*/ | ||
public function down(): void | ||
{ | ||
Schema::dropIfExists('planet_campaigns'); | ||
} | ||
}; |
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 @@ | ||
Not a route |
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