diff --git a/app/controllers/BlogController.php b/app/controllers/BlogController.php new file mode 100644 index 0000000..b61586c --- /dev/null +++ b/app/controllers/BlogController.php @@ -0,0 +1,121 @@ +with('blogs', $blogs); + } + + + /** + * Show the form for creating a new resource. + * + * @return Response + */ + public function create() + { + return View::make('blog.create'); + } + + + /** + * Store a newly created resource in storage. + * + * @return Response + */ + public function store() + { + $data = Input::all(); + + $blog = Blog::create(array( + 'title' => Input::get('title'), + 'author'=> Auth::user()->first, + 'body' => Input::get('body') + )); + + if($blog->save()) + { + return Redirect::route('blog.index'); + } + } + + + /** + * Display the specified resource. + * + * @param int $id + * @return Response + */ + public function show($id) + { + $post = Blog::find($id); + + return View::make('blog.show')->with('post', $post); + } + + + /** + * Show the form for editing the specified resource. + * + * @param int $id + * @return Response + */ + public function edit($id) + { + $post = Blog::find($id); + + return View::make('blog.edit')->with('post', $post); + } + + + /** + * Update the specified resource in storage. + * + * @param int $id + * @return Response + */ + public function update($id) + { + $data = Input::all(); + + $post = Blog::find($id); + + //complete validation here + + $post->title = Input::get('title'); + $post->author = Auth::user()->first; + $post->body = Input::get('body'); + + + if($post->save()) + { + return Redirect::route('blog.index'); + } + } + + + /** + * Remove the specified resource from storage. + * + * @param int $id + * @return Response + */ + public function destroy($id) + { + Blog::destroy($id); + + Session::flash('message', 'You have successfull deleted a blog post'); + + return Redirect::route('blog.index'); + } + + +} diff --git a/app/controllers/HomeController.php b/app/controllers/HomeController.php index 6384ff3..53a3b7a 100755 --- a/app/controllers/HomeController.php +++ b/app/controllers/HomeController.php @@ -25,4 +25,14 @@ class HomeController extends BaseController { return View::make('home'); } + public function showContact() + { + return View::make('contact'); + } + + public function contact() + { + $data = Input::all(); + } + } diff --git a/app/database/migrations/2014_07_13_045133_create_blogs_table.php b/app/database/migrations/2014_07_13_045133_create_blogs_table.php new file mode 100644 index 0000000..35430fe --- /dev/null +++ b/app/database/migrations/2014_07_13_045133_create_blogs_table.php @@ -0,0 +1,35 @@ +increments('id'); + $table->string('author'); + $table->text('title'); + $table->text('body'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('blogs'); + } + +} diff --git a/app/models/Blog.php b/app/models/Blog.php new file mode 100644 index 0000000..a4be5a0 --- /dev/null +++ b/app/models/Blog.php @@ -0,0 +1,14 @@ + 'required|min:5', + 'body' => 'required|min:100', + 'author' => 'required' + ); +} \ No newline at end of file diff --git a/app/routes.php b/app/routes.php index 55c5307..e0cb0cf 100755 --- a/app/routes.php +++ b/app/routes.php @@ -69,6 +69,10 @@ Route::group(array('before' => 'auth|admin'), function() }); +Route::get('contact', array('as' => 'contact', 'uses' => 'HomeController@showContact')); +Route::post('contact', array('uses' => 'HomeController@contact')); +Route::resource('blog', 'BlogController'); + Route::get('denied', function() { return View::make('404'); diff --git a/app/views/blog/create.blade.php b/app/views/blog/create.blade.php new file mode 100644 index 0000000..e69de29 diff --git a/app/views/blog/edit.blade.php b/app/views/blog/edit.blade.php new file mode 100644 index 0000000..e69de29 diff --git a/app/views/blog/index.blade.php b/app/views/blog/index.blade.php new file mode 100644 index 0000000..e69de29 diff --git a/app/views/blog/show.blade.php b/app/views/blog/show.blade.php new file mode 100644 index 0000000..e69de29 diff --git a/app/views/contact.blade.php b/app/views/contact.blade.php new file mode 100644 index 0000000..03dc43f --- /dev/null +++ b/app/views/contact.blade.php @@ -0,0 +1,104 @@ + + + + + + Compact contact form - Bootsnipp.com + + {{HTML::style('css/mentconnect.css')}} + {{HTML::style('css/denied.css')}} + + + +
+ +
+ +
+ {{ Form::open(array('url' => 'users/store', 'class' => 'form-horizontal')) }} + +
+
+

Got Questions?

+
+ +
+
+

Contact Us!

+

If you have any questions or suggestions, please complete the form below and we will get back to you as soon as possible.

+ +
+ +
+ +
+ + + {{ Form::email('email', \Input::old('email'), array('class' => 'form-control form-control-bordered', + 'tabindex' => '1')) }} +
+ +
+ + {{Form::text('subject', \Input::old('subject'), array('class' => 'form-control form-control-bordered', 'tabindex' => '2'))}} +
+ +
+ + {{ Form::textarea('message', Input::old('message'), array('class' => 'form-control form-control-bordered', 'tabindex' => '3')) }} +
+ +
+ {{Form::submit('Send', array('class' => 'btn btn-success btn-large submit-button'))}} +
+
+
+
+ {{ Form::close() }} +
+ + + + + \ No newline at end of file diff --git a/app/views/home.blade.php b/app/views/home.blade.php index 664b565..9f9dc73 100755 --- a/app/views/home.blade.php +++ b/app/views/home.blade.php @@ -17,11 +17,12 @@