add file model

This commit is contained in:
j3d1 2019-11-28 04:52:53 +01:00
parent 53037d26af
commit acf701da70
10 changed files with 96 additions and 9 deletions

5
.gitignore vendored
View file

@ -4,4 +4,7 @@ Homestead.json
Homestead.yaml Homestead.yaml
.env .env
/public/docs /public/docs
/resources/docs /resources/docs
composer.lock
composer.phar

View file

@ -13,7 +13,7 @@ class Container extends Model
* @var array * @var array
*/ */
protected $fillable = [ protected $fillable = [
'cid' 'cid', 'name'
]; ];
/** /**
@ -22,4 +22,4 @@ class Container extends Model
* @var array * @var array
*/ */
protected $hidden = []; protected $hidden = [];
} }

View file

@ -13,7 +13,7 @@ class Event extends Model
* @var array * @var array
*/ */
protected $fillable = [ protected $fillable = [
'eid', 'name', 'short_name' 'eid', 'name', 'slug', 'begin', 'end', 'pre_begin', 'post_end'
]; ];
/** /**
@ -22,4 +22,4 @@ class Event extends Model
* @var array * @var array
*/ */
protected $hidden = []; protected $hidden = [];
} }

25
app/File.php Normal file
View file

@ -0,0 +1,25 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class File extends Model
{
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'hash', 'iid'
];
/**
* The attributes excluded from the model's JSON form.
*
* @var array
*/
protected $hidden = [];
}

View file

@ -3,17 +3,19 @@
namespace App; namespace App;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
class Item extends Model class Item extends Model
{ {
use SoftDeletes;
/** /**
* The attributes that are mass assignable. * The attributes that are mass assignable.
* *
* @var array * @var array
*/ */
protected $fillable = [ protected $fillable = [
'iid', 'bezeichnung', 'wann', 'wo', 'eid', 'cid' 'iid', 'item_uid', 'bezeichnung', 'wann', 'wo', 'eid', 'cid'
]; ];
/** /**
@ -22,4 +24,4 @@ class Item extends Model
* @var array * @var array
*/ */
protected $hidden = []; protected $hidden = [];
} }

View file

@ -4,6 +4,8 @@ namespace App\Providers;
use Illuminate\Support\ServiceProvider; use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\Schema;
class AppServiceProvider extends ServiceProvider class AppServiceProvider extends ServiceProvider
{ {
/** /**
@ -15,4 +17,9 @@ class AppServiceProvider extends ServiceProvider
{ {
// //
} }
public function boot()
{
Schema::defaultStringLength(191);
}
} }

View file

@ -14,10 +14,18 @@ class CreateEventsTable extends Migration
public function up() public function up()
{ {
Schema::create('events', function (Blueprint $table) { Schema::create('events', function (Blueprint $table) {
$table->charset = 'utf8';
$table->collation = 'utf8_unicode_ci';
$table->bigIncrements('eid'); $table->bigIncrements('eid');
$table->string('name'); $table->string('name');
$table->string('short_name'); $table->string('slug');
$table->timestamps(); $table->timestamps();
$table->timestamp('start')->nullable();
$table->timestamp('end')->nullable();
$table->timestamp('pre_start')->nullable();
$table->timestamp('post_end')->nullable();
$table->unique('slug','uslug');
}); });
} }

View file

@ -15,6 +15,7 @@ class CreateContainersTable extends Migration
{ {
Schema::create('containers', function (Blueprint $table) { Schema::create('containers', function (Blueprint $table) {
$table->bigIncrements('cid'); $table->bigIncrements('cid');
$table->string('name');
$table->timestamps(); $table->timestamps();
}); });
} }

View file

@ -15,12 +15,16 @@ class CreateItemsTable extends Migration
{ {
Schema::create('items', function (Blueprint $table) { Schema::create('items', function (Blueprint $table) {
$table->bigIncrements('iid'); $table->bigIncrements('iid');
$table->unsignedBigInteger('item_uid');
$table->string('bezeichnung'); $table->string('bezeichnung');
$table->string('wann'); $table->timestamp('wann');
$table->string('wo'); $table->string('wo');
$table->unsignedBigInteger('eid'); $table->unsignedBigInteger('eid');
$table->unsignedBigInteger('cid'); $table->unsignedBigInteger('cid');
$table->timestamps(); $table->timestamps();
$table->softDeletes();
$table->unique(['eid', 'item_uid']);
$table->foreign('eid')->references('eid')->on('events'); $table->foreign('eid')->references('eid')->on('events');
$table->foreign('cid')->references('cid')->on('containers'); $table->foreign('cid')->references('cid')->on('containers');

View file

@ -0,0 +1,37 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateFilesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('files', function (Blueprint $table) {
$table->bigIncrements('id');
$table->timestamps();
$table->unsignedBigInteger('iid');
$table->string('hash');
$table->foreign('iid')->references('iid')->on('items');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('file');
}
}