Skip to main content

Black Friday 2025! Only until December 1st: coupon FRIDAY25 for 40% off Yearly/Lifetime membership!

Read more here

phpreel/phpreel

126 stars
2 code files
View phpreel/phpreel on GitHub

app/Helpers/Categories/CategoriesHandler.php

Open in GitHub
use Illuminate\Http\Request;
use App\Models\Movie;
use App\Models\Series;
 
class CategoriesHandler
{
public static function getMovieByCategory(string $category, string $param)
{
$movies = Movie::orderByDesc('id')
->where([[$category, 'like', '%' . $param . '%'], ['public', '=', '1']])
->join('images', 'images.id', '=', 'movies.thumbnail')
->select(
'movies.id as id',
'movies.title as title',
'movies.description as description',
'movies.year as year',
'movies.length as length',
'movies.cast as cast',
'movies.genre as genre',
'images.name as image_name',
'images.storage as image_storage',
)->get();
 
return $movies;
}
 
public static function getSeriesByCategory(string $category, string $param)
{
$series = Series::orderByDesc('id')
->where([[$category, 'like', '%' . $param . '%'], ['public', '=', '1']])
->join('images', 'images.id', '=', 'series.thumbnail')
->select(
'series.id as id',
'series.title as title',
'series.description as description',
'series.year as year',
'series.cast as cast',
'series.genre as genre',
'images.name as image_name',
'images.storage as image_storage',
)->get();
 
return $series;
}
}

app/Http/Controllers/CategoriesController.php

Open in GitHub
use App\Helpers\Categories\CategoriesHandler;
 
class CategoriesController extends Controller
{
public function showCast($slug)
{
$movies = CategoriesHandler::getMovieByCategory('cast', $slug);
 
$series = CategoriesHandler::getSeriesByCategory('cast', $slug);
//
}
//
}

We'd Love Your Feedback

Tell us what you like or what we can improve

Feel free to share anything you like or dislike about this page or the platform in general.