public function run()
 {
     $this->command->info('Deleting existing PortfolioTag table...');
     DB::table('portfoliotags')->truncate();
     $count = 5;
     $faker = Faker\Factory::create('fr_FR');
     for ($i = 0; $i < $count; $i++) {
         $name = $faker->word;
         PortfolioTag::create(array('name' => ucwords($name), 'slug' => Str::slug($name)));
     }
     $this->command->info('Portfolio Tags inserted successfully!');
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     // Get the page data
     if (is_null($post = PortfolioPost::find($id))) {
         // Redirect to Page management page
         return Redirect::route('portfolio.admin')->with('error', Lang::get('modules/portfolio/messages.error.not_found'));
     }
     if (!empty($post->image)) {
         unlink($this->destinationPath . $post->image);
     }
     $post->tags()->detach();
     foreach (PortfolioTag::all() as $tag) {
         if (!$tag->posts->count()) {
             $tag->delete();
         }
     }
     // Was the page created?
     if ($post->delete()) {
         // Redirect to the new page page
         return Redirect::route('portfolio.admin')->with('success', Lang::get('modules/portfolio/messages.success.delete'));
     }
     // Redirect to the page admin page
     return Redirect::route('portfolio.admin')->with('error', Lang::get('modules/portfolio/messages.error.delete'));
 }
Example #3
0
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'));
Route::post('contact', 'ContactController@postIndex');
// Page
Route::get('page/{id}/publish/{state}', array('as' => 'page.publish', 'uses' => 'PageController@publish'));
Route::get('page/{id}/inMenu/{state}', array('as' => 'page.inMenu', 'uses' => 'PageController@inMenu'));
Route::resource('page', 'PageController');
// Page Display
Route::get('{slug}', array('as' => 'page.show', 'uses' => 'PageController@show'));
// Set Locale
Route::get('lang/{lang}', array('as' => 'setLang', 'uses' => 'BaseController@setLocale'));