Merge branch 'master' of https://github.com/sebathefox/skolehjem-webapp
This commit is contained in:
commit
6979d0c0b4
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Resource;
|
||||||
|
use App\ResourceExtension;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Http\Response;
|
use Illuminate\Http\Response;
|
||||||
|
|
||||||
|
@ -23,9 +25,11 @@ class ResourceController extends Controller
|
||||||
*
|
*
|
||||||
* @return \Illuminate\Http\Response
|
* @return \Illuminate\Http\Response
|
||||||
*/
|
*/
|
||||||
public function index()
|
public function index(Request $request)
|
||||||
{
|
{
|
||||||
|
$resources = Resource::query()->paginate($request->input("limit", 20));
|
||||||
|
|
||||||
|
return Response::detect("resources.index", [ "resources" => $resources ]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -35,7 +39,7 @@ class ResourceController extends Controller
|
||||||
*/
|
*/
|
||||||
public function create()
|
public function create()
|
||||||
{
|
{
|
||||||
//
|
return Response::detect("resources.create");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -46,7 +50,33 @@ class ResourceController extends Controller
|
||||||
*/
|
*/
|
||||||
public function store(Request $request)
|
public function store(Request $request)
|
||||||
{
|
{
|
||||||
//
|
// $data = $request->validate([
|
||||||
|
// "" => ""
|
||||||
|
// ]);
|
||||||
|
|
||||||
|
// $resource = new Resource($data);
|
||||||
|
|
||||||
|
$file = $request->file("resource");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$resourceExtension = ResourceExtension::where("extension", "=", $file->extension())->first();
|
||||||
|
|
||||||
|
if($resourceExtension === null) {
|
||||||
|
//TODO: Create new resourceExtension!
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
|
$resource = new Resource();
|
||||||
|
|
||||||
|
$resource->resourceExtension()->save($resourceExtension);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$resource->save();
|
||||||
|
}
|
||||||
|
|
||||||
|
return Response::detect("resources.store");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -76,6 +76,7 @@ class UserController extends Controller
|
||||||
|
|
||||||
// Log::debug("CREATED USER [NOT PERSISTED YET]");
|
// Log::debug("CREATED USER [NOT PERSISTED YET]");
|
||||||
|
|
||||||
|
$user->assignRole([ "R1", "R2" ]);
|
||||||
$user->save();
|
$user->save();
|
||||||
|
|
||||||
// Log::debug("SAVED USER");
|
// Log::debug("SAVED USER");
|
||||||
|
|
|
@ -12,7 +12,9 @@ class CheckAuth
|
||||||
*
|
*
|
||||||
* @param \Illuminate\Http\Request $request
|
* @param \Illuminate\Http\Request $request
|
||||||
* @param \Closure $next
|
* @param \Closure $next
|
||||||
|
* @param $permissions
|
||||||
* @return mixed
|
* @return mixed
|
||||||
|
* @throws \Exception
|
||||||
*/
|
*/
|
||||||
public function handle($request, Closure $next, $permissions)
|
public function handle($request, Closure $next, $permissions)
|
||||||
{
|
{
|
||||||
|
|
|
@ -11,5 +11,11 @@ use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
class Resource extends Model
|
class Resource extends Model
|
||||||
{
|
{
|
||||||
//
|
public function resourceExtension() {
|
||||||
|
return $this->belongsTo("App\ResourceExtension");
|
||||||
|
}
|
||||||
|
|
||||||
|
public function resourceCategory() {
|
||||||
|
return $this->hasOneThrough("App\ResourceCategory", "App\ResourceExtension");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,5 +11,7 @@ use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
class ResourceCategory extends Model
|
class ResourceCategory extends Model
|
||||||
{
|
{
|
||||||
//
|
public function resourceExtensions() {
|
||||||
|
return $this->hasMany("App\ResourceExtension");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,5 +11,7 @@ use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
class ResourceExtension extends Model
|
class ResourceExtension extends Model
|
||||||
{
|
{
|
||||||
//
|
public function resources() {
|
||||||
|
return $this->hasMany("App\Resource");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,34 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class CreateResourceCategory extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::create('resource_categories', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->string("name", 60)->unique();
|
||||||
|
$table->text("description");
|
||||||
|
$table->string("slug", 255)->unique();
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('resource_categories');
|
||||||
|
}
|
||||||
|
}
|
|
@ -4,7 +4,7 @@ use Illuminate\Database\Migrations\Migration;
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
use Illuminate\Support\Facades\Schema;
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
class CreateResourceExtensions extends Migration
|
class CreateResourceExtension extends Migration
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Run the migrations.
|
* Run the migrations.
|
||||||
|
@ -15,9 +15,12 @@ class CreateResourceExtensions extends Migration
|
||||||
{
|
{
|
||||||
Schema::create('resource_extensions', function (Blueprint $table) {
|
Schema::create('resource_extensions', function (Blueprint $table) {
|
||||||
$table->id();
|
$table->id();
|
||||||
$table->string("extension")->unique();
|
$table->string("extension", 60)->unique();
|
||||||
$table->text("description");
|
$table->text("description");
|
||||||
|
$table->unsignedInteger("resource_category_id");
|
||||||
$table->timestamps();
|
$table->timestamps();
|
||||||
|
|
||||||
|
$table->foreign("resource_category_id")->references("id")->on("resource_categories");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class CreateResource extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::create('resources', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->string("filename")->unique();
|
||||||
|
$table->unsignedInteger("extension_id");
|
||||||
|
$table->timestamps();
|
||||||
|
|
||||||
|
$table->foreign("extension_id")->references("id")->on("resource_extensions");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('resources');
|
||||||
|
}
|
||||||
|
}
|
|
@ -17,6 +17,7 @@ class PermissionSeeder extends Seeder
|
||||||
/**
|
/**
|
||||||
* The USER specific permissions
|
* The USER specific permissions
|
||||||
*/
|
*/
|
||||||
|
"user.create" => "Creation of new user",
|
||||||
"user.list" => "Access to list the users.",
|
"user.list" => "Access to list the users.",
|
||||||
"user.show" => "Shows another user profile.",
|
"user.show" => "Shows another user profile.",
|
||||||
"user.edit" => "Allows editing of other users.",
|
"user.edit" => "Allows editing of other users.",
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
<label for="name_last">Efternavn:</label>
|
<label for="name_last">Efternavn:</label>
|
||||||
<input type="text" name="name_last" id="name_last" value="{{ $user->name_last }}" required>
|
<input type="text" name="name_last" id="name_last" value="{{ $user->name_last }}" required>
|
||||||
<label for="email">Email:</label>
|
<label for="email">Email:</label>
|
||||||
<input type="email" name="email" id="email" value="{{ $user->name_email }}" required>
|
<input type="email" name="email" id="email" value="{{ $user->email }}" required>
|
||||||
<label for="password1">Password:</label>
|
<label for="password1">Password:</label>
|
||||||
<input type="password" name="password" id="password1" value="" required>
|
<input type="password" name="password" id="password1" value="" required>
|
||||||
<label for="password2">Confirm Password:</label>
|
<label for="password2">Confirm Password:</label>
|
||||||
|
|
Loading…
Reference in New Issue