Files
UNIT3D/app/Http/Controllers/Staff/NoteController.php
HDVinnie 2da7207d2b (Update) Refactor General and Staff Controllers
- Remove all facades use besides mail
- Use Dependency Injection for Illuminate\Http\Request
- use helpers for auth, cache, validator, and more to rid of facades use
- use $request->input() over $request->get()
- use $request->isMethod('POST') over $request->getMethod('POST')
- general cleanup
2018-03-15 12:32:40 -04:00

58 lines
1.6 KiB
PHP

<?php
/**
* NOTICE OF LICENSE
*
* UNIT3D is open-sourced software licensed under the GNU General Public License v3.0
* The details is bundled with this project in the file LICENSE.txt.
*
* @project UNIT3D
* @license https://www.gnu.org/licenses/agpl-3.0.en.html/ GNU Affero General Public License v3.0
* @author HDVinnie
*/
namespace App\Http\Controllers\Staff;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Note;
use App\User;
use \Toastr;
class NoteController extends Controller
{
/**
* User Staff Notes System
*
*
*/
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.");
return redirect()->route('profil', ['username' => $user->username, 'id' => $user->id])->with(Toastr::success('Your Staff Note Has Successfully Posted', 'Yay!', ['options']));
}
public function getNotes()
{
$notes = Note::orderBy('created_at', 'DESC')->get();
return view('Staff.notes.index', ['notes' => $notes]);
}
}