コメント一覧

このコミットが含まれているのは:
テクニカル諏訪子 2020-12-30 16:15:06 +09:00
コミット 04ac8602a1
5個のファイルの変更141行の追加0行の削除

91
app/Http/Controllers/Home/CommentList.php ノーマルファイル
ファイルの表示

@ -0,0 +1,91 @@
<?php
namespace App\Http\Controllers\Home;
use Illuminate\Support\Facades\DB;
// use Illuminate\Support\Facades\Log;
use App\Http\Controllers\UserController;
class CommentList {
private $objUser;
private $valid;
private $menu;
private $user;
public function __construct ($v, $m, $u) {
$this->objUser = new UserController();
$this->valid = $v;
$this->menu = $m;
$this->user = $u;
}
public function index () {
$get = DB::table('blg_comments')->orderBy('created', 'desc')->paginate(10);
setlocale(LC_ALL, 'ja_JP.utf8');
$ucol = $this->objUser->getGroupColours();
foreach ($get as $g) {
if (!is_null($g->user_id)) {
$g->username = DB::table('users')->select('username')->where('id', $g->user_id)->first()->username;
$g->showName = '';
$g->showCol = '';
$g->perm_id = DB::table('usr_perm_id')->select('perm_id')->where('user_id', $g->user_id)->first()->perm_id;
$p = DB::table('usr_profile')->select('gender', 'avatar', 'name_style', 'display_name')->where('user_id', $g->user_id)->first();
$g->gender = $p->gender;
$g->avatar = $p->avatar;
$g->name_style = $p->name_style;
$g->display_name = $p->display_name;
if (count(userDetail($g->user_id)) > 0) {
$det = userDetail($g->user_id);
$g->user_id = $det['user_id'];
$g->showname = $det['showname'];
$g->showcol = $det['showcol'];
$g->avatar = $det['avatar'];
}
if ($g->isShadow == 0) {
if (getIp() != $g->ipaddress) unset($get->comments[$k]);
}
else {
unset($g->email);
unset($g->ipaddress);
unset($g->isShadow);
}
if (!empty($g->display_name)) $g->showname = $g->display_name;
else $g->showname = $g->username;
if (!empty($g->name_style)) $g->showcol = $g->name_style;
else {
foreach ($ucol as $j) {
if ($j->id == $g->perm_id) {
if ($g->gender == 1) $g->showcol = $j->colour_m;
else if ($g->gender == 2) $g->showcol = $j->colour_f;
else $g->showcol = $j->colour_u;
}
}
}
$g->user = userDetail(null, DB::table('users')->select('kero_token')->where('id', $g->user_id)->first()->kero_token);
}
else {
if (is_null($g->name)) $g->name = '名無しのテクニシャン';
}
if (!is_null($g->post_id) && $g->post_id != 0) {
$g->url = '/blog/'.DB::table('blg_content')->where('id', $g->post_id)->first()->slug.'#comment-'.$g->id;
$g->title = DB::table('blg_content')->where('id', $g->post_id)->first()->title;
}
else if (!is_null($g->video_id) && $g->video_id != '') {
$g->url = '/video/play/'.$g->video_id.'#comment-'.$g->id;
$g->title = DB::table('vid_video')->where('vid', $g->video_id)->first()->title;
}
$g->created = date('Y年m月d日 H:i:s', $g->created);
}
return view('pages.site.commentlist', ['res' => $get, 'menu' => $this->menu, 'user' => $this->user]);
}
}

ファイルの表示

@ -43,6 +43,11 @@ class HomeController extends Controller {
return $r->page($slug);
}
public function commentList () {
$r = new \App\Http\Controllers\Home\CommentList($this->valid, $this->menu, $this->user);
return $r->index();
}
public function newComment (Request $rr) {
$r = new Comment();
return $r->add($rr);

ファイルの表示

@ -81,6 +81,10 @@
@if ($user->perm['blg_addpost'])
<a href="/video/add" class="dropdown-item">動画の追加</a>
@endif
@if ($user->perm['blg_addpost'] || $user->perm['blg_addpage'] || $user->perm['blg_editpost'] || $user->perm['blg_editpage'] || $user->perm['blg_delpost'] || $user->perm['blg_delpage'])
<div class="dropdown-divider"></div>
<a href="/commentlist" class="dropdown-item">コメント一覧</a>
@endif
<div class="dropdown-divider"></div>
<a href="/logout" class="dropdown-item">サインアウト</a>
@else

ファイルの表示

@ -0,0 +1,39 @@
@extends('layouts.site')
@section('content')
<div class="within">
<div class="bar">コメント一覧</div>
<div class="back" style="white-space: pre-wrap;">
<div class="table-responsive">
<table class="table table-hover table-dark">
<thead>
<tr>
<th scope="col">ユーザー</th>
<th scope="col">ページ</th>
<th scope="col">日時</th>
<th scope="col">メッセージ</th>
</tr>
</thead>
@foreach ($res as $k => $r)
<tr>
<td scope="row">
@if (!is_null($r->user_id))
<a href="/profile/{{$r->user_id}}">
<img src="{{ $r->avatar }}" width="20" height="20" alt="{{ $r->showname }}のアイコン" />
<span style="{{ $r->showcol }}">{{ $r->showname }}</span>
</a>
@else
{{ (!is_null($r->name) ? $r->name : '名無しのテクニシャン') }}
@endif
</td>
<td scope="row"><a href="{{$r->url}}">{{ $r->title }}</a></td>
<td scope="row">{{ $r->created }}</td>
<td scope="row">{{ $r->message }}</td>
</tr>
@endforeach
</table>
</div>
</div>
</div>
@endsection

ファイルの表示

@ -31,4 +31,6 @@ Route::get('/video', 'VideoController@index');
Route::get('/video/{slug}', 'VideoController@table');
Route::get('/video/play/{vid}', 'VideoController@prayer');
Route::get('/commentlist', 'HomeController@commentList');
Route::get('/{slug}', 'HomeController@page');