Example #1
0
 public static function setSocialUser($userInfo)
 {
     $userSocialNetwork = SocialNetwork::firstOrNew(array('id_user_in_network' => $userInfo['id']));
     if (Auth::check()) {
         $userSocialNetwork['user_id'] = Auth::user()->getAuthIdentifier();
     }
     if ($userSocialNetwork['user_id'] != null) {
         $user = User::find($userSocialNetwork['user_id']);
         if ($user['photo'] == '/img/default_user.png') {
             $user->photo = $userInfo['photo'];
             $user->save();
         }
     } else {
         $user = new User();
         $user->first_name = $userInfo['first_name'];
         $user->last_name = $userInfo['last_name'];
         $user->photo = $userInfo['photo'];
         $user->save();
     }
     $userSocialNetwork->user_id = $user['id'];
     $userSocialNetwork->setAttribute('id_user_in_network', $userInfo['id']);
     $userSocialNetwork->setAttribute('first_name', $userInfo['first_name']);
     $userSocialNetwork->setAttribute('last_name', $userInfo['last_name']);
     $userSocialNetwork->setAttribute('link', $userInfo['link']);
     $userSocialNetwork->setAttribute('photo', $userInfo['photo']);
     $userSocialNetwork->setAttribute('social_net_name', $userInfo['social_net_name']);
     $userSocialNetwork->save();
     return $user;
 }
Example #2
0
 public function testBackRedirectAfterRegistration()
 {
     User::truncate();
     $this->call('GET', '/vanguard');
     $this->call('POST', '/registration', array('first_name' => 'Вася', 'last_name' => 'Пупкин', 'email' => '*****@*****.**', 'password' => '123123'));
     $this->assertEquals(1, User::count());
     $user = User::find(1);
     $this->assertEquals('Вася', $user->first_name);
     $this->assertRedirectedTo('/vanguard');
 }
 public static function editUser($userData)
 {
     $user = User::find($userData['id']);
     $user->first_name = $userData['first_name'];
     $user->last_name = $userData['last_name'];
     $user->photo = $userData['photo'];
     $user->email = $userData['email'];
     $user->save();
     Auth::login($user);
     return $user;
 }
 public function postRegistration()
 {
     $data = Input::all();
     $validator = Validator::make($data, WorkWithInput::rulesForInputRegistration(), WorkWithInput::messagesForErrors());
     $userMessage = $validator->messages()->first();
     $title = 'Ошибка';
     if ($userMessage != null) {
         return Redirect::to('registration')->with('userMessage', $userMessage)->with('userMessageTitle', $title)->withInput(Input::except('password'));
     }
     $user = new User();
     $user->first_name = Input::get('first_name');
     $user->last_name = Input::get('last_name');
     $user->email = Input::get('email');
     $user->password = Hash::make(Input::get('password'));
     $user->save();
     Auth::login($user);
     $userMessage = "Спасибо за регистрацию";
     $title = 'Регистрация прошла успешно';
     return Redirect::to($this->getBackUrl())->with('userMessage', $userMessage)->with('userMessageTitle', $title);
 }
 /**
  * @return string
  */
 public function changeRole()
 {
     $userN = Input::get('userN');
     $roleN = Input::get('roleN');
     $val = Input::get('val');
     $user = User::find($userN);
     if ($val == "true") {
         $user->roles()->attach($roleN);
     } else {
         $user->roles()->detach($roleN);
     }
     $res = "Изменения произошли для пользователя с порядковым номером  {$userN}";
     return $res;
 }
    public static function linkForUserProfile()
    {
        $first_name = Auth::user()->first_name;
        $last_name = Auth::user()->last_name;
        $link_admin = '';
        $user = User::find(Auth::user()->getAuthIdentifier());
        foreach ($user->roles as $role) {
            if ($role->role == "admin") {
                $link_admin = '<li class="' . LinksInMenu::isActive(URL::route('admin')) . '">
									<a href ="' . URL::route('admin') . '">Админ панель</a>
								</li>';
            }
        }
        $link_user = '******' . LinksInMenu::isActive(URL::route('profile')) . '">
							<a href="' . URL::route('profile') . '">' . $first_name . ' ' . $last_name . '</a>
						</li>';
        $link_logout = '<li><a href="/logout">Выход</a></li>';
        return $link_admin . $link_user . $link_logout;
    }
 public function sendNotice()
 {
     if (!Input::has('themes')) {
         return Redirect::to('notices');
     }
     $mTheme = MessageThemes::find(Input::get('themes'));
     $subscribers = Input::get('subscribers');
     if (count($subscribers) == 0) {
         return Redirect::to('notices');
     }
     $data['subject'] = $mTheme->name;
     $data['baseMessage'] = $mTheme->message;
     $data['themeName'] = $mTheme->name;
     $data['comment'] = Input::get('comment', '');
     $mailSender = new MailSender();
     for ($i = 0; $i < count($subscribers); $i++) {
         $user = User::find($subscribers[$i]);
         $data['to'] = $user->email;
         $data['toName'] = $user->first_name . " " . $user->last_name;
         $mailSender->doNoticeTheme($data);
     }
     return Redirect::to('notices');
 }
<?php

use FintechFab\Components\Social;
use FintechFab\Models\User;
use FintechFab\Widgets\UsersPhoto;
$user = User::find(Auth::user()->getAuthIdentifier())->toArray();
$userSocial = User::find($user['id'])->SocialNetworks()->get()->toArray();
$socialNets = array();
?>
<script src="/js/ActionForUser.js"></script>
<script type="text/javascript" src="/js/jquery.damnUploader.min.js"></script>
<script src="/js/interafce.js"></script>
<script src="/js/uploader-setup.js"></script>
<div id="profile">
	<h2 class="text-center">Профиль</h2><br>

	<div class="row">
		<div id="photo" class="col-md-offset-1 col-md-4">
			<?php 
echo UsersPhoto::getPhoto();
?>
		</div>
		<div class="col-md-5 photo_upload">
			<div class="well well-lg auto-tip" id="drop-box">
				<p>Перетащите файл в эту область, или</p>
				<?php 
echo Form::open(array('id' => 'upload-form', 'class' => 'form-inline', 'role' => 'form', 'method' => 'post', 'action' => 'upload/image', 'enctype' => 'multipart/form-data'));
?>
				<div class="form-group for_input_file">
					<?php 
echo Form::file('image', array('id' => 'file-input', 'class' => 'form-control auto-tip'));