Skip to content

Commit

Permalink
WIP show ticket
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam Crampton committed Feb 26, 2015
1 parent 17c4d8c commit 8d3a912
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 6 deletions.
17 changes: 14 additions & 3 deletions app/controllers/TicketsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,26 @@ public function index()
{
$all_tickets = $this->tickets->all();

return View::make('tickets.index')->with(array('all_tickets' => $all_tickets));
return View::make('tickets.index', ['all_tickets' => $all_tickets]);
}

public function create($create_type = null)
{

}

public function show($ticket_id = 0)
public function show($ticket_id = null)
{

if ($ticket_id !== null)
{
// Create ticket object
$ticket = $this->tickets->whereMaster_id($ticket_id)->first();

return View::make('tickets.show', ['ticket' => $ticket]);
}

return Redirect::to('/')->with('no_ticket', 'Sorry, this ticket does not exist. Please contact support.');

}

public function store()
Expand All @@ -42,6 +51,8 @@ public function destroy()
{
if (Input::has('delete'))
{
#!# Add in delete method

return Redirect::back()->with('deleted', 'Records were deleted');
}

Expand Down
3 changes: 1 addition & 2 deletions app/models/Ticket.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@
protected $table = 'master';
protected $primaryKey = 'master_id';

// DB Relationships
public function belongs()
{
// return User::where('users_id', $this->master_belongs_to_users_fk)->first()->users_username;

return $this->belongsTo('User', 'master_belongs_to_users_fk', 'users_id');
}

Expand Down
2 changes: 1 addition & 1 deletion app/views/tickets/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<tr>
<td>{{ $ticket->master_id }}</td>
<td>{{ $ticket->belongs->users_username }}</td>
<td>{{ $ticket->master_description }}</td>
<td>{{ link_to("/tickets/{$ticket->master_id}", $ticket->master_description) }}</td>
<td>{{ $ticket->category->categories_name }}</td>
<td>{{ $ticket->priority->priorities_name }}</td>
<td>{{ $ticket->assigned->users_username }}</td>
Expand Down
54 changes: 54 additions & 0 deletions app/views/tickets/show.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
@extends('layouts/default')

@section('content')

<div class="col-md-12">
<div class="row">
<p class="lead">This ticket:</p>
</div>

<div class="row">

{{ Form::open(['method' => 'put', 'route' => 'tickets.update', 'files' => true]) }}

{{ Form::hidden('id', $ticket->master_id) }}
<div class="col-md-6">
<div class="form-group">
{{ Form::label('submitted_by', 'Submitted By: ') }}
{{ Form::select('submitted_by', User::lists('users_username', 'users_id'), null, ['class' => 'form-control']) }}
{{ $errors->first('submitted_by', '<span class="label label-danger">:message</span>') }}
</div>
</div>
<div class="col-md-6 ">
<div id="content_doc_container" class="form-group has-feedback">
{{ Form::label('content_doc', 'Upload and insert document (max 8mb): ', array('class' => 'control-label')) }}
{{ Form::file('content_doc', array('class' => 'form-control')) }}
<span id="content_doc_glyph" class="glyphicon glyphicon-ok form-control-feedback hide" aria-hidden="true"></span>
<span id="ajax-error-doc"></span>
</div>
<div id="content_image_container" class="form-group has-feedback">
{{ Form::label('content_image', 'Upload and insert image: (max 8mb)', array('class' => 'control-label')) }}
{{ Form::file('content_image', array('class' => 'form-control')) }}
<span id="content_image_glyph" class="glyphicon glyphicon-ok form-control-feedback hide" aria-hidden="true"></span>
<span id="ajax-error-content"></span>
</div>
</div>
<div class="col-md-12">
<hr />
<div class="form-group">
{{ Form::label('description', 'Description: ') }} {{ $errors->first('description', '<span class="label label-danger">:message</span>') }}
{{ Form::textarea('description', $ticket->master_description, array('id' => 'content_editor', 'class' => 'form-control')) }}
</div>
<div class="form-group">
{{ Form::submit('Update', array('class' => 'btn btn-success')) }}
</div>
</div>
{{ Form::close() }}

</div>

</div>

<hr />

@stop

0 comments on commit 8d3a912

Please sign in to comment.