03.12.2015 Views

laravel4cookbook

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

File-Based CMS 337<br />

127 "code" => "required"<br />

128 ]);<br />

129<br />

130 if ($validator->fails())<br />

131 {<br />

132 return Redirect::route("admin/page/edit")<br />

133 ->withInput()<br />

134 ->withErrors($validator);<br />

135 }<br />

136<br />

137 $meta = "<br />

138 title = " . Input::get("title") . "<br />

139 description = " . Input::get("description") . "<br />

140 layout = " . Input::get("layout") . "<br />

141 route = " . Input::get("route") . "<br />

142 ==<br />

143 ";<br />

144<br />

145 $name = "pages/" . Input::get("name") . ".blade.php";<br />

146<br />

147 $this->filesystem->put($name, $meta . Input::get("code"));<br />

148<br />

149 return Redirect::route("admin/page/index");<br />

150 }<br />

151<br />

152 return View::make("admin/page/edit", compact(<br />

153 "name",<br />

154 "title",<br />

155 "description",<br />

156 "layout",<br />

157 "layouts",<br />

158 "route",<br />

159 "code"<br />

160 ));<br />

161 }<br />

162<br />

163 public function deleteAction()<br />

164 {<br />

165 $name = "pages/" . Input::get("page");<br />

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

167<br />

168 return Redirect::route("admin/page/index");

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

Saved successfully!

Ooh no, something went wrong!