Fix up the PIREP field CRUD code

This commit is contained in:
Nabeel Shahzad 2017-12-31 20:59:26 -06:00
parent 11c724649c
commit 6406f47aaa
18 changed files with 101 additions and 123 deletions

View File

@ -84,7 +84,6 @@ class CreatePirepTables extends Migration
$table->bigIncrements('id');
$table->string('name', 50);
$table->boolean('required')->default(false);
$table->timestamps();
});
Schema::create('pirep_field_values', function (Blueprint $table) {

View File

@ -107,11 +107,6 @@ class PirepFieldController extends BaseController
/**
* Update the specified PirepField in storage.
*
* @param int $id
* @param UpdatePirepFieldRequest $request
*
* @return Response
*/
public function update($id, UpdatePirepFieldRequest $request)
{

View File

@ -10,31 +10,19 @@ namespace App\Models;
class PirepField extends BaseModel
{
public $table = 'pirep_fields';
public $timestamps = false;
public $fillable
= [
'name',
'required',
];
public $fillable = [
'name',
'required',
];
/**
* The attributes that should be casted to native types.
*
* @var array
*/
protected $casts
= [
'name' => 'string',
'required' => 'integer',
];
protected $casts = [
'name' => 'string',
'required' => 'boolean',
];
/**
* Validation rules
*
* @var array
*/
public static $rules
= [
'name' => 'required',
];
public static $rules = [
'name' => 'required',
];
}

View File

@ -17,7 +17,7 @@
<td>{!! $airport->name !!}</td>
<td>{!! $airport->location !!}</td>
<td style="text-align: center;">
@if($airport->hub == 1)
@if($airport->hub === true)
<span class="label label-success">Hub</span>
@endif
</td>

View File

@ -1,19 +0,0 @@
@extends('admin.app')
@section('content')
<section class="content-header">
<h1>Edit "{!! $field->name !!}"</h1>
</section>
<div class="content">
@include('admin.flash.message')
<div class="box box-primary">
<div class="box-body">
<div class="row">
{!! Form::model($field, ['route' => ['admin.pirepfields.update', $field->id], 'method' => 'patch']) !!}
@include('admin.pirep_fields.fields')
{!! Form::close() !!}
</div>
</div>
</div>
</div>
@endsection

View File

@ -1,17 +0,0 @@
<!-- Name Field -->
<div class="form-group col-sm-6">
{!! Form::label('name', 'Name:') !!}
{!! Form::text('name', null, ['class' => 'form-control']) !!}
</div>
<!-- Required Field -->
<div class="form-group col-sm-6">
{!! Form::label('required', 'Required:') !!}
{!! Form::text('required', null, ['class' => 'form-control']) !!}
</div>
<!-- Submit Field -->
<div class="form-group col-sm-12">
{!! Form::submit('Save', ['class' => 'btn btn-primary']) !!}
<a href="{!! route('admin.pirepfields.index') !!}" class="btn btn-default">Cancel</a>
</div>

View File

@ -1,23 +0,0 @@
@extends('admin.app')
@section('content')
<section class="content-header">
<h1 class="pull-left">PIREP Fields</h1>
<h1 class="pull-right">
<a class="btn btn-primary pull-right" style="margin-top: -10px;margin-bottom: 5px" href="{!! route('admin.pirepfields.create') !!}">Add New</a>
</h1>
</section>
<div class="content">
<div class="clearfix"></div>
@include('flash::message')
<div class="clearfix"></div>
<div class="box box-primary">
<div class="box-body">
@include('admin.pirep_fields.table')
</div>
</div>
</div>
@endsection

View File

@ -1,24 +0,0 @@
<table class="table table-hover table-responsive" id="pirepFields-table">
<thead>
<th>Name</th>
<th>Required</th>
<th></th>
</thead>
<tbody>
@foreach($fields as $field)
<tr>
<td>{!! $field->name !!}</td>
<td>{!! $field->required !!}</td>
<td>
{!! Form::open(['route' => ['admin.pirepfields.destroy', $field->id], 'method' => 'delete']) !!}
<div class='btn-group'>
{{--<a href="{!! route('admin.pirepfields.show', [$field->id]) !!}" class='btn btn-default btn-xs'><i class="glyphicon glyphicon-eye-open"></i></a>
<a href="{!! route('admin.pirepfields.edit', [$field->id]) !!}" class='btn btn-default btn-xs'><i class="glyphicon glyphicon-edit"></i></a>--}}
{!! Form::button('<i class="glyphicon glyphicon-trash"></i>', ['type' => 'submit', 'class' => 'btn btn-danger btn-xs', 'onclick' => "return confirm('Are you sure?')"]) !!}
</div>
{!! Form::close() !!}
</td>
</tr>
@endforeach
</tbody>
</table>

View File

@ -1,11 +1,11 @@
@extends('admin.app')
@section('title', 'Add PIREP Field')
@section('title', 'Adding Field')
@section('content')
<div class="card border-blue-bottom">
<div class="content">
@include('admin.flash.message')
{!! Form::open(['route' => 'admin.pirepfields.store']) !!}
@include('admin.pirep_fields.fields')
@include('admin.pirepfields.fields')
{!! Form::close() !!}
</div>
</div>

View File

@ -0,0 +1,12 @@
@extends('admin.app')
@section('title', 'Editing ' . $field->name)
@section('content')
<div class="card border-blue-bottom">
<div class="content">
@include('admin.flash.message')
{!! Form::model($field, ['route' => ['admin.pirepfields.update', $field->id], 'method' => 'patch']) !!}
@include('admin.pirepfields.fields')
{!! Form::close() !!}
</div>
</div>
@endsection

View File

@ -0,0 +1,20 @@
<div class="row">
<div class="form-group col-sm-6">
{!! Form::label('name', 'Name:') !!}&nbsp;&nbsp;<span class="required">*</span>
{!! Form::text('name', null, ['class' => 'form-control']) !!}
</div>
<!-- Required Field -->
<div class="form-group col-sm-6">
{!! Form::label('required', 'Required:') !!}
{!! Form::hidden('required', 0) !!}
{!! Form::checkbox('required', null) !!}
</div>
</div>
<div class="row">
<!-- Submit Field -->
<div class="form-group col-sm-12">
{!! Form::submit('Save', ['class' => 'btn btn-primary']) !!}
<a href="{!! route('admin.pirepfields.index') !!}" class="btn btn-default">Cancel</a>
</div>
</div>

View File

@ -0,0 +1,15 @@
@extends('admin.app')
@section('title', 'PIREP Fields')
@section('actions')
<li><a href="{!! route('admin.pirepfields.create') !!}"><i class="ti-plus"></i>Add
Field</a></li>
@endsection
@section('content')
<div class="card border-blue-bottom">
<div class="content">
@include('admin.flash.message')
@include('admin.pirepfields.table')
</div>
</div>
@endsection

View File

@ -8,7 +8,7 @@
<div class="box box-primary">
<div class="box-body">
<div class="row" style="padding-left: 20px">
@include('admin.pirep_fields.show_fields')
@include('admin.pirepfields.show_fields')
<a href="{!! route('admin.pirepfields.index') !!}" class="btn btn-default">Back</a>
</div>
</div>

View File

@ -0,0 +1,31 @@
<div class="content table-responsive table-full-width">
<table class="table table-hover table-responsive" id="pirepFields-table">
<thead>
<th>Name</th>
<th>Required</th>
<th></th>
</thead>
<tbody>
@foreach($fields as $field)
<tr>
<td>{!! $field->name !!}</td>
<td style="text-align: center;">
@if($field->required === true)
<span class="label label-success">Hub</span>
@endif
</td>
<td class="text-right">
{!! Form::open(['route' => ['admin.pirepfields.destroy', $field->id], 'method' => 'delete']) !!}
<a href="{!! route('admin.pirepfields.edit', [$field->id]) !!}"
class='btn btn-sm btn-success btn-icon'>
<i class="fa fa-pencil-square-o"></i></a>
{!! Form::button('<i class="fa fa-times"></i>',
['type' => 'submit', 'class' => 'btn btn-sm btn-danger btn-icon',
'onclick' => "return confirm('Are you sure?')"]) !!}
{!! Form::close() !!}
</td>
</tr>
@endforeach
</tbody>
</table>

View File

@ -2,12 +2,12 @@
@section('title', 'Pilot Reports')
@section('actions')
<li><a href="{!! route('admin.pirepfields.index') !!}"><i class="ti-menu-alt"></i>PIREP Fields</a></li>
<li><a href="{!! route('admin.pireps.index') !!}?search=status:0"><i class="ti-plus"></i>Pending</a></li>
<li><a href="{!! route('admin.pireps.index') !!}"><i class="ti-plus"></i>View All</a></li>
@endsection
@section('content')
@include('admin.pireps.table')
<div class="row">
<div class="col-12 text-center">
{{ $pireps->links('admin.pagination.default') }}

View File

@ -8,8 +8,10 @@
</li>
@endsection
@section('content')
<div class="card">
@include('flash::message')
@include('admin.subfleets.table')
<div class="card border-blue-bottom">
<div class="content">
@include('admin.flash.message')
@include('admin.subfleets.table')
</div>
</div>
@endsection

View File

@ -87,8 +87,7 @@
<i class="now-ui-icons users_single-02"></i>
</span>-->
{!! Form::text('field_'.$field->id, null, [
'class' => 'form-control',
'required' => $field->required,
'class' => 'form-control'
]) !!}
</div>
</td>