Skip to content

Commit

Permalink
Fix styling
Browse files Browse the repository at this point in the history
  • Loading branch information
frknasir authored and github-actions[bot] committed Oct 9, 2022
1 parent 20a9207 commit b069896
Show file tree
Hide file tree
Showing 14 changed files with 28 additions and 34 deletions.
10 changes: 4 additions & 6 deletions src/Review.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@

namespace StarfolkSoftware\Gauge;

use Illuminate\Contracts\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\MorphToMany;

abstract class Review extends Model
{
Expand Down Expand Up @@ -34,7 +32,7 @@ abstract class Review extends Model

/**
* Returns the table name.
*
*
* @return string
*/
public function getTable(): string
Expand All @@ -54,7 +52,7 @@ public function team()

/**
* Returns the rewiewable.
*
*
* @return \Illuminate\Database\Eloquent\Relations\MorphTo
*/
public function reviewable()
Expand All @@ -64,11 +62,11 @@ public function reviewable()

/**
* Returns the user.
*
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function user()
{
return $this->belongsTo(Gauge::userModel());
}
}
}
23 changes: 11 additions & 12 deletions src/Reviewable.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@ trait Reviewable
{
/**
* Leaves a review on the model.
*
* @param mixed $user
* @param int $rating
* @param string|null $comment
*
*
* @param mixed $user
* @param int $rating
* @param string|null $comment
* @return void
*/
public function review($user, int $rating, $comment = null)
Expand All @@ -38,7 +37,7 @@ public function review($user, int $rating, $comment = null)

/**
* Retrieves the reviews of the model.
*
*
* @return \Illuminate\Database\Eloquent\Relations\morphMany
*/
public function reviews()
Expand All @@ -48,7 +47,7 @@ public function reviews()

/**
* Returns the latest review.
*
*
* @return \Illuminate\Database\Eloquent\Casts\Attribute
*/
public function latestReview(): Attribute
Expand All @@ -58,7 +57,7 @@ public function latestReview(): Attribute

/**
* Calculates the avarage rating
*
*
* @return \Illuminate\Database\Eloquent\Casts\Attribute
*/
public function averageRating(): Attribute
Expand All @@ -68,7 +67,7 @@ public function averageRating(): Attribute

/**
* Calculates the total value of ratings
*
*
* @return \Illuminate\Database\Eloquent\Casts\Attribute
*/
public function totalRating(): Attribute
Expand All @@ -78,7 +77,7 @@ public function totalRating(): Attribute

/**
* Returns the reviews count
*
*
* @return \Illuminate\Database\Eloquent\Casts\Attribute
*/
public function reviewsCount()
Expand All @@ -88,11 +87,11 @@ public function reviewsCount()

/**
* Returns the count of the users that have rated.
*
*
* @return \Illuminate\Database\Eloquent\Casts\Attribute
*/
public function usersCount()
{
return Attribute::make(fn () => $this->reviews()->groupBy('user_id')->pluck('user_id')->count());
}
}
}
2 changes: 1 addition & 1 deletion src/TeamHasReviews.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ public function reviews()
{
return $this->hasMany(Gauge::reviewModel(), 'team_id');
}
}
}
3 changes: 1 addition & 2 deletions stubs/app/Models/Review.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@

class Review extends GaugeReview
{

}
}
3 changes: 1 addition & 2 deletions stubs/app/Providers/GaugeServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,5 @@ public function register()
*/
public function boot()
{

}
}
}
4 changes: 2 additions & 2 deletions stubs/database/factories/ReviewFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ public function definition()
return [
'team_id' => 1,
'user_id' => 1,
'reviewable_type' => "App\\Models\\Item",
'reviewable_type' => 'App\\Models\\Item',
'reviewable_id' => 1,
'rating' => 4,
'comment' => $this->faker->paragraph()
'comment' => $this->faker->paragraph(),
];
}
}
2 changes: 1 addition & 1 deletion tests/Mocks/Item.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ class Item extends Model
use Reviewable;

protected $table = 'items';
}
}
2 changes: 1 addition & 1 deletion tests/Mocks/Review.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ protected static function newFactory()
{
return ReviewFactory::new();
}
}
}
4 changes: 2 additions & 2 deletions tests/Mocks/ReviewFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ public function definition()
return [
'team_id' => 1,
'user_id' => 1,
'reviewable_type' => "App\\Models\\Item",
'reviewable_type' => 'App\\Models\\Item',
'reviewable_id' => 1,
'rating' => 4,
'comment' => $this->faker->paragraph()
'comment' => $this->faker->paragraph(),
];
}
}
2 changes: 1 addition & 1 deletion tests/Mocks/Team.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ class Team extends Model
use TeamHasReviews;

protected $table = 'teams';
}
}
2 changes: 1 addition & 1 deletion tests/Mocks/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
class User extends AuthUser
{
protected $table = 'users';
}
}
2 changes: 1 addition & 1 deletion tests/ReviewTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@
$review = Review::factory()->create();

$this->assertSoftDeleted($review->fresh);
});
});
2 changes: 1 addition & 1 deletion tests/TeamTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@
$team->reviews()->save($review);

expect($team->fresh()->reviews()->count())->toBe(1);
});
});
1 change: 0 additions & 1 deletion tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
use Orchestra\Testbench\TestCase as Orchestra;
use StarfolkSoftware\Gauge\GaugeServiceProvider;
Expand Down

0 comments on commit b069896

Please sign in to comment.