TahunProgramDetailRepositories.php 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. namespace App\Repositories;
  3. use App\Model\TahunProgramDetail as model;
  4. class TahunProgramDetailRepositories
  5. {
  6. private $model;
  7. public function __construct(model $model)
  8. {
  9. $this->model = $model;
  10. }
  11. public function get($id) {
  12. $getData = $this->model->where('id_tahun_program', $id);
  13. return $getData->get();
  14. }
  15. public function save($data) {
  16. $save = new $this->model;
  17. $save->id_tahun_program = $data['id_tahun_program'];
  18. $save->id_template_program = $data['id_template_program'];
  19. $save->unit = $data['unit'];
  20. $save->satuan = $data['satuan'];
  21. $save->status = $data['status'] ? $data['status'] : 1;
  22. // print_r($save->save());
  23. $save->save();
  24. return $save->fresh();
  25. }
  26. public function delete($id){
  27. $db = new $this->model;
  28. $getData = $db->where('id', $id);
  29. // $getData->update(['deleted_at' => date("Y-m-d h:i:s")]);
  30. $getData->delete();
  31. // return $getData->first();
  32. }
  33. }