Skip to content

Commit

Permalink
Updated code quality
Browse files Browse the repository at this point in the history
  • Loading branch information
shiftenterdev committed Sep 12, 2023
1 parent 7e079fd commit 90cecd6
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 51 deletions.
21 changes: 4 additions & 17 deletions app/Events/CustomerRegistered.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
namespace App\Events;

use App\Models\Customer;
use Illuminate\Broadcasting\Channel;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Foundation\Events\Dispatchable;
Expand All @@ -16,26 +17,12 @@ class CustomerRegistered
{
use Dispatchable, InteractsWithSockets, SerializesModels;

/**
* @var Customer
*/
public $customer;

/**
* Create a new event instance.
*/
public function __construct(Customer $customer)
public function __construct(private readonly Customer $customer)
{
//
$this->customer = $customer;
}

/**
* Get the channels the event should broadcast on.
*
* @return \Illuminate\Broadcasting\Channel|array
*/
public function broadcastOn()

public function broadcastOn(): Channel
{
return new PrivateChannel('channel-name');
}
Expand Down
21 changes: 3 additions & 18 deletions app/Repository/Eloquent/BaseRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,15 @@

class BaseRepository implements EloquentRepositoryInterface
{
/**
* @var Model
*/
protected $model;

/**
* BaseRepository constructor.
*/
public function __construct(Model $model)
{
$this->model = $model;
}

public function __construct(protected readonly Model $model)
{}

public function create(array $attributes): Model
{
return $this->model->create($attributes);
}

/**
* @return Model
*/
public function find($id): ?Model
{
return $this->model->find($id);
Expand All @@ -49,9 +37,6 @@ public function update(array $attributes): bool
return $this->model->update($attributes);
}

/**
* @throws \Exception
*/
public function destroy(Model $model): ?bool
{
return $this->model->delete();
Expand Down
7 changes: 0 additions & 7 deletions app/Repository/Eloquent/CartRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,6 @@

class CartRepository extends BaseRepository implements CartRepositoryInterface
{
/**
* CartRepository constructor.
*/
public function __construct(Quote $model)
{
parent::__construct($model);
}

public function add(array $attributes): Quote
{
Expand Down
10 changes: 1 addition & 9 deletions app/Repository/Eloquent/UserRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,4 @@
use App\Repository\UserRepositoryInterface;

class UserRepository extends BaseRepository implements UserRepositoryInterface
{
/**
* UserRepository constructor.
*/
public function __construct(User $model)
{
parent::__construct($model);
}
}
{}

0 comments on commit 90cecd6

Please sign in to comment.