add and delete news from admin dashboard #52
This commit is contained in:
29
app/Repositories/NewsRepository.php
Normal file
29
app/Repositories/NewsRepository.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repositories;
|
||||
|
||||
use App\Models\News;
|
||||
use App\Repositories\Traits\CacheableRepository;
|
||||
use Prettus\Repository\Contracts\CacheableInterface;
|
||||
|
||||
class NewsRepository extends BaseRepository implements CacheableInterface
|
||||
{
|
||||
use CacheableRepository;
|
||||
|
||||
public function model()
|
||||
{
|
||||
return News::class;
|
||||
}
|
||||
|
||||
/**
|
||||
* Latest news items
|
||||
* @param int $count
|
||||
* @return mixed
|
||||
*/
|
||||
public function getLatest($count=5)
|
||||
{
|
||||
return $this->orderBy('created_at', 'desc')
|
||||
->with(['user'])
|
||||
->paginate($count);
|
||||
}
|
||||
}
|
||||
@@ -54,7 +54,9 @@ class PirepRepository extends BaseRepository
|
||||
$where['user_id'] = $user->id;
|
||||
}
|
||||
|
||||
$pireps = $this->orderBy('created_at', 'desc')->findWhere($where)->count();
|
||||
$pireps = $this->orderBy('created_at', 'desc')
|
||||
->findWhere($where, ['id'])
|
||||
->count();
|
||||
return $pireps;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,10 @@ class UserRepository extends BaseRepository
|
||||
'state' => UserState::PENDING,
|
||||
];
|
||||
|
||||
$users = $this->orderBy('created_at', 'desc')->findWhere($where)->count();
|
||||
$users = $this->orderBy('created_at', 'desc')
|
||||
->findWhere($where, ['id'])
|
||||
->count();
|
||||
|
||||
return $users;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user