Skip to content

Commit

Permalink
Merge pull request #30 from Alain-Kay/database-shema
Browse files Browse the repository at this point in the history
database shema
  • Loading branch information
curtisdelicata authored Mar 11, 2024
2 parents 0608c3c + e9128bb commit d7f7ea1
Show file tree
Hide file tree
Showing 19 changed files with 691 additions and 0 deletions.
102 changes: 102 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
COMPOSE_FILE=docker-compose.yml
BASE_IMAGE_DOCKERFILE=./.docker/prod/base/Dockerfile
IMAGE_REGISTRY=familytree365
IMAGE_TAG=latest

APP_NAME="Liberu Cms"
APP_ENV=local
APP_KEY=base64:2DzJhWedD2gRkRfhK/ENYEBBiQJACDRVfiYg0NdImvw=
APP_DEBUG=true
APP_URL=http://localhost

OWNER_COMPANY_ID=1
DB_TENANT_DATABASE=tenant

LOG_CHANNEL=stack
LOG_DEPRECATIONS_CHANNEL=null
LOG_LEVEL=debug

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=cms
DB_USERNAME=root
DB_PASSWORD=

BROADCAST_DRIVER=redis
CACHE_DRIVER=array
FILESYSTEM_DISK=local
SESSION_DRIVER=file
SESSION_LIFETIME=120
SESSION_DOMAIN=localhost

CACHE_LIFETIME=60

LOGIN_ATTEMPTS_PER_MINUTE=5
PASSWORD_LIFETIME=0
PASSWORD_MIN_LENGTH=6
PASSWORD_MIXED_CASE=0
PASSWORD_NUMERIC=0
PASSWORD_SPECIAL=0

REDIS_HOST=127.0.0.1
REDIS_PREFIX=
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_MAILER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS=null
MAIL_FROM_NAME="${APP_NAME}"

MAILGUN_DOMAIN=
MAILGUN_SECRET=
MAILGUN_ENDPOINT=api.mailgun.net

AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=
AWS_USE_PATH_STYLE_ENDPOINT=false

PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=mt1

FACEBOOK_CLIENT_ID=
FACEBOOK_CLIENT_SECRET=
FACEBOOK_REDIRECT_URI=

GOOGLE_CLIENT_ID=
GOOGLE_CLIENT_SECRET=
GOOGLE_REDIRECT_URI=

GITHUB_CLIENT_ID=
GITHUB_CLIENT_SECRET=
GITHUB_REDIRECT_URI=

STRIPE_KEY=XXX
STRIPE_SECRET=XXX

SENTRY_DSN=

TELESCOPE_ENABLED=0

ENSO_API_TOKEN=

WIKITREE_API=

TINY_MCE_API_KEY=

SANCTUM_STATEFUL_DOMAINS=localhost,127.0.0.1,127.0.0.1:8000,127.0.0.1:3000,localhost:3000,localhost:8080,::1

GELATO_API_KEY=x

LARAVEL_ECHO_SERVER_REDIS_HOST=127.0.0.1
LARAVEL_ECHO_SERVER_REDIS_PORT=6379
LARAVEL_ECHO_SERVER_DEBUG=true
28 changes: 28 additions & 0 deletions app/Models/Activation.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

/**
* @property int $id
* @property int $user_id
* @property string $token
* @property string $ip_address
* @property string $created_at
* @property string $updated_at
*/
class Activation extends Model
{
/**
* The "type" of the auto-incrementing ID.
*
* @var string
*/
protected $keyType = 'integer';

/**
* @var array
*/
protected $fillable = ['user_id', 'token', 'ip_address', 'created_at', 'updated_at'];
}
31 changes: 31 additions & 0 deletions app/Models/Author.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class Author extends Model
{
use HasFactory;

protected $primaryKey = 'author_id';

protected $fillable = [
'author_name',
'author_last_name',
'author_email',
'author_phone',
];

public function contents()
{
return $this->hasMany(Content::class);
}

public function comments()
{
return $this->hasMany(Comment::class);
}

}
31 changes: 31 additions & 0 deletions app/Models/Comment.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class Comment extends Model
{
use HasFactory;

protected $primaryKey = 'comment_id';

protected $fillable = [
'content_id',
'author_id',
'comment_body',
];

public function content()
{
return $this->belongsTo(Content::class);
}

public function author()
{
return $this->belongsTo(Author::class);
}


}
19 changes: 19 additions & 0 deletions app/Models/Company.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace App\Models;

use App\Traits\CreatedBy;
use LaravelLiberu\Companies\Models\Company as CoreCompany;

class Company extends CoreCompany
{
use CreatedBy;

protected $fillable = [
'privacy',
'name',
'email',
'is_tenant',
'status',
];
}
44 changes: 44 additions & 0 deletions app/Models/Content.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class Content extends Model
{
use HasFactory;

protected $primaryKey = 'content_id';

protected $fillable = [
'content_title',
'content_body',
'author_id',
'published_date',
'content_type',
'category_id',
'content_status',
'featured_image_url',
];

public function author()
{
return $this->belongsTo(Author::class);
}

public function category()
{
return $this->belongsTo(ContentCategory::class);
}

public function comments()
{
return $this->hasMany(Comment::class);
}

public function tag()
{
return $this->belongsToMany(Tag::class);
}
}
17 changes: 17 additions & 0 deletions app/Models/ContentCategory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class ContentCategory extends Model
{
use HasFactory;

protected $primaryKey = 'content_category_id';

protected $fillable = [
'content_category_name',
];
}
86 changes: 86 additions & 0 deletions app/Models/Person.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
<?php

namespace App\Models;

use App\Traits\TenantConnectionResolver;
use File;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Support\Facades\Auth;
use LaravelLiberu\People\Models\Person as CorePerson;

class Person extends CorePerson
{
use HasFactory;
use TenantConnectionResolver;

/**
* The attributes that should be mutated to dates.
*
* @var array
*/
protected $casts = [
'deleted_at' => 'datetime',
'birthday' => 'datetime',
'deathday' => 'datetime',
'burial_day' => 'datetime',
'chan' => 'datetime',
];

protected $guarded = ['id'];

protected $fillable = [
'gid',
'givn',
'surn',
'sex',
'child_in_family_id',
'description',
'titl', 'name', 'appellative', 'email', 'phone', 'birthday',
'deathday', 'burial_day', 'bank', 'bank_account', 'chan', 'rin', 'resn', 'rfn', 'afn',
];

public function fullname(): string
{
return $this->givn . ' ' . $this->surn;
}

public function getSex(): string
{
if ($this->sex === 'F') {
return 'Female';
}

return 'Male';
}

public static function getList()
{
$persons = self::get();
$result = [];
foreach ($persons as $person) {
$result[$person->id] = $person->fullname();
}

return collect($result);
}

public static function bootUpdatedBy()
{
self::creating(fn($model) => $model->setUpdatedBy());

self::updating(fn($model) => $model->setUpdatedBy());
}

public function setUpdatedBy()
{
if (!is_dir(storage_path('app/public'))) {
// dir doesn't exist, make it
File::makeDirectory(storage_path() . '/app/public', 0777, true);
}

file_put_contents(storage_path('app/public/file.txt'), $this->connection);
if ($this->connection !== 'tenant' && Auth::check()) {
$this->updated_by = Auth::id();
}
}
}
22 changes: 22 additions & 0 deletions app/Models/Tag.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class Tag extends Model
{
use HasFactory;

protected $primaryKey = 'tag_id';

protected $fillable = [
'tag_name',
];

public function contents()
{
return $this->belongsToMany(Content::class);
}
}
Loading

0 comments on commit d7f7ea1

Please sign in to comment.