Skip to content

Commit

Permalink
Add ratings
Browse files Browse the repository at this point in the history
  • Loading branch information
OniiCoder committed Sep 23, 2023
1 parent e253ea0 commit eb84c4a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 2 additions & 0 deletions resources/views/models/orders/form.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
wire:model="model.product_id"
label="Product"
help="This is the product being ordered."
:disabled="$model->product_id ? true : false"
>
<option value="0">-- Choose the Product</option>
@foreach($this->allProducts() as $data)
Expand All @@ -32,6 +33,7 @@
wire:model="model.organization_id"
label="Organization"
help="This is the organization placing the order or for which this order is being recorded."
:disabled="$model->organization_id ? true : false"
>
<option value="0">-- Choose the Organization</option>
@foreach($this->allOrganizations() as $data)
Expand Down
8 changes: 7 additions & 1 deletion src/Models/Driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,26 @@
use Illuminate\Support\Str;
use Spatie\Sluggable\SlugOptions;
use Vibraniuum\Pamtechoga\Models\Order;
use Vibraniuum\Pamtechoga\Models\Review;

class Driver extends LegoModel implements Searchable, Mediable
{
use HasMedia;

protected $table = 'pamtechoga_drivers';

protected $appends = ['trips_count'];
protected $appends = ['trips_count', 'ratings'];

public function getTripsCountAttribute()
{
return Order::where('driver_id', $this->id)->count();
}

public function getRatingsAttribute()
{
return Review::where('driver_id', $this->id)->avg('rating');
}

public static function icon(): string
{
return Icon::COLLECTION;
Expand Down

0 comments on commit eb84c4a

Please sign in to comment.