Commit d345d732 authored by dm141569's avatar dm141569 Committed by BZ

Initial commit, some work is already done

parents
APP_ENV=local
APP_KEY=SomeRandomString
DB_USERNAME=homestead
DB_PASSWORD=homestead
* text=auto
/.idea
/vendor
/node_modules
.env
.DS_Store
Thumbs.db
composer.lock
composer.phar
var elixir = require('laravel-elixir');
/*
|----------------------------------------------------------------
| Have a Drink!
|----------------------------------------------------------------
|
| Elixir provides a clean, fluent API for defining some basic
| Gulp tasks for your Laravel application. Elixir supports
| several common CSS, JavaScript and even testing tools!
|
*/
elixir(function(mix) {
mix.sass("bootstrap.scss")
.routes()
.events()
.phpUnit();
});
<?php namespace App\Console;
use Illuminate\Console\Command;
use Illuminate\Foundation\Inspiring;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument;
class InspireCommand extends Command {
/**
* The console command name.
*
* @var string
*/
protected $name = 'inspire';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Display an inspiring quote';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function fire()
{
$this->comment(PHP_EOL.Inspiring::quote().PHP_EOL);
}
}
<?php namespace App;
use Illuminate\Database\Eloquent\Model as Eloquent;
class Event extends Eloquent {
public function participants()
{
return $this->hasMany('App\Participant');
}
}
\ No newline at end of file
<?php namespace App\Http\Controllers\Auth;
use Illuminate\Routing\Controller;
use Illuminate\Contracts\Auth\Guard;
use App\Http\Requests\Auth\LoginRequest;
use App\Http\Requests\Auth\RegisterRequest;
/**
* @Middleware("guest", except={"logout"})
*/
class AuthController extends Controller {
/**
* The Guard implementation.
*
* @var Guard
*/
protected $auth;
/**
* Create a new authentication controller instance.
*
* @param Guard $auth
* @return void
*/
public function __construct(Guard $auth)
{
$this->auth = $auth;
}
/**
* Show the application registration form.
*
* @Get("auth/register")
*
* @return Response
*/
public function showRegistrationForm()
{
return view('auth.register');
}
/**
* Handle a registration request for the application.
*
* @Post("auth/register")
*
* @param RegisterRequest $request
* @return Response
*/
public function register(RegisterRequest $request)
{
// Registration form is valid, create user...
$this->auth->login($user);
return redirect('/');
}
/**
* Show the application login form.
*
* @Get("auth/login")
*
* @return Response
*/
public function showLoginForm()
{
return view('auth.login');
}
/**
* Handle a login request to the application.
*
* @Post("auth/login")
*
* @param LoginRequest $request
* @return Response
*/
public function login(LoginRequest $request)
{
if ($this->auth->attempt($request->only('email', 'password')))
{
return redirect('/');
}
return redirect('/auth/login')->withErrors([
'email' => 'These credentials do not match our records.',
]);
}
/**
* Log the user out of the application.
*
* @Get("auth/logout")
*
* @return Response
*/
public function logout()
{
$this->auth->logout();
return redirect('/');
}
}
<?php namespace App\Http\Controllers\Auth;
use Illuminate\Http\Request;
use Illuminate\Routing\Controller;
use Illuminate\Contracts\Auth\PasswordBroker;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
/**
* @Middleware("guest")
*/
class PasswordController extends Controller {
/**
* The password broker implementation.
*
* @var PasswordBroker
*/
protected $passwords;
/**
* Create a new password controller instance.
*
* @param PasswordBroker $passwords
* @return void
*/
public function __construct(PasswordBroker $passwords)
{
$this->passwords = $passwords;
}
/**
* Display the form to request a password reset link.
*
* @Get("password/email")
*
* @return Response
*/
public function showResetRequestForm()
{
return view('password.email');
}
/**
* Send a reset link to the given user.
*
* @Post("password/email")
*
* @param Request $request
* @return Response
*/
public function sendResetLink(Request $request)
{
switch ($response = $this->passwords->sendResetLink($request->only('email')))
{
case PasswordBroker::INVALID_USER:
return redirect()->back()->with('error', trans($response));
case PasswordBroker::RESET_LINK_SENT:
return redirect()->back()->with('status', trans($response));
}
}
/**
* Display the password reset view for the given token.
*
* @Get("password/reset")
*
* @param string $token
* @return Response
*/
public function showResetForm($token = null)
{
if (is_null($token))
{
throw new NotFoundHttpException;
}
return view('password.reset')->with('token', $token);
}
/**
* Reset the given user's password.
*
* @Post("password/reset")
*
* @param Request $request
* @return Response
*/
public function resetPassword(Request $request)
{
$credentials = $request->only(
'email', 'password', 'password_confirmation', 'token'
);
$response = $this->passwords->reset($credentials, function($user, $password)
{
$user->password = bcrypt($password);
$user->save();
});
switch ($response)
{
case PasswordBroker::INVALID_PASSWORD:
case PasswordBroker::INVALID_TOKEN:
case PasswordBroker::INVALID_USER:
return redirect()->back()->with('error', trans($response));
case PasswordBroker::PASSWORD_RESET:
return redirect()->to('/');
}
}
}
<?php namespace App\Http\Controllers;
use Illuminate\Routing\Controller;
use Illuminate\Support\Facades\Response;
use App\Event;
use DB;
class HomeController extends Controller {
/**
* Entry point for Frontend
*
* @Get("/public")
*/
public function view() {
return 'hello';
}
/**
* Get all events
*
* @Get("/")
*/
public function index()
{
// $events = DB::table('events')->get();
$events = Event::orderBy('time', 'asc')
->get()
->groupBy('date');
return Response::json($events);
}
/**
* Get event by id
*
* @Get("/{id}")
*/
public function show($id)
{
// $event = DB::table('events')->find($id);
// $participants = DB::table('participants')->where('event_id', $id)->get();
$event = Event::find($id);
/* $ps = $event->participants;
foreach ($ps as $p) {
echo $p->name;
} die(); */
User::with('images')->find($userId)
return Response::json($event);
}
/**
* Add new event
*
* @Post("/")
*/
public function create()
{
$success = DB::table('events')->insert([
'name' => 'Bernhard',
'contact' => 'mt111073@fhstp.ac.at',
'sport' => 'Laufen',
'date' => '2014-10-22',
'time' => '20:00:00',
'meeting_place' => 'FH Aula',
'updated_at' => '1413543572',
'created_at' => '1413543572'
]);
if ($success) {
return true;
} else {
return false;
}
}
/**
* Attend to an event
*
* @Post("/{id}")
*/
public function attend($id)
{
$success = DB::table('participants')->insert([
'event_id' => $id,
'name' => 'Teilnehmer 1',
'contact' => 'mt222222@fhstp.ac.at',
'updated_at' => '',
'created_at' => ''
]);
if ($success) {
return true;
} else {
return false;
}
}
}
<?php namespace App\Http\Middleware;
use Closure;
use Illuminate\Contracts\Auth\Guard;
use Illuminate\Contracts\Routing\Middleware;
use Illuminate\Contracts\Routing\ResponseFactory;
class AuthMiddleware implements Middleware {
/**
* The Guard implementation.
*
* @var Guard
*/
protected $auth;
/**
* The response factory implementation.
*
* @var ResponseFactory
*/
protected $response;
/**
* Create a new filter instance.
*
* @param Guard $auth
* @param ResponseFactory $response
* @return void
*/
public function __construct(Guard $auth,
ResponseFactory $response)
{
$this->auth = $auth;
$this->response = $response;
}
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if ($this->auth->guest())
{
if ($request->ajax())
{
return $this->response->make('Unauthorized', 401);
}
else
{
return $this->response->redirectGuest('auth/login');
}
}
return $next($request);
}
}
<?php namespace App\Http\Middleware;
use Closure;
use Illuminate\Contracts\Auth\Guard;
use Illuminate\Contracts\Routing\Middleware;
class BasicAuthMiddleware implements Middleware {
/**
* The Guard implementation.
*
* @var Guard
*/
protected $auth;
/**
* Create a new filter instance.
*
* @param Guard $auth
* @return void
*/
public function __construct(Guard $auth)
{
$this->auth = $auth;
}
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
return $this->auth->basic() ?: $next($request);
}
}
<?php namespace App\Http\Middleware;
use Closure;
use Illuminate\Contracts\Routing\Middleware;
use Illuminate\Session\TokenMismatchException;
class CsrfMiddleware implements Middleware {
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*
* @throws TokenMismatchException
*/
public function handle($request, Closure $next)
{
if ($request->method() == 'GET' || $this->tokensMatch($request))
{
return $next($request);
}
throw new TokenMismatchException;
}
/**
* Determine if the session and input CSRF tokens match.
*
* @param \Illuminate\Http\Request $request
* @return bool
*/
protected function tokensMatch($request)
{
return $request->session()->token() == $request->input('_token');
}
}
<?php namespace App\Http\Middleware;
use Closure;
use Illuminate\Contracts\Auth\Guard;
use Illuminate\Http\RedirectResponse;
use Illuminate\Contracts\Routing\Middleware;
class GuestMiddleware implements Middleware {
/**
* The Guard implementation.
*
* @var Guard
*/
protected $auth;
/**
* Create a new filter instance.
*
* @param Guard $auth
* @return void
*/
public function __construct(Guard $auth)
{
$this->auth = $auth;
}
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if ($this->auth->check())
{
return new RedirectResponse(url('/'));
}
return $next($request);
}
}
<?php namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Response;
use Illuminate\Contracts\Routing\Middleware;
use Illuminate\Contracts\Foundation\Application;
class MaintenanceMiddleware implements Middleware {