Advertisement
Guest User

Untitled

a guest
Jan 16th, 2016
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.85 KB | None | 0 0
  1. public function login(){
  2.  
  3. $validator=Validator::make(Input::all(),array(
  4.  
  5. 'email' => 'email|required',
  6.  
  7. 'password' => 'required'
  8.  
  9. ));
  10.  
  11.  
  12.  
  13. if($validator->fails()){
  14.  
  15. $messages = $validator->messages();
  16.  
  17. $msg='';
  18.  
  19. foreach ($messages->all() as $message)
  20.  
  21. {
  22.  
  23. $msg .= "<li>".$message."</li><br />";
  24.  
  25. }
  26.  
  27. return $msg;
  28.  
  29. }
  30.  
  31. else{
  32.  
  33. $email = Input::get('email');
  34.  
  35. $password = Input::get('password');
  36.  
  37. $user=Auth::attempt(array(
  38.  
  39. 'email' => $email,
  40.  
  41. 'password' => $password,
  42.  
  43. 'activated' => 1
  44.  
  45. ),true);
  46. //die(Auth::user()->rule);
  47. if($user){
  48. //Auth::login($user);
  49. //die('1111111111');
  50. return 1;
  51.  
  52. }
  53.  
  54. else{
  55.  
  56. return "يوجد خطأ فى البريد الإلكترونى أو كلمة المرور";
  57.  
  58. }
  59. //die('11111111111111111');
  60. }
  61.  
  62. }
  63.  
  64. <?php
  65. use IlluminateAuthUserInterface;
  66. use IlluminateAuthRemindersRemindableInterface;
  67. use MmanosSocialSocialTrait;
  68.  
  69. class User extends Eloquent implements UserInterface, RemindableInterface
  70. {
  71. use SocialTrait;
  72.  
  73. protected $fillable = array('username','password','rule', 'email','active','phone','address','add_info','image','first_name','sec_name','country','area','baqah_id');
  74. /**
  75. * The database table used by the model.
  76. *
  77. * @var string
  78. */
  79. protected $table = 'users';
  80.  
  81. public static function is_admin(){
  82. if(Auth::user()->rule=='admin'){
  83. return true;
  84. }
  85. return false;
  86. }
  87.  
  88. /*
  89. one to one relation
  90. */
  91. /**
  92. * The attributes excluded from the model's JSON form.
  93. *
  94. * @var array
  95. */
  96. protected $hidden = array('password');
  97.  
  98. /**
  99. * Get the unique identifier for the user.
  100. *
  101. * @return mixed
  102. */
  103. public function getAuthIdentifier()
  104. {
  105. return $this->getKey();
  106. }
  107.  
  108. /**
  109. * Get the password for the user.
  110. *
  111. * @return string
  112. */
  113. public function getAuthPassword()
  114. {
  115. return $this->password;
  116. }
  117.  
  118.  
  119. /**
  120. * Get the e-mail address where password reminders are sent.
  121. *
  122. * @return string
  123. */
  124. public function getReminderEmail()
  125. {
  126. return $this->email;
  127. }
  128. public function getRememberToken()
  129. {
  130. return $this->remember_token;
  131. }
  132.  
  133. public function setRememberToken($value)
  134. {
  135. $this->remember_token = $value;
  136. }
  137.  
  138. public function getRememberTokenName()
  139. {
  140. return 'remember_token';
  141. }
  142. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement