03.12.2015 Views

laravel4cookbook

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

File-Based CMS 333<br />

1 public function deleteAction()<br />

2 {<br />

3 $name = "layouts/" . Input::get("layout");<br />

4 $this->filesystem->delete($name);<br />

5<br />

6 return Redirect::route("admin/layout/index");<br />

7 }<br />

.<br />

This was extracted from app/controllers/LayoutController.php.<br />

1 Route::any("admin/layout/delete", [<br />

2 "as" => "admin/layout/delete",<br />

3 "uses" => "LayoutController@deleteAction"<br />

4 ]);<br />

.<br />

This was extracted from app/routes.php.<br />

We link straight to the deleteAction() method in the index view. This method simply deletes the<br />

layout file and redirects back to the index page. We’ve added the appropriate route to make this page<br />

accessible.<br />

We can now list the layout files, add new ones, edit existing ones and delete those layout files we<br />

no longer require. It’s basic, and could definitely be polished a bit, but it’s sufficient for our needs.<br />

Creating Pages<br />

Pages are handled in much the same way, so we’re not going to spend too much time on them. Let’s<br />

begin with the controller:

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!