/** * Run the database seeds. * * @return void */ public function run() { $videos = glob(public_path() . '/b/*'); usort($videos, function ($a, $b) { $a = (int) basename($a, '.webm'); $b = (int) basename($b, '.webm'); if ($a == $b) { return 0; } return $a < $b ? -1 : 1; }); $category = \App\Models\Category::where('shortname', '=', 'misc')->first(); $user = \App\Models\User::find(1); foreach ($videos as $video) { if (\App\Models\Video::whereFile(basename($video))->count() > 0) { continue; } $v = new \App\Models\Video(); $v->user()->associate($user); $v->category()->associate($category); $v->hash = sha1_file($video); $v->file = basename($video); $v->save(); } }
/* |-------------------------------------------------------------------------- | 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. | */ Route::get('/', ['as' => 'home', function () { Session::reflash(); $id = App\Models\Video::count() - 1; $id = rand(0, $id); $video = App\Models\Video::skip($id)->first(); return redirect($video->id); }]); Route::get('user/{username}', 'UserController@show'); Route::get('logout', 'UserController@logout'); Route::post('login', 'UserController@login'); Route::get('register', 'UserController@create'); Route::post('register', 'UserController@store'); Route::get('activate/{token}', 'UserController@activate'); Route::get('songindex', 'VideoController@index'); Route::get('upload', 'VideoController@create'); Route::post('upload', 'VideoController@store'); Route::get('categories', 'CategoryController@index'); Route::get('about', function () { return view('about'); });