index() public méthode

General "post" form, allows posting of any kind of form. Attach to PostController_AfterFormCollection_Handler.
Since: 2.0.0
public index ( $CurrentFormName = 'discussion' )
Exemple #1
0
require_once 'app/db/doConnection.php';
?>

<!DOCTYPE html>
<html>
  <head>
    <title>The social network</title>
    <link type="text/css" rel="stylesheet" href="/assets/css/base.css" media="all" />
  </head>
  <body>
    <?php 
// Include the PostController
require_once 'app/controllers/PostController.php';
// Get the posts for current user based on the role.
$post = new PostController();
$results = $post->index();
?>

    <div id="main-wrapp">
      <header>
        <div class="logo"><a href="/">The Social Network</a></div>
        <div class="user-data">
          <p>Welcome USER!</p>
          <a href="/post_add.php">Add new post</a>
        </div>
      </header>

      <div class="main-container">
        <?php 
if (empty($results)) {
    ?>
require 'models/' . changesingulare($resource) . '.php';
$cont = new PostController();
$modl = new Post();
//複数形を単数形に変換
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':
        //各条件
<?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));
});