You've already forked lubo_comment_query
init
This commit is contained in:
27
app/Http/Controllers/CommentQueryController.php
Normal file
27
app/Http/Controllers/CommentQueryController.php
Normal file
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\VideoComments;
|
||||
use Illuminate\Routing\Controller as BaseController;
|
||||
|
||||
class CommentQueryController extends BaseController
|
||||
{
|
||||
public function index() {
|
||||
$keyword = request()->get("keyword", "");
|
||||
$query = VideoComments::query()->where("is_top", "=", 1)->with("video")->orderByDesc("created_at");
|
||||
if ($keyword) {
|
||||
$keyword_split = explode(" ", $keyword);
|
||||
foreach ($keyword_split as $_keyword) {
|
||||
if (mb_strlen(trim($_keyword)) > 0) {
|
||||
$query->where("content", "like", "%{$_keyword}%");
|
||||
}
|
||||
}
|
||||
}
|
||||
$comments = $query->limit(20)->get();
|
||||
return view("index", [
|
||||
"keyword" => $keyword,
|
||||
"comments" => $comments,
|
||||
]);
|
||||
}
|
||||
}
|
13
app/Http/Controllers/Controller.php
Normal file
13
app/Http/Controllers/Controller.php
Normal file
@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
||||
use Illuminate\Foundation\Bus\DispatchesJobs;
|
||||
use Illuminate\Foundation\Validation\ValidatesRequests;
|
||||
use Illuminate\Routing\Controller as BaseController;
|
||||
|
||||
class Controller extends BaseController
|
||||
{
|
||||
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
|
||||
}
|
Reference in New Issue
Block a user