コード例 #1
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function destroy(Request $request)
 {
     $delete_items = $request->input('delete_items', []);
     if (count($delete_items) > 0) {
         $query = $this->article->whereIn('id', $delete_items);
         $query->delete();
     }
     Flash::success(trans('message.entity_deleted', ['entity' => trans('models.article')]));
     return redirect()->route('admin.articles.index');
 }
コード例 #2
0
ファイル: ArticleSeeder.php プロジェクト: larasite/larasite
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Model::unguard();
     DB::table('articles')->delete();
     $statuses = Article::$statuses;
     $faker = Faker\Factory::create('en_US');
     $today = Carbon::today();
     for ($i = 0; $i < 1000; $i++) {
         Article::create(['title' => $faker->sentence(), 'body' => $faker->paragraph(), 'status' => $statuses[array_rand($statuses)], 'published_at' => $today]);
     }
     Model::reguard();
 }
コード例 #3
0
ファイル: routes.php プロジェクト: larasite/larasite
/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| 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 controller to call when that URI is requested.
|
*/
use App\Entities\Article;
require 'routes_admin.php';
Route::get('/blog', function () {
    $articles = Article::with(['category', 'tags'])->where('status', 'Published')->orderBy('published_at', 'desc')->orderBy('created_at', 'desc')->paginate();
    return view('pages.blog.index', compact('articles'));
});
Route::get('/blog/{id}', function ($id) {
    $article = Article::findOrFail($id);
    return view('pages.blog.show', compact('article'));
});
Route::post('mailform', 'MailFormController@sendmail');
Route::get('/', function () {
    return view('pages/home');
});
Route::get('{any}', function ($any) {
    try {
        return view("pages/{$any}");
    } catch (Exception $e) {
        abort(404);
    }
})->where('view', '.*');