<?php use myMvc\System\Router; foreach ($users as $user) { printf('<a href="%s"><strong>%s</strong> (%s)</a><br />', Router::url('userShow', ['id' => $user->id]), $user->name, $user->email); }
<div class="form-group"> <label for="inputEmail" class="col-lg-3 control-label">Username</label> <div class="col-lg-9"> <?php printf('<p class="form-control-static">%s</p>', $user->username); ?> </div> </div> </fieldset> </form> <?php printf('<p><a class="btn btn-default" href="%s" role="button">Edit this user »</a></p>', Router::url('userEdit', ['id' => $user->id])); ?> </article> <article class="col-md-4"> <h2>Heading</h2> <p>Donec sed odio dui. Cras justo odio, dapibus ac facilisis in, egestas eget quam. Vestibulum id ligula porta felis euismod semper. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus.</p> <p><a class="btn btn-default" href="#" role="button">View details »</a></p> </article> </section> <?php
/** * [update description] * @param [type] $id [description] * @return [type] [description] */ public function update($id) { $result = $this->UserModel->update($id); if ($result) { Router::redirect('userShow', ['id' => $id]); } else { Router::redirect('userEdit', ['id' => $id]); } }
<p> <?php foreach ($klanten as $klantRow) { printf('<a href="%s"><strong>%s</strong> (%s)</a><br />', Router::url('klantShow', ['id' => $klantRow->id]), $klantRow->name, $klantRow->email); } printf('<p><a class="btn btn-primary" href="%s" role="button">Add a new user »</a></p>', Router::url('userCreate', ['id' => $klantRow->id])); ?> </p> </article> <article class="col-md-4"> <h2>User</h2> <form class="form-horizontal" method="post" action="<?php echo Router::url('userInsert'); ?> "> <fieldset> <legend>Create a user</legend> <div class="form-group"> <label for="name" class="col-lg-3 control-label">Name</label> <div class="col-lg-9"> <?php printf('<input type="text" class="form-control" id="name" name="name" placeholder="Name" value="%s" />', null); ?> </div> </div>
<p> <?php foreach ($users as $userRow) { printf('<a href="%s"><strong>%s</strong> (%s)</a><br />', Router::url('userShow', ['id' => $userRow->id]), $userRow->name, $userRow->email); } printf('<p><a class="btn btn-primary" href="%s" role="button">Add a new user »</a></p>', Router::url('userCreate', ['id' => $userRow->id])); ?> </p> </article> <article class="col-md-4"> <h2>User</h2> <form class="form-horizontal" method="post" action="<?php echo Router::url('userUpdate', ['id' => $user->id]); ?> "> <fieldset> <legend>Edit a user</legend> <div class="form-group"> <label for="name" class="col-lg-3 control-label">Name</label> <div class="col-lg-9"> <?php printf('<input type="text" class="form-control" id="name" name="name" placeholder="Name" value="%s" />', $user->name); ?> </div> </div>
/** * [update description] * @param [type] $id [description] * @return [type] [description] */ public function update($id) { $result = $this->klantModel->update($id); if ($result) { Router::redirect('klantenhow', ['id' => $id]); } else { Router::redirect('klantEdit', ['id' => $id]); } }
<?php use myMvc\System\Router; Router::route('get', '/test', function () { echo "Subrouter 'Test' works!"; });
Router::route('post', '/users/create', 'UserController::insert', 'userInsert'); # Note that routes with variables should be at the bottom Router::route('post', '/users/:id', 'UserController::update', 'userUpdate'); Router::route('get', '/users/:id', 'UserController::show', 'userShow'); Router::route('get', '/users/:id/edit', 'UserController::edit', 'userEdit'); # Another example using the View class. # This time showByView() adds views to multiple sections /*Router::route('get', '/users/:id', function ($id){ # Initialize a UserController, we'll use the # fully qualified name for this test $UserController = new myMvc\App\Controllers\UserController(); # This method adds two views to the 'firstcolumn' and 'secondcolumn' sections # main layout view, App/Views/app.layout.php $UserController->showByView($id); # For now the View class is only used in this instance # When implemented in all Controller methods, this # call should be executed last, at the bottom of this page. View::display('App/Views/app.layout.php', []); }, 'userShow');*/ /* More routes, or make subroutes in App/Routes, see App/Routes/test.php */ /* Execute route */ Router::execute();
<?php include 'App/Views/app.header.php'; ?> <section class="row"> <article class="col-md-4"> <h2>Users</h2> <h3>A list of all our users.</h3> <p> <?php foreach ($users as $user) { printf('<a href="%s"><strong>%s</strong> (%s)</a><br />', Router::url('userShow', ['id' => $user->id]), $user->name, $user->email); } printf('<p><a class="btn btn-primary" href="%s" role="button">Add a new user »</a></p>', Router::url('userCreate', ['id' => $user->id])); ?> </p> </article> <article class="col-md-4"> <h2>Heading</h2> <p>Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui. </p> <p><a class="btn btn-default" href="#" role="button">View details »</a></p> </article> <article class="col-md-4"> <h2>Heading</h2> <p>Donec sed odio dui. Cras justo odio, dapibus ac facilisis in, egestas eget quam. Vestibulum id ligula porta felis euismod semper. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus.</p>