Created
January 14, 2015 02:23
-
-
Save dugjohnson/0d7984935dc0d309f8c0 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
//Code in EntryController | |
public function addEntry(Request $request) | |
{ | |
$id = Auth::user()->id; | |
// redirect | |
$entry = new Entry(); | |
$entry->published = $request->published; | |
$entry->user_id = $id; | |
$entry->author = $request->author; | |
$entry->title = $request->title; | |
$entry->category = $request->category; | |
$entry->signed = $request->signed; | |
//$entry->dateOfEntry = $request->dateOfEntry; | |
if ($request->published == false) { | |
//deal with upload | |
// $entry->filename = $request->filename; | |
$entry->filename = 'Deal with upload'; | |
} else { | |
$entry->publisher = $request->publisher; | |
$entry->editor = $request->editor; | |
$entry->publicationMonth = $request->publicationMonth; | |
} | |
$entry->save(); | |
Session::flash('message', 'Successfully added Entry!'); | |
return redirect('/entries/'.$id); | |
} | |
/** | |
* Store a newly created resource in storage. | |
* | |
* @return Response | |
*/ | |
public function storePub(Requests\CreatePublishedEntryRequest $request) | |
{ | |
$this->addEntry($request) | |
} | |
/** | |
* Store a newly created resource in storage. | |
* | |
* @return Response | |
*/ | |
public function storeUnpub(Requests\CreateUnpublishedEntryRequest $request) | |
{ | |
$this->addEntry($request); | |
} | |
//Code in blade form | |
@extends('layout-nonav') | |
@section('content') | |
@if ($errors->any()) | |
<ul> | |
@foreach($errors->all() as $error) | |
<li>{!! $error !!}</li> | |
@endforeach | |
</ul> | |
@endif | |
{!! Form::open(array('url' => 'entries/storepub','method' => 'POST')) !!} | |
{!! Form::hidden('published',true) !!} | |
<!-- Author Name Form Input --> | |
<div class="form-group"> | |
{!! Form::label('author', 'Author Name:') !!} | |
{!! Form::text('author',null, ['class' => 'form-control']) !!} | |
</div> | |
<!-- Title Form Input --> | |
<div class="form-group"> | |
{!! Form::label('title', 'Title:') !!} | |
{!! Form::text('title',null, ['class' => 'form-control']) !!} | |
</div> | |
<!-- Category Form Input --> | |
<div class="form-group"> | |
{!! Form::label('category', 'Category:') !!} | |
{!! Form::select('category', $categories , null , ['class' => 'form-control']) !!} | |
</div> | |
<!-- Publisher Form Input --> | |
<div class="form-group"> | |
{!! Form::label('publisher', 'Publisher:') !!} | |
{!! Form::text('publisher',null, ['class' => 'form-control']) !!} | |
</div> | |
<!-- Editor Form Input --> | |
<div class="form-group"> | |
{!! Form::label('editor', 'Editor:') !!} | |
{!! Form::text('editor',null, ['class' => 'form-control']) !!} | |
</div> | |
<!-- Publication Month Form Input --> | |
<div class="form-group"> | |
{!! Form::label('publicationMonth', 'Publication or Release Month (see rules):') !!} | |
{!! Form::select('publicationMonth',$monthlist,null, ['class' => 'form-control']) !!} | |
</div> | |
<!-- Signed Form Input --> | |
<div class="form-group"> | |
{!! Form::label('signed', 'Signed (type your name):') !!} | |
{!! Form::text('signed',null, ['class' => 'form-control']) !!} | |
</div> | |
<!-- Invoice Number Form Input --> | |
<div class="form-group"> | |
{!! Form::label('invoiceNumber', 'Invoice Number:') !!} | |
{!! Form::text('invoiceNumber',null, ['class' => 'form-control']) !!} | |
</div> | |
{!! Form::submit('Submit!') !!} | |
{!! Form::close() !!} | |
@stop | |
// routes file | |
Route::get('/', 'WelcomeController@index'); | |
Route::get('home', 'HomeController@index'); | |
Route::get('entries/create/pub','EntryController@createPub'); | |
Route::get('entries/create/unpub','EntryController@createUnpub'); | |
Route::post('entries/storepub','EntryController@storePub'); | |
Route::post('entries/storeunpub','EntryController@storeUnpub'); | |
Route::resource('judges','JudgeController'); | |
Route::resource('entries','EntryController'); | |
Route::resource('users','UserController'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment