Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

De 3 musqltiers #286

Open
wants to merge 11 commits into
base: development
Choose a base branch
from
10 changes: 5 additions & 5 deletions app/Category.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
* @property \App\WorkplaceLearningPeriod $InternshipPeriods
* @property \App\Cohort|null $cohort
* @property \App\EducationProgram|null $educationProgram
* @property \App\LearningActivityProducing $learningactivitiesproducing
* @property \App\GenericLearningActivity $genericlearningactivity
* @property \App\WorkplaceLearningPeriod $workplaceLearningPeriod
*
* @method static \Illuminate\Database\Eloquent\Builder|\App\Category whereCategoryId($value)
Expand Down Expand Up @@ -74,9 +74,9 @@ public function InternshipPeriods()
return $this->belongsTo(\App\WorkplaceLearningPeriod::class, 'wplp_id', 'wplp_id');
}

public function learningactivitiesproducing()
{
return $this->belongsTo(\App\LearningActivityProducing::class, 'category_id', 'category_id');
public function genericLearningActivity()
{ //TODO:: HasMany?
return $this->hasMany(GenericLearningActivity::class, 'category_id', 'category_id');
}

public function getCategoryLabel()
Expand All @@ -92,7 +92,7 @@ public function setCategoryLabel($label): void
// Relations for query builder
public function getRelationships()
{
return ['cohort', 'educationProgram', 'InternshipPeriods', 'learningactivitiesproducing'];
return ['cohort', 'educationProgram', 'InternshipPeriods', 'genericLearningActivity'];
}

public function workplaceLearningPeriod(): BelongsTo
Expand Down
24 changes: 13 additions & 11 deletions app/Chain.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@
*
* @property int $id
* @property string $name
* @property Collection|LearningActivityProducing[] $activities
// * @property Collection|LearningActivityProducing[] $activities
* @property int $status
* @property int $wplp_id
* @property \App\WorkplaceLearningPeriod $workplaceLearningPeriod
* @property \App\GenericLearningActivity $genericLearningActivity
*
* @method static \Illuminate\Database\Eloquent\Builder|\App\Chain whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Chain whereName($value)
Expand All @@ -36,22 +37,23 @@ class Chain extends Model
public const STATUS_BUSY = 0;
public const STATUS_FINISHED = 1;

public function activities(): HasMany
public function genericLearningActivity(): HasMany
{
return $this->hasMany(LearningActivityProducing::class, 'chain_id', 'id')->orderBy('date', 'ASC');
return $this->hasMany(GenericLearningActivity::class, 'chains_id', 'id')
//->orderBy('date', 'ASC');
}

public function workplaceLearningPeriod(): BelongsTo
{
return $this->belongsTo(WorkplaceLearningPeriod::class, 'wplp_id', 'wplp_id');
}

public function hours(): float
{
return array_reduce($this->activities->all(), function (float $hours, LearningActivityProducing $activity) {
$hours += $activity->duration;

return $hours;
}, 0);
}
// public function hours(): float
// {
// return array_reduce($this->activities->all(), function (float $hours, LearningActivityProducing $activity) {
// $hours += $activity->duration;
//
// return $hours;
// }, 0);
// }
}
10 changes: 5 additions & 5 deletions app/ChainManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ public function updateChain(Chain $chain, ?string $name, ?int $status): void

$chain->save();
}

public function attachActivity(LearningActivityProducing $learningActivityProducing, Chain $chain): void
//TODO:: Veranderd
public function attachActivity(GenericLearningActivity $genericLearningActivity, Chain $chain): void
{
$learningActivityProducing->chain()->associate($chain);
$genericLearningActivity->chain()->associate($chain);
}

public function detachActivity(LearningActivityProducing $learningActivityProducing): void
public function detachActivity(GenericLearningActivity $genericLearningActivity): void
{
$learningActivityProducing->chain()->dissociate();
$genericLearningActivity->chain()->dissociate();
}

/**
Expand Down
72 changes: 72 additions & 0 deletions app/Column.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<?php

namespace App;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasOne;

/**
* Class Column
* @package App
*
* @property int $column_id
* @property int $gla_id
* @property int $fieldtype_id
* @property string $name
* @property string $column_options
*
* @method static \Illuminate\Database\Eloquent\Builder|\App\Column whereColumn_id($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Column whereGla_id($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Column whereFieldtype_id($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Column whereName($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Column whereColumn_options($value)
*
* @method static \Illuminate\Database\Eloquent\Builder|\App\Column newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Column newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Column query()
*/

class Column extends Model
{

protected $table = 'column';

//public $timestamps = false;

protected $primaryKey = 'column_id';

// Default
protected $fillable = [
'column_id',
'gla_id',
'fieldtype_id',
'name',
'column_options'
];

public function genericLearningActivity(): BelongsTo
{
return $this->belongsTo(GenericLearningActivity::class, 'gla_id', 'gla_id');
}

public function fieldType(): BelongsTo
{
return $this->belongsTo(Fieldtype::class, 'fieldtype_id', 'fieldtype');
}

public function column_data(): HasOne
{
return $this->hasOne(column_data::class, 'column_id', 'column_id');
}

// Relations for query builder
public function getRelationships(): array
{
return [
'column_data',
'fieldType',
'genericLearningActivity'
];
}
}
56 changes: 56 additions & 0 deletions app/Column_data.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?php

namespace App;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasOne;

/**
* Class column_data
* @package App
*
* @property int $column_data_id
* @property int $column_id
* @property string $data_type
* @property string $data_as_string
*
* @method static \Illuminate\Database\Eloquent\Builder|\App\Column_data whereColumn_data_id($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Column_data whereColumn_id($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Column_data whereData_type($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Column_data whereData_as_string($value)
*
* @method static \Illuminate\Database\Eloquent\Builder|\App\Column_data newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Column_data newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Column_data query()
*/
class column_data extends Model
{
protected $table = 'column_data';

//public $timestamps = false;

protected $primaryKey = 'column_data_id';

// Default
protected $fillable = [
'column_data_id',
'column_id',
'data_type',
'data_as_string'
];

public function column(): BelongsTo
{
return $this->belongsTo(Column::class, 'column_id', 'column_id');
}


// Relations for query builder
public function getRelationships(): array
{
return [
'column',
];
}
}
14 changes: 10 additions & 4 deletions app/Competence.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* @property int|null $cohort_id
* @property \App\Cohort|null $cohort
* @property \App\EducationProgram|null $educationProgram
* @property \Illuminate\Database\Eloquent\Collection|\App\LearningActivityActing[] $learningActivityActing
* @property \Illuminate\Database\Eloquent\Collection|\App\GenericLearningActivity[] $genericLearningActivity
*
* @method static \Illuminate\Database\Eloquent\Builder|\App\Competence whereCohortId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Competence whereCompetenceId($value)
Expand Down Expand Up @@ -59,15 +59,21 @@ public function educationProgram()
return $this->belongsTo(\App\EducationProgram::class, 'educationprogram_id', 'ep_id');
}

public function learningActivityActing()
public function genericLearningActivity()
{
return $this->belongsToMany(\App\LearningActivityActing::class, 'activityforcompetence', 'competence_id', 'learningactivity_id');
return $this->belongsToMany(\App\GenericLearningActivity::class, 'activityforcompetence', 'competence_id', 'genericlearningactivity_id');
}

// public function learningActivityActing()
// {
// return $this->belongsToMany(\App\LearningActivityActing::class, 'activityforcompetence', 'competence_id', 'learningactivity_id');
// }

// Relations for query builder

public function getRelationships()
{
return ['cohort', 'educationProgram', 'learningActivityActing'];
return ['cohort', 'educationProgram', 'genericLearningActivity'];
}

public function getLabel(): string
Expand Down
8 changes: 4 additions & 4 deletions app/Difficulty.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*
* @property string $difficulty_label
* @property int $difficulty_id
* @property \Illuminate\Database\Eloquent\Collection|\App\LearningActivityProducing[] $learningActivityProducing
* @property \Illuminate\Database\Eloquent\Collection|\App\LearningActivityProducing[] $genericLearningActivity
*
* @method static \Illuminate\Database\Eloquent\Builder|\App\Difficulty whereDifficultyId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Difficulty whereDifficultyLabel($value)
Expand All @@ -37,15 +37,15 @@ class Difficulty extends Model
'difficulty_label',
];

public function learningActivityProducing(): HasMany
public function genericLearningActivity(): HasMany
{
return $this->hasMany(\App\LearningActivityProducing::class, 'difficulty_id', 'difficulty_id');
return $this->hasMany(\App\GenericLearningActivity::class, 'difficulty_id', 'difficulty_id');
}

// Relations for query builder
public function getRelationships()
{
return ['learningActivityProducing'];
return ['genericLearningActivity'];
}

public function isEasy(): bool
Expand Down
10 changes: 5 additions & 5 deletions app/Evidence.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@
* @mixin \Eloquent
*
* @property int $id
* @property int $learning_activity_acting_id
* @property int $genericlearningactivity_id
* @property string $filename
* @property string $mime
* @property \App\LearningActivityActing $learningActivity
* @property \App\GenericLearningActivity $genericLearningActivity
*
* @method static \Illuminate\Database\Eloquent\Builder|\App\Evidence whereDiskFilename($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Evidence whereFilename($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Evidence whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Evidence whereLearningActivityActingId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Evidence whereGenericLearningActivityId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Evidence whereMime($value)
*
* @property string $disk_filename
Expand All @@ -41,8 +41,8 @@ class Evidence extends Model
'mime',
];

public function learningActivity(): BelongsTo
public function genericLearningActivity(): BelongsTo
{
return $this->belongsTo(LearningActivityActing::class, 'learning_activity_acting_id', 'laa_id');
return $this->belongsTo(GenericLearningActivity::class, 'genericlearningactivity_id', 'gla_id');
}
}
12 changes: 6 additions & 6 deletions app/Feedback.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
/**
* App\Feedback.
*
* @property learningActivityProducing $learningActivityProducing
* @property genericLearningActivity $genericLearningActivity
* @property int $fb_id
* @property string $notfinished
* @property string $initiative
Expand All @@ -27,11 +27,11 @@
* @property string $nextstep_self
* @property string $support_needed_wp
* @property string $support_needed_ed
* @property int $learningactivity_id
* @property int $genericlearningactivity_id
*
* @method static Builder|Feedback whereFbId($value)
* @method static Builder|Feedback whereInitiative($value)
* @method static Builder|Feedback whereLearningactivityId($value)
* @method static Builder|Feedback whereGenericLearningActivityId($value)
* @method static Builder|Feedback whereNextstepSelf($value)
* @method static Builder|Feedback whereNotfinished($value)
* @method static Builder|Feedback whereProgressSatisfied($value)
Expand Down Expand Up @@ -61,7 +61,7 @@ class Feedback extends Model
// Default
protected $fillable = [
'fb_id',
'learningactivity_id',
'genericlearningactivity_id',
'notfinished',
'initiative',
'progress_satisfied',
Expand All @@ -81,8 +81,8 @@ public function isSaved(): bool
return $this->notfinished !== '';
}

public function learningActivityProducing(): BelongsTo
public function genericLearningActivity(): BelongsTo
{
return $this->belongsTo(LearningActivityProducing::class, 'learningactivity_id', 'lap_id');
return $this->belongsTo(GenericLearningActivity::class, 'genericlearningactivity_id', 'gla_id');
}
}
Loading