mirror of
https://github.com/HDInnovations/UNIT3D-Community-Edition.git
synced 2026-01-26 13:59:29 -06:00
129 lines
3.3 KiB
PHP
129 lines
3.3 KiB
PHP
<?php
|
|
/**
|
|
* NOTICE OF LICENSE.
|
|
*
|
|
* UNIT3D Community Edition is open-sourced software licensed under the GNU Affero General Public License v3.0
|
|
* The details is bundled with this project in the file LICENSE.txt.
|
|
*
|
|
* @project UNIT3D Community Edition
|
|
*
|
|
* @author HDVinnie <hdinnovations@protonmail.com>
|
|
* @license https://www.gnu.org/licenses/agpl-3.0.en.html/ GNU Affero General Public License v3.0
|
|
*/
|
|
|
|
namespace App\Http\Controllers\Staff;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Models\ChatStatus;
|
|
use App\Repositories\ChatRepository;
|
|
use Illuminate\Http\Request;
|
|
|
|
class ChatStatusController extends Controller
|
|
{
|
|
/**
|
|
* @var ChatRepository
|
|
*/
|
|
private $chat;
|
|
|
|
/**
|
|
* ChatController Constructor.
|
|
*
|
|
* @param ChatRepository $chat
|
|
*/
|
|
public function __construct(ChatRepository $chat)
|
|
{
|
|
$this->chat = $chat;
|
|
}
|
|
|
|
/**
|
|
* Chat Management.
|
|
*
|
|
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
|
*/
|
|
public function index()
|
|
{
|
|
$chatstatuses = $this->chat->statuses();
|
|
|
|
return view('Staff.chat.status.index', [
|
|
'chatstatuses' => $chatstatuses,
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* Store A New Chat Status.
|
|
*
|
|
* @param \Illuminate\Http\Request $request
|
|
*
|
|
* @return \Illuminate\Http\RedirectResponse
|
|
*/
|
|
public function store(Request $request)
|
|
{
|
|
$chatstatus = new ChatStatus();
|
|
$chatstatus->name = $request->input('name');
|
|
$chatstatus->color = $request->input('color');
|
|
$chatstatus->icon = $request->input('icon');
|
|
|
|
$v = validator($chatstatus->toArray(), [
|
|
'name' => 'required',
|
|
'color' => 'required',
|
|
'icon' => 'required',
|
|
]);
|
|
|
|
if ($v->fails()) {
|
|
return redirect()->route('staff.statuses.index')
|
|
->withErrors($v->errors());
|
|
}
|
|
$chatstatus->save();
|
|
|
|
return redirect()->route('staff.statuses.index')
|
|
->withSuccess('Chat Status Successfully Added');
|
|
}
|
|
|
|
/**
|
|
* Update A Chat Status.
|
|
*
|
|
* @param \Illuminate\Http\Request $request
|
|
* @param \App\Models\ChatStatus $id
|
|
*
|
|
* @return \Illuminate\Http\RedirectResponse
|
|
*/
|
|
public function update(Request $request, $id)
|
|
{
|
|
$chatstatus = ChatStatus::findOrFail($id);
|
|
$chatstatus->name = $request->input('name');
|
|
$chatstatus->color = $request->input('color');
|
|
$chatstatus->icon = $request->input('icon');
|
|
|
|
$v = validator($chatstatus->toArray(), [
|
|
'name' => 'required',
|
|
'color' => 'required',
|
|
'icon' => 'required',
|
|
]);
|
|
|
|
if ($v->fails()) {
|
|
return redirect()->route('staff.statuses.index')
|
|
->withErrors($v->errors());
|
|
}
|
|
$chatstatus->save();
|
|
|
|
return redirect()->route('staff.statuses.index')
|
|
->withSuccess('Chat Status Successfully Modified');
|
|
}
|
|
|
|
/**
|
|
* Delete A Chat Status.
|
|
*
|
|
* @param \App\Models\ChatStatus $id
|
|
*
|
|
* @return \Illuminate\Http\RedirectResponse
|
|
*/
|
|
public function destroy($id)
|
|
{
|
|
$chatstatus = ChatStatus::findOrFail($id);
|
|
$chatstatus->delete();
|
|
|
|
return redirect()->route('staff.statuses.index')
|
|
->withSuccess('Chat Status Successfully Deleted');
|
|
}
|
|
}
|