UserModel.php 642 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php namespace App\Models;
  2. /**
  3. * @author Andy Brookes
  4. * @author Andy Brookes <andybrookestar at gmail dot com>
  5. */
  6. use CodeIgniter\Database\ConnectionInterface;
  7. use CodeIgniter\Model;
  8. class UserModel extends Model
  9. {
  10. protected $limit;
  11. protected $offset;
  12. protected $table = 'admin';
  13. protected $primaryKey = 'Id';
  14. protected $allowedFields = ['Name','Password','Role'];
  15. public function getUser()
  16. {
  17. $this->limit=1;
  18. return $this->findAll($this->limit);
  19. }
  20. public function getOne($role)
  21. {
  22. return $this->asArray()
  23. ->where(['Role' => $role])
  24. ->first();
  25. }
  26. }