function changesingulare($value) { if ($value == 'posts') { return 'post'; } } //$action = $_GET['action']; //var_dump($_GET['action']); switch ($action) { case 'index': //各条件 $cont->index(); break; case 'show': //各条件 $cont->show(10); break; case 'edit': //各条件 $cont->edit(20); break; case 'destroy': //各条件 $cont->destroy(10); break; case 'view': //各条件 $modl->view(10); break; case 'update': //各条件
<?php /* |-------------------------------------------------------------------------- | Application Routes |-------------------------------------------------------------------------- | | Here is where you can register all of the routes for an application. | It's a breeze. Simply tell Laravel the URIs it should respond to | and give it the Closure to execute when that URI is requested. | */ Route::group(array('prefix' => '/api'), function () { Route::post('login/auth', 'AuthController@Login'); Route::get('login/destroy', 'AuthController@Logout'); Route::resource('posts', 'PostController'); }); Route::get('admin', function () { return View::make('admin'); }); Route::get('/', function () { $posts = new PostController(); return View::make('index')->with('posts', $posts->index(1)); }); Route::get('/post/{id}', function ($id) { $posts = new PostController(); return View::make('single')->with('post', $posts->show($id, 1)); });