Initial commit of testapi

This commit is contained in:
2025-06-20 13:33:07 +02:00
commit a455aba1d5
377 changed files with 30566 additions and 0 deletions
+23
View File
@@ -0,0 +1,23 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use App\Models\User;
class ApiAdmins extends Model
{
use HasFactory;
protected $table = 'apiadmins';
protected $fillable = [
'user_id'
];
public function user(): BelongsTo {
return $this->belongsTo(User::class, 'user_id');
}
}
+17
View File
@@ -0,0 +1,17 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class ApiKeys extends Model
{
use HasFactory;
protected $table = 'apikeys';
protected $fillable = [
'category',
'key'
];
}
+28
View File
@@ -0,0 +1,28 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
class Department extends Model
{
use HasFactory;
protected $fillable = [
'name',
];
/**
* The projects that belong to the department.
*/
public function projects(): BelongsToMany {
return $this->belongsToMany(
Project::class,
'department_project',
'department_id',
'project_id'
);
}
}
+49
View File
@@ -0,0 +1,49 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\HasMany;
class Project extends Model
{
use HasFactory;
protected $fillable = [
'project_name',
'project_number',
];
/**
* The profiles associated with this project.
*/
public function profiles(): BelongsToMany {
return $this->belongsToMany(
SmartdokProfile::class,
'project_smartdok_profile',
'project_id',
'smartdok_profile_id'
);
}
/**
* The departments associated with this project.
*/
public function departments(): BelongsToMany {
return $this->belongsToMany(
Department::class,
'department_project',
'project_id',
'department_id'
);
}
/**
* The work hours entries linked to this project.
*/
public function workHours(): HasMany {
return $this->hasMany(WorkHour::class, 'project_id');
}
}
+42
View File
@@ -0,0 +1,42 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\HasMany;
class SmartdokProfile extends Model
{
use HasFactory;
protected $table = 'smartdok_profiles';
public $incrementing = false;
protected $keyType = 'string';
protected $fillable = [
'id',
'username',
'name',
];
/**
* The projects that belong to the profile.
*/
public function projects(): BelongsToMany {
return $this->belongsToMany(
Project::class,
'project_smartdok_profile',
'smartdok_profile_id',
'project_id'
);
}
/**
* The work hours entries for the profile.
*/
public function workHours(): HasMany {
return $this->hasMany(WorkHour::class, 'user_id', 'id');
}
}
+55
View File
@@ -0,0 +1,55 @@
<?php
namespace App\Models;
// use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\HasOne;
use Illuminate\Notifications\Notifiable;
use Laravel\Sanctum\HasApiTokens;
use App\Models\ApiAdmins;
class User extends Authenticatable
{
/** @use HasFactory<\Database\Factories\UserFactory> */
use HasApiTokens, HasFactory, Notifiable;
/**
* The attributes that are mass assignable.
*
* @var list<string>
*/
protected $fillable = [
'name',
'email',
'password',
];
/**
* The attributes that should be hidden for serialization.
*
* @var list<string>
*/
protected $hidden = [
'password',
'remember_token',
];
/**
* Get the attributes that should be cast.
*
* @return array<string, string>
*/
protected function casts(): array {
return [
'email_verified_at' => 'datetime',
'password' => 'hashed',
];
}
public function apiAdmin(): HasOne {
return $this->hasOne(ApiAdmins::class, 'user_id');
}
}
+41
View File
@@ -0,0 +1,41 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
class WorkHour extends Model
{
use HasFactory;
protected $table = 'work_hours';
protected $fillable = [
'user_id',
'project_id',
'ordinary_hours',
'work_date',
'comment'
];
protected $casts = [
'work_date' => 'date',
];
/**
* The profile that owns the work hour entry.
*/
public function user(): BelongsTo {
return $this->belongsTo(SmartdokProfile::class, 'user_id', 'id');
}
/**
* The project linked to this work hour entry.
*/
public function project(): BelongsTo {
return $this->belongsTo(Project::class, 'project_id');
}
}