mirror of
https://github.com/HDInnovations/UNIT3D-Community-Edition.git
synced 2026-04-24 03:59:08 -05:00
(Update) User Note System
This commit is contained in:
@@ -21,11 +21,10 @@ use \Toastr;
|
||||
class NoteController extends Controller
|
||||
{
|
||||
/**
|
||||
* User Staff Notes System
|
||||
*
|
||||
* Get All User Notes
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
|
||||
public function getNotes()
|
||||
{
|
||||
$notes = Note::latest()->paginate(25);
|
||||
@@ -33,36 +32,56 @@ class NoteController extends Controller
|
||||
return view('Staff.notes.index', ['notes' => $notes]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Post A User Note
|
||||
*
|
||||
* @param Request $request
|
||||
* @param $username
|
||||
* @param $id
|
||||
* @return Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function postNote(Request $request, $username, $id)
|
||||
{
|
||||
$staff = auth()->user();
|
||||
$user = User::findOrFail($id);
|
||||
|
||||
$v = validator($request->all(), [
|
||||
'user_id' => 'required',
|
||||
'staff_id' => 'required|numeric',
|
||||
'message' => 'required',
|
||||
]);
|
||||
|
||||
$note = new Note();
|
||||
$note->user_id = $user->id;
|
||||
$note->staff_id = $staff->id;
|
||||
$note->message = $request->input('message');
|
||||
$note->save();
|
||||
|
||||
// Activity Log
|
||||
\LogActivity::addToLog("Staff Member {$staff->username} has added a note on {$user->username} account.");
|
||||
$v = validator($note->toArray(), [
|
||||
'user_id' => 'required',
|
||||
'staff_id' => 'required',
|
||||
'message' => 'required'
|
||||
]);
|
||||
|
||||
return redirect()->route('profile', ['username' => $user->username, 'id' => $user->id])->with(Toastr::success('Note Has Successfully Posted', 'Yay!', ['options']));
|
||||
if ($v->fails()) {
|
||||
return redirect()->route('profile', ['username' => $user->username, 'id' => $user->id])
|
||||
->with(Toastr::error($v->errors()->toJson(), 'Whoops!', ['options']));
|
||||
} else {
|
||||
$note->save();
|
||||
|
||||
// Activity Log
|
||||
\LogActivity::addToLog("Staff Member {$staff->username} has added a note on {$user->username} account.");
|
||||
|
||||
return redirect()->route('profile', ['username' => $user->username, 'id' => $user->id])
|
||||
->with(Toastr::success('Note Has Successfully Posted', 'Yay!', ['options']));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete A User Note
|
||||
*
|
||||
* @param $id
|
||||
* @return Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function deleteNote($id)
|
||||
{
|
||||
$note = Note::findOrFail($id);
|
||||
$note->delete();
|
||||
|
||||
return redirect()
|
||||
->back()
|
||||
return redirect()->back()
|
||||
->with(Toastr::success('Note Has Successfully Been Deleted', 'Yay!', ['options']));
|
||||
}
|
||||
|
||||
|
||||
+3
-9
@@ -23,17 +23,8 @@ class Note extends Model
|
||||
*/
|
||||
protected $table = "user_notes";
|
||||
|
||||
/**
|
||||
* Mass assignment fields
|
||||
*
|
||||
*/
|
||||
protected $fillable = [
|
||||
'user_id', 'staff_id', 'message'
|
||||
];
|
||||
|
||||
/**
|
||||
* Belongs to User
|
||||
*
|
||||
*/
|
||||
public function noteduser()
|
||||
{
|
||||
@@ -43,6 +34,9 @@ class Note extends Model
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Belongs to Staff User
|
||||
*/
|
||||
public function staffuser()
|
||||
{
|
||||
return $this->belongsTo(\App\User::class, "staff_id")->withDefault([
|
||||
|
||||
@@ -93,12 +93,19 @@
|
||||
<i class="fa fa-circle text-red" data-toggle="tooltip" title=""
|
||||
data-original-title="{{ trans('user.offline') }}"></i>
|
||||
@endif
|
||||
@if($user->getWarning() > 0)<i class="fa fa-exclamation-circle text-orange"
|
||||
aria-hidden="true" data-toggle="tooltip" title=""
|
||||
data-original-title="{{ trans('user.active-warning') }}"></i>@endif
|
||||
@if($user->notes->count() > 0 && auth()->user()->group->is_modo)<i
|
||||
class="fa fa-comment fa-beat" aria-hidden="true" data-toggle="tooltip"
|
||||
title="" data-original-title="{{ trans('user.staff-noted') }}"></i>@endif
|
||||
@if($user->getWarning() > 0)
|
||||
<i class="fa fa-exclamation-circle text-orange" aria-hidden="true"
|
||||
data-toggle="tooltip" title="" data-original-title="{{ trans('user.active-warning') }}">
|
||||
</i>
|
||||
@endif
|
||||
@if($user->notes->count() > 0 && auth()->user()->group->is_modo)
|
||||
<a href="{{ route('user_setting', ['username' => $user->username, 'id' => $user->id]) }}"
|
||||
class="edit">
|
||||
<i class="fa fa-comment fa-beat text-danger" aria-hidden="true" data-toggle="tooltip"
|
||||
title="" data-original-title="{{ trans('user.staff-noted') }}">
|
||||
</i>
|
||||
</a>
|
||||
@endif
|
||||
</h2>
|
||||
<h4>{{ trans('common.group') }}: <span class="badge-user text-bold"
|
||||
style="color:{{ $user->group->color }}; background-image:{{ $user->group->effect }};"><i
|
||||
|
||||
Reference in New Issue
Block a user