<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Route::get('/', function() { return redirect()->route('nieuws'); });

Route::get('/nieuws', 'NewsController@overview')->name('nieuws');
Route::get('/nieuws/regio/{region}', 'NewsController@regionlist' )->where(['region' => '[a-z0-9]+'])->name('nieuws.regio');
Route::get('/nieuws/thema/{theme}', 'NewsController@themelist' )->where(['themelist' => '[a-z0-9]+'])->name('nieuws.thema');
Route::get('/nieuws/{id}/{title}', 'NewsController@show')->where(['id' => '\d+'])->name('nieuws.detail');
Route::get('/nieuws/zoeken/{query}', 'NewsController@search')->name('nieuws.zoeken');
Route::get('/nieuws/zoeken', function(Illuminate\Http\Request $request) { 
  if($query = $request->get('query', null)) { 
    return redirect('/nieuws/zoeken/' . urlencode($query));
  }
  return redirect('/nieuws');
});

Route::get('/blog/{id}/{title}', 'NewsController@blog')->where(['id' => '\d+'])->name('blog');
Route::get('/blog', 'NewsController@activeblog');

Route::get('/beelden', 'ImagesController@overview')->name('beelden');
Route::get('/beelden/regio/{region}', 'ImagesController@regionlist' )->where(['region' => '[a-z0-9]+'])->name('beelden.regio');
Route::get('/beelden/thema/{theme}', 'ImagesController@themelist' )->where(['themelist' => '[a-z0-9]+'])->name('beelden.thema');
Route::get('/beelden/{id}/{title}', 'ImagesController@show')->where(['id' => '\d+'])->name('beelden.detail');

Route::get('/onair', 'RadioController@onair')->name('onair');

Route::get('/agenda', 'CalendarController@overview')->name('agenda');
Route::get('/agenda/{id}/{title}', 'CalendarController@show')->where(['id' => '\d+'])->name('agenda.details');

Route::get('/gids/{shift?}', 'RadioController@schedule')->where(['shift' => '-?\d+'])->name('radio.gids');
Route::get('/programma/{id}/{title}', 'RadioController@program')->where(['id' => '\d+']);
Route::get('/programma')->name('programma');

Route::get('/luister/live', 'StreamController@liveradio')->name('luister.live');
Route::get('/luister/regionieuws', 'NewsController@regionieuws')->name('luister.regionieuws');
Route::get('/luister/gemeenteraad', 'StreamController@gemeenteraad')->name('luister.gemeenteraad');
Route::get('/luister/fragment/{id}/{title}', 'StreamController@podcast')->where(['id' => '\d+']);
Route::get('/luister/fragment')->name('luister.podcast');
Route::get('/luister/programma/{year}/{month}/{day}/{hour}/{duration}/{offset?}', 'StreamController@program')
	->where(['id' => '\d+', 'year' => '20\d\d', 'month' => '\d\d?', 'day' => '\d\d?', 'hour' => '\d\d?', 'duration' => '\d\d?', 'offset' => '\d\d?']);
Route::get('/luister/programma')->name('luister.programma');

Route::get('/gemist', 'RadioController@podcasts')->name('gemist');
Route::get('/gemist/zoeken/{query}', 'RadioController@searchpodcast')->name('gemist.zoeken');
Route::get('/gemist/zoeken', function(Illuminate\Http\Request $request) { 
  if($query = $request->get('query', null)) { 
    return redirect('/gemist/zoeken/' . urlencode($query));
  }
  return redirect('/gemist');
});

Route::get('/gemist/fragment', 'RadioController@podcasts')->name('gemist.fragment');
Route::get('/gemist/fragment/{id}/{title}', 'RadioController@podcast')->where(['id' => '\d+']);
Route::get('/gemist/programma', 'RadioController@terugluisteren')->name('gemist.programma');
Route::get('/gemist/programma/{programma}/{title}', 'RadioController@podcasts')->where(['programma' => '\d+']);

Route::get('/podcast/{programma}/{title}', 'PodcastController@podcasts')->where(['programma' => '\d+']);
Route::get('/podcast/aflevering/{id}/{title}', 'PodcastController@podcast')->where(['id' => '\d+']);
Route::get('/podcast/zoeken/{query}', 'RadioController@searchpodcast')->name('gemist.zoeken');
Route::get('/podcast/zoeken', function(Illuminate\Http\Request $request) { 
  if($query = $request->get('query', null)) { 
    return redirect('/podcast/zoeken/' . urlencode($query));
  }
  return redirect('/podcast');
});

Route::get('/kijk/live', 'StreamController@livetv')->name('kijk.live');
Route::get('/kijk/studio', 'StreamController@studio')->name('kijk.studio');

Route::get('/kerkdienst', 'KerkdienstController@main')->name('kerkdienst');
Route::get('/kerkdienst/luister', 'StreamController@kerkdienst')->name('luister.kerkdienst');

Route::get('/contact', 'Controller@view_contact')->name('contact');
Route::get('/frequenties', 'Controller@view_frequenties')->name('frequenties');
Route::get('/adverteren', 'Controller@view_adverteren')->name('adverteren');
Route::get('/app', 'Controller@view_app')->name('app');

Route::get('/vacatures/ontmoet-ons', 'JobsController@bijeenkomst');
Route::post('/vacatures/ontmoet-ons', 'JobsController@aanmelden');
Route::get('/vacatures', 'JobsController@overview')->name('vacatures');
Route::get('/vacatures/{id}/{title}', 'JobsController@show')->where(['id' => '\d+'])->name('vacature');

Route::any('/winterse50', function() { return redirect('/programma/1080/winterse-50'); });

// Route::any('/vol-luisterlijst', 'SpecialController@luisterlijst_stem');
Route::any('/vol-luisterlijst', 'Controller@view_luisterlijst_2021');
Route::any('/luisterlijst/2019', 'Controller@view_luisterlijst_2019');
Route::any('/luisterlijst/2021', 'Controller@view_luisterlijst_2021');
Route::any('/luisterlijst', 'Controller@view_luisterlijst_2021');

Route::any('/debat', 'Controller@view_debat');

//Route::get('/special/stmaarten', function() { return file_get_contents('http://api-dev.6fm.nl/special/stmaarten'); });
//Route::get('/kabelkrant', function() { return view('kabelkrant'); });

