first change
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Content\Repositories;
|
||||
|
||||
use Modules\Content\Interfaces\ContentCategoryInterface;
|
||||
use Modules\Content\Models\ContentCategory;
|
||||
|
||||
class ContentCategoryRepository implements ContentCategoryInterface
|
||||
{
|
||||
public function findAll()
|
||||
{
|
||||
return ContentCategory::when(true, function ($query) {
|
||||
|
||||
})->latest()->paginate(20);
|
||||
}
|
||||
|
||||
public function getContentCategoryById($ContentCategoryId)
|
||||
{
|
||||
return ContentCategory::findOrFail($ContentCategoryId);
|
||||
}
|
||||
|
||||
public function getContentCategoryList()
|
||||
{
|
||||
return ContentCategory::pluck('title', 'id');
|
||||
}
|
||||
|
||||
public function delete($ContentCategoryId)
|
||||
{
|
||||
ContentCategory::destroy($ContentCategoryId);
|
||||
}
|
||||
|
||||
public function create($ContentCategoryDetails)
|
||||
{
|
||||
return ContentCategory::create($ContentCategoryDetails);
|
||||
}
|
||||
|
||||
public function update($ContentCategoryId, array $newDetails)
|
||||
{
|
||||
return ContentCategory::whereId($ContentCategoryId)->update($newDetails);
|
||||
}
|
||||
|
||||
public function pluck(){
|
||||
return ContentCategory::pluck('title', 'id');
|
||||
}
|
||||
public function count(){
|
||||
return ContentCategory::count();
|
||||
}
|
||||
}
|
62
Modules/Content/app/Repositories/ContentRepository.php
Normal file
62
Modules/Content/app/Repositories/ContentRepository.php
Normal file
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Content\Repositories;
|
||||
|
||||
use Modules\Content\Interfaces\ContentInterface;
|
||||
use Modules\Content\Models\Content;
|
||||
|
||||
class ContentRepository implements ContentInterface
|
||||
{
|
||||
|
||||
public function findAll()
|
||||
{
|
||||
return Content::all();
|
||||
}
|
||||
|
||||
public function findAllUpcomingScheduledContent()
|
||||
{
|
||||
|
||||
return Content::when(true, function($query){
|
||||
if (auth()->user()->hasRole('employee')) {
|
||||
$query->where("createdby", auth()->user()->id);
|
||||
}
|
||||
})
|
||||
->where('status', 12)
|
||||
->whereDate('release_date', '>=', now())
|
||||
->get();
|
||||
}
|
||||
|
||||
public function getContentById($ContentId)
|
||||
{
|
||||
return Content::findOrFail($ContentId);
|
||||
}
|
||||
|
||||
public function getContentByEmail($email)
|
||||
{
|
||||
return Content::where('email', $email)->first();
|
||||
}
|
||||
|
||||
public function delete($ContentId)
|
||||
{
|
||||
Content::destroy($ContentId);
|
||||
}
|
||||
|
||||
public function create($ContentDetails)
|
||||
{
|
||||
return Content::create($ContentDetails);
|
||||
}
|
||||
|
||||
public function update($ContentId, array $newDetails)
|
||||
{
|
||||
return Content::whereId($ContentId)->update($newDetails);
|
||||
}
|
||||
public function pluck()
|
||||
{
|
||||
return Content::pluck('title', 'id');
|
||||
}
|
||||
public function count()
|
||||
{
|
||||
return Content::count();
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user