Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function login(){
- $validator=Validator::make(Input::all(),array(
- 'email' => 'email|required',
- 'password' => 'required'
- ));
- if($validator->fails()){
- $messages = $validator->messages();
- $msg='';
- foreach ($messages->all() as $message)
- {
- $msg .= "<li>".$message."</li><br />";
- }
- return $msg;
- }
- else{
- $email = Input::get('email');
- $password = Input::get('password');
- $user=Auth::attempt(array(
- 'email' => $email,
- 'password' => $password,
- 'activated' => 1
- ),true);
- //die(Auth::user()->rule);
- if($user){
- //Auth::login($user);
- //die('1111111111');
- return 1;
- }
- else{
- return "يوجد خطأ فى البريد الإلكترونى أو كلمة المرور";
- }
- //die('11111111111111111');
- }
- }
- <?php
- use IlluminateAuthUserInterface;
- use IlluminateAuthRemindersRemindableInterface;
- use MmanosSocialSocialTrait;
- class User extends Eloquent implements UserInterface, RemindableInterface
- {
- use SocialTrait;
- protected $fillable = array('username','password','rule', 'email','active','phone','address','add_info','image','first_name','sec_name','country','area','baqah_id');
- /**
- * The database table used by the model.
- *
- * @var string
- */
- protected $table = 'users';
- public static function is_admin(){
- if(Auth::user()->rule=='admin'){
- return true;
- }
- return false;
- }
- /*
- one to one relation
- */
- /**
- * The attributes excluded from the model's JSON form.
- *
- * @var array
- */
- protected $hidden = array('password');
- /**
- * Get the unique identifier for the user.
- *
- * @return mixed
- */
- public function getAuthIdentifier()
- {
- return $this->getKey();
- }
- /**
- * Get the password for the user.
- *
- * @return string
- */
- public function getAuthPassword()
- {
- return $this->password;
- }
- /**
- * Get the e-mail address where password reminders are sent.
- *
- * @return string
- */
- public function getReminderEmail()
- {
- return $this->email;
- }
- public function getRememberToken()
- {
- return $this->remember_token;
- }
- public function setRememberToken($value)
- {
- $this->remember_token = $value;
- }
- public function getRememberTokenName()
- {
- return 'remember_token';
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement