first change
This commit is contained in:
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