content_model.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. class Content_model extends Model{
  3. function content_new($post){
  4. if(Session::select('userid') == '66'){$status = '1';}else{$status = '0';}
  5. DB::insert('content',[
  6. 'title' => $post['title'],
  7. 'title_seo' => seo($post['title']),
  8. 'content' => $post['content'],
  9. 'homepage' => $post['homepage'],
  10. 'category' => $post['kategori'],
  11. 'keywords' => $post['keywords'],
  12. 'description' => $post['description'],
  13. 'author' => Session::select('userid'),
  14. 'status' => $status,
  15. ]);
  16. if(DB::affectedRows()){redirect(baseUrl().'admin/content');}
  17. }
  18. function content_list(){
  19. return DB::orderBy('id','DESC')
  20. ->get('content')
  21. ->result();
  22. }
  23. function content_edit($post){ return DB::where('id',$post)->get('content')->row(); }
  24. function content_update($post){
  25. $seo = yFunc::seo($post['baslik']);
  26. DB::where('id',$post['id'])->update('content',[
  27. 'title' => $post['baslik'],
  28. 'category' => $post['kategori'],
  29. 'title_seo' => $seo,
  30. 'content' => $post['icerik'],
  31. 'homapage' => $post['anasayfa'],
  32. 'keywords' => $post['keywords'],
  33. 'description' => $post['description'],
  34. ]);
  35. if(DB::affectedRows()){redirect(baseUrl().'admin/content');}
  36. }
  37. function kategoriEkle($post){
  38. DB::insert('kategori',[
  39. 'ust_kategori_id' => $post['ustkategori'],
  40. 'kategori' => $post['kategori'],
  41. 'kat_seo' => seo($post['kategori'])
  42. ]);
  43. if (DB::affectedRows()) {
  44. redirect('yonetim/kategori');
  45. }
  46. }
  47. }