diff --git a/app/config/app.php b/app/config/app.php index 349cee5..aa5a934 100644 --- a/app/config/app.php +++ b/app/config/app.php @@ -13,7 +13,7 @@ return array( | */ - 'debug' => false, + 'debug' => true, /* |-------------------------------------------------------------------------- diff --git a/app/controllers/MentorController.php b/app/controllers/MentorController.php new file mode 100644 index 0000000..25fd1ed --- /dev/null +++ b/app/controllers/MentorController.php @@ -0,0 +1,153 @@ +with('mentors', $mentors); + } + + + /** + * Show the form for creating a new resource. + * + * @return Response + */ + public function create() + { + return \View::make('mentors.create'); + } + + + /** + * Store a newly created resource in storage. + * + * @return Response + */ + public function store() + { + $rules = array( + 'name' => 'required', + 'email' => 'required|email', + 'title' => 'required' + ); + $validator = Validator::make(Input::all(), $rules); + + // process the login + if ($validator->fails()) { + return Redirect::to('mentors/create') + ->withErrors($validator) + ->withInput(Input::except('password')); + } else { + // store + $nerd = new Mentor; + $nerd->name = Input::get('name'); + $nerd->email = Input::get('email'); + $nerd->title = Input::get('title'); + $nerd->save(); + + // redirect + Session::flash('message', 'Successfully created nerd!'); + return Redirect::to('mentors'); + } + } + + + /** + * Display the specified resource. + * + * @param int $id + * @return Response + */ + public function show($id) + { + // get the nerd + $mentor = Mentor::find($id); + + // show the view and pass the nerd to it + return View::make('mentors.show') + ->with('mentor', $mentor); + } + + + /** + * Show the form for editing the specified resource. + * + * @param int $id + * @return Response + */ + public function edit($id) + { + // get the nerd + $mentor = Mentor::find($id); + + // show the edit form and pass the nerd + return View::make('mentors.edit') + ->with('mentor', $mentor); + } + + + /** + * Update the specified resource in storage. + * + * @param int $id + * @return Response + */ + public function update($id) + { + // validate + // read more on validation at http://laravel.com/docs/validation + $rules = array( + 'name' => 'required', + 'email' => 'required|email', + 'title' => 'required' + ); + $validator = Validator::make(Input::all(), $rules); + + // process the login + if ($validator->fails()) { + return Redirect::to('mentors/' . $id . '/edit') + ->withErrors($validator) + ->withInput(Input::except('password')); + } else { + // store + $mentor = Mentor::find($id); + $mentor->name = Input::get('name'); + $mentor->email = Input::get('email'); + $mentor->title = Input::get('title'); + $mentor->save(); + + // redirect + Session::flash('message', 'Successfully updated mentor!'); + return Redirect::to('mentors'); + } + } + + + /** + * Remove the specified resource from storage. + * + * @param int $id + * @return Response + */ + public function destroy($id) + { + // delete + $mentor = Mentor::find($id); + $mentor->delete(); + + // redirect + Session::flash('message', 'Successfully deleted the mentor!'); + return Redirect::to('mentors'); + } + + +} diff --git a/app/database/migrations/2014_06_04_041712_create_mentors_table.php b/app/database/migrations/2014_06_04_041712_create_mentors_table.php new file mode 100644 index 0000000..454d68b --- /dev/null +++ b/app/database/migrations/2014_06_04_041712_create_mentors_table.php @@ -0,0 +1,35 @@ +increments('id'); + $table->string('name', 100); + $table->string('email', 100); + $table->string('title', 100); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('mentors'); + } + +} diff --git a/app/models/Mentor.php b/app/models/Mentor.php new file mode 100644 index 0000000..d62cdbc --- /dev/null +++ b/app/models/Mentor.php @@ -0,0 +1,4 @@ +
Laravel PHP Framework -

You have arrived.

+

You have arrived. This is all you need to succeed.

diff --git a/app/views/mentors/create.blade.php b/app/views/mentors/create.blade.php new file mode 100644 index 0000000..39346a0 --- /dev/null +++ b/app/views/mentors/create.blade.php @@ -0,0 +1,48 @@ + + + + Look! I'm CRUDding + + + +
+ + + +

Create a Nerd

+ + +{{ HTML::ul($errors->all()) }} + +{{ Form::open(array('url' => 'mentors')) }} + +
+ {{ Form::label('name', 'Name') }} + {{ Form::text('name', Input::old('name'), array('class' => 'form-control')) }} +
+ +
+ {{ Form::label('email', 'Email') }} + {{ Form::email('email', Input::old('email'), array('class' => 'form-control')) }} +
+ +
+ {{ Form::label('title', 'Mentor Title') }} + {{ Form::select('title', array('0' => 'Select a title', '1' => 'Mentor', '2' => 'Mentee', '3' => 'Both'), Input::old('title'), array('class' => 'form-control')) }} +
+ + {{ Form::submit('Create the mentor!', array('class' => 'btn btn-primary')) }} + +{{ Form::close() }} + +
+ + \ No newline at end of file diff --git a/app/views/mentors/edit.blade.php b/app/views/mentors/edit.blade.php new file mode 100644 index 0000000..63844e0 --- /dev/null +++ b/app/views/mentors/edit.blade.php @@ -0,0 +1,49 @@ + + + + + Look! I'm CRUDding + + + +
+ + + +

Edit {{ $mentor->name }}

+ + +{{ HTML::ul($errors->all()) }} + +{{ Form::model($mentor, array('route' => array('mentors.update', $mentor->id), 'method' => 'PUT')) }} + +
+ {{ Form::label('name', 'Name') }} + {{ Form::text('name', null, array('class' => 'form-control')) }} +
+ +
+ {{ Form::label('email', 'Email') }} + {{ Form::email('email', null, array('class' => 'form-control')) }} +
+ +
+ {{ Form::label('title', 'Title') }} + {{ Form::select('title', array('0' => 'Select a title', '1' => 'Mentor', '2' => 'Mentee', '3' => 'Both'), null, array('class' => 'form-control')) }} +
+ + {{ Form::submit('Edit the Mentor!', array('class' => 'btn btn-primary')) }} + +{{ Form::close() }} + +
+ + \ No newline at end of file diff --git a/app/views/mentors/index.blade.php b/app/views/mentors/index.blade.php new file mode 100644 index 0000000..6408963 --- /dev/null +++ b/app/views/mentors/index.blade.php @@ -0,0 +1,70 @@ + + + + Look! I'm CRUDding + + + +
+ + + +

All the Mentors

+ + +@if (Session::has('message')) +
{{ Session::get('message') }}
+@endif + + + + + + + + + + + + + @foreach($mentors as $key => $value) + + + + + + + + + + @endforeach + +
IDNameEmailTitleActions
{{ $value->id }}{{ $value->name }}{{ $value->email }}{{ $value->title }} + + + + + {{ Form::open(array('url' => 'mentors/' . $value->id, 'class' => 'pull-right')) }} + {{ Form::hidden('method', 'DELETE') }} + {{ Form::submit('Delete this Mentor', array('class' => 'btn btn-warning')) }} + {{ Form::close() }} + + + Show this mentor + + + Edit this mentor + +
+ +
+ + \ No newline at end of file diff --git a/app/views/mentors/show.blade.php b/app/views/mentors/show.blade.php new file mode 100644 index 0000000..e47e8f8 --- /dev/null +++ b/app/views/mentors/show.blade.php @@ -0,0 +1,34 @@ + + + + + + Look! I'm CRUDding + + + +
+ + + +

Showing {{ $mentor->name }}

+ +
+

{{ $mentor->name }}

+

+ Email: {{ $mentor->email }}
+ Title: {{ $mentor->title }} +

+
+ +
+ + \ No newline at end of file diff --git a/vendor/autoload.php b/vendor/autoload.php index d68079d..12afaae 100644 --- a/vendor/autoload.php +++ b/vendor/autoload.php @@ -4,4 +4,4 @@ require_once __DIR__ . '/composer' . '/autoload_real.php'; -return ComposerAutoloaderInitce866d1c30f9d3a988e9f177d36447af::getLoader(); +return ComposerAutoloaderInit72c82083eb743a8ff678afeb7e958c8c::getLoader(); diff --git a/vendor/composer/autoload_classmap.php b/vendor/composer/autoload_classmap.php index 4483abb..5a213fc 100644 --- a/vendor/composer/autoload_classmap.php +++ b/vendor/composer/autoload_classmap.php @@ -28,6 +28,7 @@ return array( 'ClassPreloader\\Parser\\DirVisitor' => $vendorDir . '/classpreloader/classpreloader/src/ClassPreloader/Parser/DirVisitor.php', 'ClassPreloader\\Parser\\FileVisitor' => $vendorDir . '/classpreloader/classpreloader/src/ClassPreloader/Parser/FileVisitor.php', 'ClassPreloader\\Parser\\NodeTraverser' => $vendorDir . '/classpreloader/classpreloader/src/ClassPreloader/Parser/NodeTraverser.php', + 'CreateMentorsTable' => $baseDir . '/app/database/migrations/2014_06_04_041712_create_mentors_table.php', 'Crypt_AES' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/AES.php', 'Crypt_Base' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/Base.php', 'Crypt_Blowfish' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/Blowfish.php', @@ -415,6 +416,8 @@ return array( 'Jeremeamia\\SuperClosure\\Visitor\\ClosureFinderVisitor' => $vendorDir . '/jeremeamia/SuperClosure/src/Jeremeamia/SuperClosure/Visitor/ClosureFinderVisitor.php', 'Jeremeamia\\SuperClosure\\Visitor\\MagicConstantVisitor' => $vendorDir . '/jeremeamia/SuperClosure/src/Jeremeamia/SuperClosure/Visitor/MagicConstantVisitor.php', 'Math_BigInteger' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Math/BigInteger.php', + 'Mentor' => $baseDir . '/app/models/Mentor.php', + 'MentorController' => $baseDir . '/app/controllers/MentorController.php', 'Monolog\\ErrorHandler' => $vendorDir . '/monolog/monolog/src/Monolog/ErrorHandler.php', 'Monolog\\Formatter\\ChromePHPFormatter' => $vendorDir . '/monolog/monolog/src/Monolog/Formatter/ChromePHPFormatter.php', 'Monolog\\Formatter\\ElasticaFormatter' => $vendorDir . '/monolog/monolog/src/Monolog/Formatter/ElasticaFormatter.php', diff --git a/vendor/composer/autoload_real.php b/vendor/composer/autoload_real.php index c66327d..097d560 100644 --- a/vendor/composer/autoload_real.php +++ b/vendor/composer/autoload_real.php @@ -2,7 +2,7 @@ // autoload_real.php @generated by Composer -class ComposerAutoloaderInitce866d1c30f9d3a988e9f177d36447af +class ComposerAutoloaderInit72c82083eb743a8ff678afeb7e958c8c { private static $loader; @@ -19,9 +19,9 @@ class ComposerAutoloaderInitce866d1c30f9d3a988e9f177d36447af return self::$loader; } - spl_autoload_register(array('ComposerAutoloaderInitce866d1c30f9d3a988e9f177d36447af', 'loadClassLoader'), true, true); + spl_autoload_register(array('ComposerAutoloaderInit72c82083eb743a8ff678afeb7e958c8c', 'loadClassLoader'), true, true); self::$loader = $loader = new \Composer\Autoload\ClassLoader(); - spl_autoload_unregister(array('ComposerAutoloaderInitce866d1c30f9d3a988e9f177d36447af', 'loadClassLoader')); + spl_autoload_unregister(array('ComposerAutoloaderInit72c82083eb743a8ff678afeb7e958c8c', 'loadClassLoader')); $vendorDir = dirname(__DIR__); $baseDir = dirname($vendorDir); @@ -49,14 +49,14 @@ class ComposerAutoloaderInitce866d1c30f9d3a988e9f177d36447af $includeFiles = require __DIR__ . '/autoload_files.php'; foreach ($includeFiles as $file) { - composerRequirece866d1c30f9d3a988e9f177d36447af($file); + composerRequire72c82083eb743a8ff678afeb7e958c8c($file); } return $loader; } } -function composerRequirece866d1c30f9d3a988e9f177d36447af($file) +function composerRequire72c82083eb743a8ff678afeb7e958c8c($file) { require $file; }