Files
firefly-iii/app/Http/Controllers/Admin/HomeController.php

77 lines
2.3 KiB
PHP
Raw Normal View History

2016-04-03 07:07:17 +02:00
<?php
/**
* HomeController.php
2017-10-21 08:40:00 +02:00
* Copyright (c) 2017 thegrumpydictator@gmail.com
2016-04-03 07:07:17 +02:00
*
2017-10-21 08:40:00 +02:00
* This file is part of Firefly III.
*
2017-10-21 08:40:00 +02:00
* Firefly III is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Firefly III is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
2017-12-17 14:41:58 +01:00
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
2016-04-03 07:07:17 +02:00
*/
declare(strict_types=1);
2016-04-03 07:07:17 +02:00
namespace FireflyIII\Http\Controllers\Admin;
2017-09-27 15:45:55 +02:00
use FireflyIII\Events\AdminRequestedTestMessage;
2016-04-03 07:07:17 +02:00
use FireflyIII\Http\Controllers\Controller;
2017-12-19 19:25:50 +01:00
use FireflyIII\Http\Middleware\IsDemoUser;
use FireflyIII\Http\Middleware\IsSandStormUser;
2018-07-09 19:24:08 +02:00
use FireflyIII\User;
2017-09-27 15:45:55 +02:00
use Illuminate\Http\Request;
use Log;
2016-04-03 07:07:17 +02:00
/**
2017-11-15 12:25:49 +01:00
* Class HomeController.
2016-04-03 07:07:17 +02:00
*/
class HomeController extends Controller
{
2017-12-11 10:26:44 +01:00
/**
* ConfigurationController constructor.
*/
public function __construct()
{
parent::__construct();
2017-12-19 19:25:50 +01:00
$this->middleware(IsDemoUser::class)->except(['index']);
$this->middleware(IsSandStormUser::class)->except(['index']);
2017-12-11 10:26:44 +01:00
}
2016-04-03 07:07:17 +02:00
/**
2016-11-26 10:39:05 +01:00
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
2016-04-03 07:07:17 +02:00
*/
public function index()
{
2018-04-02 15:10:40 +02:00
$title = (string)trans('firefly.administration');
2016-04-03 07:07:17 +02:00
$mainTitleIcon = 'fa-hand-spock-o';
2018-06-21 18:58:27 +02:00
$sandstorm = 1 === (int)getenv('SANDSTORM');
2016-04-03 07:07:17 +02:00
2018-06-21 18:58:27 +02:00
return view('admin.index', compact('title', 'mainTitleIcon', 'sandstorm'));
2016-04-03 07:07:17 +02:00
}
2017-09-27 15:45:55 +02:00
/**
* @param Request $request
*
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
*/
public function testMessage(Request $request)
{
2018-07-09 19:24:08 +02:00
/** @var User $user */
$user = auth()->user();
2017-09-27 15:45:55 +02:00
$ipAddress = $request->ip();
Log::debug(sprintf('Now in testMessage() controller. IP is %s', $ipAddress));
2018-07-09 19:24:08 +02:00
event(new AdminRequestedTestMessage($user, $ipAddress));
2018-04-22 17:10:11 +02:00
session()->flash('info', (string)trans('firefly.send_test_triggered'));
2017-10-05 11:49:06 +02:00
2017-09-27 15:45:55 +02:00
return redirect(route('admin.index'));
}
2016-04-08 17:54:25 +02:00
}