Commit ff846673 authored by ZeMKI's avatar ZeMKI
Browse files

Initial commit

parents
<?php
namespace App\Providers;
use Illuminate\Support\Facades\Route;
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
class RouteServiceProvider extends ServiceProvider
{
/**
* This namespace is applied to your controller routes.
*
* In addition, it is set as the URL generator's root namespace.
*
* @var string
*/
protected $namespace = 'App\Http\Controllers';
/**
* Define your route model bindings, pattern filters, etc.
*
* @return void
*/
public function boot()
{
//
parent::boot();
}
/**
* Define the routes for the application.
*
* @return void
*/
public function map()
{
$this->mapApiRoutes();
$this->mapWebRoutes();
//
}
/**
* Define the "web" routes for the application.
*
* These routes all receive session state, CSRF protection, etc.
*
* @return void
*/
protected function mapWebRoutes()
{
Route::middleware('web')
->namespace($this->namespace)
->group(base_path('routes/web.php'));
}
/**
* Define the "api" routes for the application.
*
* These routes are typically stateless.
*
* @return void
*/
protected function mapApiRoutes()
{
Route::prefix('api')
->middleware('api')
->namespace($this->namespace)
->group(base_path('routes/api.php'));
}
}
<?php
namespace App\Providers;
use Laravel\Telescope\Telescope;
use Illuminate\Support\Facades\Gate;
use Laravel\Telescope\IncomingEntry;
use Laravel\Telescope\TelescopeApplicationServiceProvider;
class TelescopeServiceProvider extends TelescopeApplicationServiceProvider
{
/**
* Register any application services.
*
* @return void
*/
public function register()
{
// Telescope::night();
$this->hideSensitiveRequestDetails();
Telescope::filter(function (IncomingEntry $entry) {
if ($this->app->isLocal()) {
return true;
}
return $entry->isReportableException() ||
$entry->isFailedJob() ||
$entry->isScheduledTask() ||
$entry->hasMonitoredTag();
});
}
/**
* Prevent sensitive request details from being logged by Telescope.
*
* @return void
*/
protected function hideSensitiveRequestDetails()
{
if ($this->app->isLocal()) {
return;
}
Telescope::hideRequestParameters(['_token']);
Telescope::hideRequestHeaders([
'cookie',
'x-csrf-token',
'x-xsrf-token',
]);
}
/**
* Register the Telescope gate.
*
* This gate determines who can access Telescope in non-local environments.
*
* @return void
*/
protected function gate()
{
Gate::define('viewTelescope', function ($user) {
return in_array($user->email, [
'belli@uni-bremen.de'
]);
});
}
}
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Question extends Model
{
public function study()
{
return $this->hasOne('App\Study');
}
public function answers()
{
return $this->belongsToMany('App\Answer','interview_answers')->withTimestamps();
}
}
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Role extends Model
{
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'name', 'description'
];
/**
* The attributes that should be hidden for arrays.
*
* @var array
*/
/**
* The users that belong to the role.
*/
public function users()
{
return $this->belongsToMany('App\User','user_roles');
}
}
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Sorting extends Model
{
public function studies()
{
return $this->belongsToMany('App\Study','study_sorting')->withTimestamps();
}
}
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
use Auth;
use Storage;
class Study extends Model
{
protected $fillable = [
'description', 'user_id', 'Author'
];
// this is a recommended way to declare event handlers
public static function boot() {
parent::boot();
static::deleting(function($study) {
$tokens= Token::join('study_tokens','tokens.id','=','token_id')->where('study_id','=',$study->id)->pluck('tokens.id')->toArray();
$study->available_tokens()->detach($tokens);
$files = Token::whereIn('id',$tokens)->pluck('image_path');
foreach ($files as $f) {
Storage::delete($f);
}
foreach ($tokens as $t) {
Token::where('id',$t)->delete();
}
$answers= Answer::join('questions','questions.id','=','question_id')->where('study_id','=',$study->id)->pluck('answers.id')->toArray();
foreach ($study->questions as $q) {
$q->answers()->detach();
}
Answer::whereIn('id',$answers)->delete();
Question::where('study_id','=',$study->id)->delete();
$study->sortings()->detach();
$study->users()->detach();
});
}
/**
* return who created the study
* @return User instance
*/
public function creator()
{
return \App\User::find($this->user_id);
}
public function users()
{
return $this->belongsToMany('App\User','study_users')->withPivot('permission_id');
}
// we keep a third table to ensure we save data about the specific sorting in another table
public function sortings()
{
return $this->belongsToMany('App\Sorting','study_sortings')->withPivot('details')->withTimestamps();
}
public function interviews()
{
return $this->hasMany('App\Interview');
}
public function questions()
{
return $this->hasMany('App\Question');
}
public function permissions()
{
return $this->belongsToMany('App\Permission','study_users')->withPivot('permission_id');
}
public function allowedtointerview()
{
return ($this->permissions()->where('user_id','=',Auth::user()->id)->whereNotIn('permission_id',['1'])->first());
}
public function iseditable()
{
return ($this->interviews()->count() == 0);
}
public function available_tokens()
{
return $this->belongsToMany('App\Token','study_tokens')->withTimestamps();
}
}
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Token extends Model
{
protected $fillable = [
'name', 'image_path','author'
];
public function answers()
{
return $this->belongsToMany('App\Answer','interview_tokens')->withTimestamps();
}
public function studies()
{
return $this->belongsToMany('App\Study','study_tokens')->withTimestamps();
}
public function author()
{
return $this->belongsTo('App\User')->withTimestamps();
}
}
<?php
namespace App;
use Illuminate\Notifications\Notifiable;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Database\Eloquent\SoftDeletes;
use DB;
use Auth;
class User extends Authenticatable
{
use Notifiable;
use SoftDeletes;
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'name', 'email', 'password','supervised_by'
];
/**
* The attributes that should be hidden for arrays.
*
* @var array
*/
protected $hidden = [
'password', 'remember_token',
];
/**
* The attributes that should be mutated to dates.
*
* @var array
*/
protected $dates = ['deleted_at'];
/**
* The role that belong to the user.
*/
public function roles()
{
return $this->belongsToMany('App\Role','user_roles');
}
public function studies()
{
return $this->belongsToMany('App\Study','study_users')->withPivot(['permission_id']);
}
public function studiesforedit()
{
return $this->belongsToMany('App\Study','study_users')->withPivot(['permission_id'])->where('permission_id','<>',1);
}
public function permissions()
{
return $this->belongsToMany('App\Permission','study_users')->withPivot('permission_id');
}
public function cancreateusers()
{
return ($this->permissions()->where('user_id','=',Auth::user()->id)->where('permission_id','=',2)->first());
}
}
#!/usr/bin/env php
<?php
define('LARAVEL_START', microtime(true));
/*
|--------------------------------------------------------------------------
| Register The Auto Loader
|--------------------------------------------------------------------------
|
| Composer provides a convenient, automatically generated class loader
| for our application. We just need to utilize it! We'll require it
| into the script here so that we do not have to worry about the
| loading of any our classes "manually". Feels great to relax.
|
*/
require __DIR__.'/vendor/autoload.php';
$app = require_once __DIR__.'/bootstrap/app.php';
/*
|--------------------------------------------------------------------------
| Run The Artisan Application
|--------------------------------------------------------------------------
|
| When we run the console application, the current CLI command will be
| executed in this console and the response sent back to a terminal
| or another output device for the developers. Here goes nothing!
|
*/
$kernel = $app->make(Illuminate\Contracts\Console\Kernel::class);
$status = $kernel->handle(
$input = new Symfony\Component\Console\Input\ArgvInput,
new Symfony\Component\Console\Output\ConsoleOutput
);
/*
|--------------------------------------------------------------------------
| Shutdown The Application
|--------------------------------------------------------------------------
|
| Once Artisan has finished running, we will fire off the shutdown events
| so that any final work may be done by the application before we shut
| down the process. This is the last thing to happen to the request.
|
*/
$kernel->terminate($input, $status);
exit($status);
<?php
/*
|--------------------------------------------------------------------------
| Create The Application
|--------------------------------------------------------------------------
|
| The first thing we will do is create a new Laravel application instance
| which serves as the "glue" for all the components of Laravel, and is
| the IoC container for the system binding all of the various parts.
|
*/
$app = new Illuminate\Foundation\Application(
realpath(__DIR__.'/../')
);
/*
|--------------------------------------------------------------------------
| Bind Important Interfaces
|--------------------------------------------------------------------------
|
| Next, we need to bind some important interfaces into the container so
| we will be able to resolve them when needed. The kernels serve the
| incoming requests to this application from both the web and CLI.
|
*/
$app->singleton(
Illuminate\Contracts\Http\Kernel::class,
App\Http\Kernel::class
);
$app->singleton(
Illuminate\Contracts\Console\Kernel::class,
App\Console\Kernel::class
);
$app->singleton(
Illuminate\Contracts\Debug\ExceptionHandler::class,
App\Exceptions\Handler::class
);
/*
|--------------------------------------------------------------------------
| Return The Application
|--------------------------------------------------------------------------
|
| This script returns the application instance. The instance is given to
| the calling script so we can separate the building of the instances
| from the actual running of the application and sending responses.
|
*/
return $app;
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
"php": "^7.1.3",
"barryvdh/laravel-dompdf": "^0.8.3",
"barryvdh/laravel-translation-manager": "^0.5.1",
"fideloper/proxy": "^4.0",
"intervention/image": "^2.4",
"laravel/framework": "5.7.*",
"laravel/telescope": "^1.0",
"laravel/tinker": "^1.0"
},
"require-dev": {
"barryvdh/laravel-debugbar": "^3.2",
"beyondcode/laravel-dump-server": "^1.0",
"filp/whoops": "^2.0",
"fzaninotto/faker": "^1.4",
"mockery/mockery": "^1.0",
"nunomaduro/collision": "^2.0",
"phpunit/phpunit": "^7.0",
"wnx/laravel-stats": "^1.8"
},
"autoload": {
"classmap": [
"database/seeds",
"database/factories"
],
"psr-4": {
"App\\": "app/"
}
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"extra": {
"laravel": {
"dont-discover": [
]
}
},
"scripts": {
"post-root-package-install": [
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"@php artisan key:generate"
],
"post-autoload-dump": [
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
"@php artisan package:discover"
]
},
"config": {
"preferred-install": "dist",
"sort-packages": true,
"optimize-autoloader": true
},
"minimum-stability": "dev",
"prefer-stable": true
}
This diff is collapsed.
<?php
return [
/*
|--------------------------------------------------------------------------
| Application Name
|--------------------------------------------------------------------------
|
| This value is the name of your application. This value is used when the
| framework needs to place the application's name in a notification or
| any other location as required by the application or its packages.
|
*/
'name' => env('APP_NAME', 'Mesort'),
/*