2020-06-05 13:54:40 +00:00
|
|
|
<?php
|
2020-08-04 11:25:22 +00:00
|
|
|
|
2020-06-10 15:00:12 +00:00
|
|
|
/**
|
|
|
|
* @copyright 2020 Podlibre
|
|
|
|
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
|
|
|
|
* @link https://castopod.org/
|
|
|
|
*/
|
2020-06-05 13:54:40 +00:00
|
|
|
|
|
|
|
namespace App\Controllers;
|
|
|
|
|
|
|
|
use App\Models\PodcastModel;
|
|
|
|
|
|
|
|
class Home extends BaseController
|
|
|
|
{
|
2021-05-06 14:00:48 +00:00
|
|
|
/**
|
|
|
|
* @return mixed
|
|
|
|
*/
|
2020-06-10 15:00:12 +00:00
|
|
|
public function index()
|
|
|
|
{
|
|
|
|
$model = new PodcastModel();
|
2020-06-05 13:54:40 +00:00
|
|
|
|
2020-08-04 11:25:22 +00:00
|
|
|
$allPodcasts = $model->findAll();
|
2020-06-26 14:34:52 +00:00
|
|
|
|
|
|
|
// check if there's only one podcast to redirect user to it
|
2020-08-04 11:25:22 +00:00
|
|
|
if (count($allPodcasts) == 1) {
|
2021-04-02 17:20:02 +00:00
|
|
|
return redirect()->route('podcast-activity', [
|
|
|
|
$allPodcasts[0]->name,
|
|
|
|
]);
|
2020-06-26 14:34:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// default behavior: list all podcasts on home page
|
2020-08-04 11:25:22 +00:00
|
|
|
$data = ['podcasts' => $allPodcasts];
|
2020-06-10 15:00:12 +00:00
|
|
|
return view('home', $data);
|
|
|
|
}
|
2020-06-05 13:54:40 +00:00
|
|
|
}
|