Skip to content

Commit

Permalink
✨ Play view
Browse files Browse the repository at this point in the history
  • Loading branch information
juzaweb committed Oct 8, 2021
1 parent 260b700 commit e21ecda
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 17 deletions.
12 changes: 12 additions & 0 deletions src/Actions/MenuAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,18 @@ public function addAjaxTheme()
HookAction::registerFrontendAjax('get-player', [
'callback' => [app(AjaxController::class), 'getPlayer']
]);

HookAction::registerFrontendAjax('set-view', [
'callback' => [app(AjaxController::class), 'setMovieView']
]);

HookAction::registerFrontendAjax('popular-movies', [
'callback' => [app(AjaxController::class), 'getPopularMovies']
]);

HookAction::registerFrontendAjax('movies-genre', [
'callback' => [app(AjaxController::class), 'getMoviesByGenre']
]);
}

/**
Expand Down
43 changes: 27 additions & 16 deletions src/Http/Controllers/AjaxController.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,16 @@ public function getFilterForm()
]);
}

public function getMoviesByGenre(Request $request)
public function getMoviesByGenre()
{
$genre = $request->get('cat_id');
$showpost = $request->get('showpost', 12);
$genre = request()->get('cat_id');
$showpost = request()->get('showpost', 12);

$query = Movie::select([
'id',
'name',
'other_name',
'short_description',
'title',
'origin_title',
'description',
'thumbnail',
'slug',
'views',
Expand All @@ -61,19 +61,29 @@ public function getMoviesByGenre(Request $request)
]);

$query->wherePublish();
$query->whereRaw('find_in_set(?, genres)', [$genre]);
$query->whereTaxonomy($genre);
$query->limit($showpost);

return view('data.movies_by_genre', [
'items' => $query->get()
]);
}

public function getPopularMovies(Request $request)
public function getPopularMovies()
{
$type = $request->get('type');
$type = request()->get('type');
$items = $this->getPopular($type);
return view('data.popular_movies', [

foreach ($items as $item) {
$item->url = $item->getLink();
$item->thumbnail = $item->getThumbnail();
$item->views = $item->views .' '. trans('juzaweb::app.views');
if (empty($item->origin_title)) {
$item->origin_title = '';
}
}

return response()->json([
'items' => $items
]);
}
Expand Down Expand Up @@ -132,8 +142,9 @@ public function getPlayer()
]);
}

public function setMovieView($slug)
public function setMovieView()
{
$slug = request()->post('slug');
$movie = Movie::createFrontendBuilder()
->where('slug', '=', $slug)
->firstOrFail(['id', 'views']);
Expand Down Expand Up @@ -184,9 +195,9 @@ public function download(Request $request)

public function setRating()
{
$slug = request()->post('slug');
$movie = request()->post('movie');
$movie = Movie::createFrontendBuilder()
->where('slug', '=', $slug)
->where('id', '=', $movie)
->firstOrFail(['id']);

$start = request()->post('value');
Expand Down Expand Up @@ -271,9 +282,9 @@ protected function getPopular($type)
{
$query = Movie::select([
'id',
'name',
'other_name',
'short_description',
'title',
'origin_title',
'description',
'thumbnail',
'slug',
'views',
Expand Down
3 changes: 2 additions & 1 deletion src/Http/Controllers/Backend/AdsSettingController.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ public function form($id = null)
]);
}

public function save(Request $request) {
public function save(Request $request)
{
$this->validate($request, [
'body' => 'nullable',
'status' => 'required|in:0,1',
Expand Down

0 comments on commit e21ecda

Please sign in to comment.