HelpService.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. namespace App\Modules\Help\Services;
  3. use App\Modules\Help\Models\Help;
  4. class HelpService
  5. {
  6. public static function getEnableHelpList(){
  7. return Help::where('is_enabled',1)->select('id','title','is_enabled','created_at','updated_at')->orderBy('created_at','desc')->get();
  8. }
  9. public static function getAllHelpList(array $where=[]){
  10. if($where){
  11. return Help::select('id','title','content','is_enabled','created_at','updated_at')->where($where)->orderBy('id')->paginate(20);
  12. }else{
  13. return Help::select('id','title','content','is_enabled','created_at','updated_at')->orderBy('id')->paginate(20);
  14. }
  15. }
  16. public static function updateHelp(int $id,array $data){
  17. return Help::where('id',$id)->update($data);
  18. }
  19. public static function enableHelpStatus(int $id,int $status){
  20. return self::updateHelp($id,['is_enabled'=>$status]);
  21. }
  22. public static function create($data){
  23. return Help::create($data);
  24. }
  25. public static function getById(int $id){
  26. return Help::where('id',$id)->select('id','title','content','is_enabled','created_at','updated_at')->first();
  27. }
  28. }