Skip to content

Commit

Permalink
Merge pull request #3 from romo4ko/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
romo4ko authored Oct 26, 2024
2 parents 44e169a + 9add34f commit 3dd5c64
Show file tree
Hide file tree
Showing 27 changed files with 803 additions and 7 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,3 @@ jobs:
composer install
php artisan migrate --force
php artisan cache:clear
npm ci
npm run build
32 changes: 32 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: CI-BUILD-TEST
on: [ push, pull_request ]

jobs:
coding-standard:
name: Coding Standard
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.3'
coverage: none

- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

- name: Cache composer dependencies
uses: actions/cache@v1
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-composer-

- name: Install dependencies
run: composer install --no-progress --no-suggest --prefer-dist --no-interaction --ignore-platform-reqs

- name: Check coding style
run: composer cs-check
23 changes: 23 additions & 0 deletions app/Models/Achievement.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

namespace App\Models;

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

class Achievement extends Model
{
use HasFactory;

protected $fillable = ['name', 'description', 'image_id'];

public function challenges()
{
return $this->hasMany(Challenge::class);
}

public function image()
{
return $this->belongsTo(Image::class);
}
}
18 changes: 18 additions & 0 deletions app/Models/Category.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace App\Models;

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

class Category extends Model
{
use HasFactory;

protected $fillable = ['name'];

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

namespace App\Models;

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

class Challenge extends Model
{
use HasFactory;

protected $fillable = [
'name',
'description',
'category_id',
'start_date',
'end_date',
'achievement_id',
'image_id'
];

public function users()
{
return $this->belongsToMany(User::class, 'users_challenges');
}

public function image()
{
return $this->belongsTo(Image::class);
}

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

public function achievement()
{
return $this->belongsTo(Achievement::class);
}
}
28 changes: 28 additions & 0 deletions app/Models/Image.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

namespace App\Models;

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

class Image extends Model
{
use HasFactory;

protected $fillable = ['image_path'];

public function users()
{
return $this->hasMany(User::class);
}

public function challenges()
{
return $this->hasMany(Challenge::class);
}

public function achievements()
{
return $this->hasMany(Achievement::class);
}
}
14 changes: 14 additions & 0 deletions app/Models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,24 @@ class User extends Authenticatable
*/
protected $fillable = [
'name',
'surname',
'email',
'password',
'about',
'image_id',
'is_admin'
];

public function challenges()
{
return $this->belongsToMany(Challenge::class, 'users_challenges');
}

public function image()
{
return $this->belongsTo(Image::class);
}

/**
* The attributes that should be hidden for serialization.
*
Expand Down
11 changes: 8 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
"laravel/sail": "^1.26",
"mockery/mockery": "^1.6",
"nunomaduro/collision": "^8.1",
"phpunit/phpunit": "^11.0.1"
"phpunit/phpunit": "^11.0.1",
"slevomat/coding-standard": "^8.15",
"squizlabs/php_codesniffer": "^3.10"
},
"autoload": {
"psr-4": {
Expand Down Expand Up @@ -50,7 +52,9 @@
"dev": [
"Composer\\Config::disableProcessTimeout",
"npx concurrently -c \"#93c5fd,#c4b5fd,#fb7185,#fdba74\" \"php artisan serve\" \"php artisan queue:listen --tries=1\" \"php artisan pail --timeout=0\" \"npm run dev\" --names=server,queue,logs,vite"
]
],
"cs-check": "phpcs",
"cs-fix": "phpcbf"
},
"extra": {
"laravel": {
Expand All @@ -63,7 +67,8 @@
"sort-packages": true,
"allow-plugins": {
"pestphp/pest-plugin": true,
"php-http/discovery": true
"php-http/discovery": true,
"dealerdirect/phpcodesniffer-composer-installer": true
}
},
"minimum-stability": "stable",
Expand Down
Loading

0 comments on commit 3dd5c64

Please sign in to comment.