63 lines
1.3 KiB
PHP
63 lines
1.3 KiB
PHP
<?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();
|
|
}
|
|
|
|
}
|