Created
March 29, 2014 17:13
-
-
Save Rokt33r/9858259 to your computer and use it in GitHub Desktop.
Laravel 基礎 Lesson 4 - DB (app/controllers/PostController.php)
This file contains 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
<?php | |
class PostController extends BaseController{ | |
function create(){ | |
return View::make('posts.create'); | |
} | |
function store(){ | |
DB::table('posts')->insert([ | |
'title'=>Input::get('title'), | |
'body'=>Input::get('body') | |
]); | |
return Redirect::to('posts'); | |
} | |
function index(){ | |
$posts = DB::table('posts')->get(); | |
return View::make('posts.index')->with('posts', $posts); | |
} | |
function show($postid){ | |
$post = DB::table('posts')->where('id',$postid)->first(); | |
return View::make('posts.show')->with('post', $post); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment