Exemple #1
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     // Get the page data
     if (is_null($post = BlogPost::find($id))) {
         // Redirect to BlogPost management page
         return Redirect::route('blog.admin')->with('error', Lang::get('modules/blog/messages.error.not_found'));
     }
     if (!empty($post->image)) {
         unlink($this->destinationPath . $post->image);
     }
     $post->tags()->detach();
     foreach (BlogTag::all() as $tag) {
         if (!$tag->posts->count()) {
             $tag->delete();
         }
     }
     // Was the page created?
     if ($post->delete()) {
         // Redirect to the BlogPost management page
         return Redirect::route('blog.admin')->with('success', Lang::get('modules/blog/messages.success.delete'));
     }
     // Redirect to the BlogPost management page
     return Redirect::route('blog.admin')->with('error', Lang::get('modules/blog/messages.error.delete'));
 }
Exemple #2
0
|--------------------------------------------------------------------------
|
| 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.
|
*/
// Blog
Route::get('/', array('as' => 'home', 'uses' => 'HomeController@getIndex'));
Route::group(array('prefix' => 'blog'), function () {
    Route::get('admin', array('as' => 'blog.admin', 'uses' => 'BlogController@admin'));
    Route::get('{id}/delete', array('as' => 'blog.delete', 'uses' => 'BlogController@destroy'));
    Route::get('{id}/publish/{state}', array('as' => 'blog.publish', 'uses' => 'BlogController@publish'));
    Route::get('tag/{slug}', array('as' => 'blog.postsByTag', 'uses' => 'BlogController@getPostsByTag'));
    Route::get('cats.json', function () {
        return BlogTag::all()->lists('name');
    });
});
Route::resource('blog', 'BlogController');
// Portfolio
Route::group(array('prefix' => 'portfolio'), function () {
    Route::get('admin', array('as' => 'portfolio.admin', 'uses' => 'PortfolioController@admin'));
    Route::get('{id}/delete', array('as' => 'portfolio.delete', 'uses' => 'PortfolioController@destroy'));
    Route::get('{id}/publish/{state}', array('as' => 'portfolio.publish', 'uses' => 'PortfolioController@publish'));
    Route::get('cats.json', function () {
        return PortfolioTag::all()->lists('name');
    });
});
Route::resource('portfolio', 'PortfolioController');
// Contact
Route::get('contact', array('as' => 'contact', 'uses' => 'ContactController@getIndex'));