Adding Ship Class column
This commit is contained in:
parent
589bf47eff
commit
0145a8073a
@ -25,6 +25,8 @@ class ShipsController extends Controller
|
||||
|
||||
public function add(Request $request){
|
||||
|
||||
$eliteShips = DB::table('elite_ships');
|
||||
|
||||
if($request->input('addShip')) {
|
||||
try {
|
||||
$ship = new Ships;
|
||||
@ -33,6 +35,8 @@ class ShipsController extends Controller
|
||||
$ship->shipName = request('shipName');
|
||||
$ship->shipOwner = request('shipOwner');
|
||||
$ship->shipType = request('shipType');
|
||||
// $ship->shipClass = $eliteShips->where('shipName', request('shipType'));
|
||||
$ship->shipClass = $eliteShips->where('shipName', request('shipType'))->value('shipClass');
|
||||
$ship->created_at = now();
|
||||
$ship->save();
|
||||
}catch(\Exception $e){
|
||||
@ -64,7 +68,9 @@ class ShipsController extends Controller
|
||||
'shipId' => strtoupper(request('shipId')),
|
||||
'shipName' => request('shipName'),
|
||||
'shipOwner' => request('shipOwner'),
|
||||
'shipType' => request('shipType')
|
||||
'shipType' => request('shipType'),
|
||||
// 'shipClass' => $eliteShips->where('shipName', request('shipType')),
|
||||
'shipClass' => $eliteShips->where('shipName', request('shipType'))->value('shipClass'),
|
||||
));
|
||||
}catch(\Exception $e){
|
||||
Log::error($e);
|
||||
|
@ -10,6 +10,6 @@ use Kyslik\ColumnSortable\Sortable;
|
||||
class Ships extends Model
|
||||
{
|
||||
use Sortable;
|
||||
public $sortable = ['shipId', 'shipName', 'shipOwner', 'shipType'];
|
||||
public $sortable = ['shipId', 'shipName', 'shipOwner', 'shipType', 'shipClass'];
|
||||
protected $casts = ['id' => 'string'];
|
||||
}
|
||||
|
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AddShipClassToShips extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('ships', function (Blueprint $table) {
|
||||
$table->string('shipClass')->nullable(true);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('ships', function (Blueprint $table) {
|
||||
$table->dropColumn('shipClass');
|
||||
});
|
||||
}
|
||||
}
|
@ -60,6 +60,7 @@
|
||||
<th scope="col">@sortablelink('shipName', 'Ship Name')</th>
|
||||
<th scope="col">@sortablelink('shipType', 'Ship Type')</th>
|
||||
<th scope="col">@sortablelink('shipOwner', 'Ship Owner')</th>
|
||||
<th scope="col">@sortablelink('shipClass', 'Ship Class')</th>
|
||||
<th scope="col">Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
@ -70,6 +71,7 @@
|
||||
<td>{{ $ship->shipName }}</td>
|
||||
<td>{{ $ship->shipType }}</td>
|
||||
<td>{{ $ship->shipOwner }}</td>
|
||||
<td>{{ $ship->shipClass }}</td>
|
||||
<td>
|
||||
<button type="button" class="btn bi bi-wrench" data-target="#editShip-{{ $ship->id }}" data-toggle="modal"><x-bi-tools/></button>
|
||||
<button type="button" class="btn" data-target="#deleteShip-{{ $ship->id }}" data-toggle="modal"><x-bi-trash/></button>
|
||||
|
Loading…
Reference in New Issue
Block a user