Skip to content

Commit

Permalink
PHP 8 and Laravel 8 support added
Browse files Browse the repository at this point in the history
  • Loading branch information
nazmulpcc committed Mar 25, 2021
1 parent 798a0e6 commit dd0ed08
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 6 deletions.
5 changes: 2 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,11 @@
}
],
"require": {
"php": "^5.6 || ^7.0 || ^7.1 || ^7.2",
"php": ">=5.6",
"illuminate/contracts": ">=5.1.0",
"illuminate/support": ">=5.1.0",
"sebastian-berc/repositories": "^1.0",
"nesbot/carbon": "^2.22",
"pusher/pusher-php-server": "^3.0",
"pusher/pusher-php-server": "^5.0",
"predis/predis": "~1.1.1",
"mpratt/embera": "^1.9"
},
Expand Down
58 changes: 58 additions & 0 deletions src/BaseRepository.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?php


namespace Nahid\Talk;


use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Log;

abstract class BaseRepository
{
/**
* @var Model
*/
protected $model = null;

public function __construct()
{
$this->model = $this->makeModel();
}

public function __call($method, $arguments)
{
return call_user_func_array([$this->model, $method], $arguments);
}

protected function makeModel()
{
$model = $this->takeModel();
if (is_null($this->model)) {
$this->model = new $model();
}

return $this->model;
}

abstract public function takeModel();

public function update($id, $data)
{
$model = $this->model->find($id);

return $model->update($data);
}


public function create($data)
{
return $this->model->create($data);
}

public function delete($id)
{
$model = $this->model->find($id);

return $model->delete();
}
}
3 changes: 2 additions & 1 deletion src/Conversations/ConversationRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

namespace Nahid\Talk\Conversations;

use Nahid\Talk\BaseRepository;
use SebastianBerc\Repositories\Repository;

class ConversationRepository extends Repository
class ConversationRepository extends BaseRepository
{
/*
* this method is default method for repository package
Expand Down
5 changes: 3 additions & 2 deletions src/Messages/MessageRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

namespace Nahid\Talk\Messages;

use Nahid\Talk\BaseRepository;
use SebastianBerc\Repositories\Repository;

class MessageRepository extends Repository
class MessageRepository extends BaseRepository
{
public function takeModel()
{
Expand Down Expand Up @@ -34,6 +35,6 @@ public function softDeleteMessage($messageId, $authUserId)
}

return (boolean) $this->update($message);

}
}

0 comments on commit dd0ed08

Please sign in to comment.