SerhiiNuzhnyi

Experience

750

0 Best Reply Awards

  • Member Since 2 Months Ago
  • 0 Lessons Completed
  • 0 Favorites

1st July, 2017

SerhiiNuzhnyi left a reply on Cant Find Div With The Same Class As Current • 3 weeks ago

Want to share solution I've just found

$(this).parents('.row').next('.row').find('.'+classN).html("<input type='text' class='input_field'>").focus();

28th June, 2017

SerhiiNuzhnyi started a new conversation Cant Find Div With The Same Class As Current • 4 weeks ago

I have such a html

   foreach ($users as $user): ?> 
 <div class="row edit_tr" id="<?php echo $user->id; ?>">
  <div class="col-xs-2 col-md-2 edit_td " >
   <div class='name' ><?php echo $user->name; ?></div>   
  </div>
  <div class="col-xs-2 col-md-2 edit_td " >
<div class='email'> <?php echo $user->email; ?></div>  
  </div>
   <div class="col-xs-2 col-md-2 edit_td " >
<div class='phone'> <?php echo $user->phone; ?></div>  
  </div>
  <div class="col-xs-2 col-md-2 edit_td " >
<div class='city'> <?php echo $user->city; ?></div>  
  </div>
   </div>
 <?php endforeach; ?> 

And I want to be able after event to find the div with the same class as current has. I do it in this way

var classN = $(this).parents('div').attr('class');
//alert(classN); - shows right current classname
$(this).parents('.row').next('.row').children(classN).html("<input type='text' class='input_field'>").focus();
//here I want to replace inner text with input field but nothing happens

27th June, 2017

SerhiiNuzhnyi left a reply on Replace Element With Jquery • 1 month ago

Thank you cipsas.

SerhiiNuzhnyi left a reply on Routes Does Not Work • 1 month ago

I'm sorry. I just edited roles and accidentally changed main admin role) so middleware 'role' couldnt access any page. Is any way to edit error page to have more information?

SerhiiNuzhnyi left a reply on Routes Does Not Work • 1 month ago

For example this route worked fine http://localhost/doctor_lar/public/admin/roles_list Now it throws

Sorry, the page you are looking for could not be found.

1/1
NotFoundHttpException in RouteCollection.php line 179:
in RouteCollection.php line 179
at RouteCollection->match(object(Request)) in Router.php line 533
at Router->findRoute(object(Request)) in Router.php line 512
at Router->dispatchToRoute(object(Request)) in Router.php line 498
at Router->dispatch(object(Request)) in Kernel.php line 174

26th June, 2017

SerhiiNuzhnyi started a new conversation Routes Does Noy Work • 1 month ago

I cant say exactly why but my app does not find routes and give me warnings NotFoundHttpException in RouteCollection.php line 179:. route: list

 +--------+----------+------------------------+-------------------+------------------------------------------------------------------------+-------------------------------+
| Domain | Method   | URI                    | Name              | Action                                                                 | Middleware                    |
+--------+----------+------------------------+-------------------+------------------------------------------------------------------------+-------------------------------+
|        | POST     | admin/assign_role      |                   | App\Http\Controllers\[email protected]_role                       | web                           |
|        | POST     | admin/create_role      |                   | App\Http\Controllers\[email protected]_role                       | web                           |
|        | POST     | admin/create_user      | admin.create_user | App\Http\Controllers\[email protected]_user                       | web,role:supervisor,adminmenu |
|        | POST     | admin/delete_role      |                   | App\Http\Controllers\[email protected]_role                       | web                           |
|        | GET|HEAD | admin/edit_roles       |                   | App\Http\Controllers\[email protected]_list                        | web,role:supervisor,adminmenu |
|        | GET|HEAD | admin/edit_users       |                   | App\Http\Controllers\[email protected]_users                        | web,role:supervisor,adminmenu |
|        | GET|HEAD | admin/register_user    |                   | App\Http\Controllers\[email protected]_user                     | web,role:supervisor,adminmenu |
|        | GET|HEAD | api/user               |                   | Closure                                                                | api,auth:api                  |
|        | POST     | dialogue               |                   | App\Http\Controllers\[email protected]                          | web                           |
|        | GET|HEAD | login                  | login             | App\Http\Controllers\Auth\[email protected]                | web,guest                     |
|        | POST     | login                  |                   | App\Http\Controllers\Auth\[email protected]                        | web,guest                     |
|        | POST     | logout                 | logout            | App\Http\Controllers\Auth\[email protected]                       | web                           |
|        | POST     | password/email         | password.email    | App\Http\Controllers\Auth\[email protected]  | web,guest                     |
|        | GET|HEAD | password/reset         | password.request  | App\Http\Controllers\Auth\[email protected] | web,guest                     |
|        | POST     | password/reset         |                   | App\Http\Controllers\Auth\[email protected]                | web,guest                     |
|        | GET|HEAD | password/reset/{token} | password.reset    | App\Http\Controllers\Auth\[email protected]        | web,guest                     |
|        | POST     | patient                |                   | App\Http\Controllers\[email protected]                           | web                           |
|        | POST     | register               |                   | App\Http\Controllers\Auth\[email protected]                  | web,guest                     |
|        | GET|HEAD | register               | register          | App\Http\Controllers\Auth\[email protected]      | web,guest                     |

SerhiiNuzhnyi left a reply on Replace Element With Jquery • 1 month ago

Here I add initial text to previous element and you to current.

25th June, 2017

SerhiiNuzhnyi left a reply on Replace Element With Jquery • 1 month ago

So I found proper way to work for me

var prev = '';
$(document).ready(function()
{
    $( ".name, .email, .phone, .city" ).on( "click", function( event ) {
if($(this).children('.user_data').length<1){
$('.user_data').replaceWith(prev);    
prev= $(this).text();
$(this).html("<input type='text' class='user_data'>").find('input').focus();
}
});
});

SerhiiNuzhnyi left a reply on Replace Element With Jquery • 1 month ago

Yes elements are loaded dynamically and I suppose event listener is added to each element from class list. I would like to have no event listener on new added input but after click on it input field become empty so I assume that event is called. And with this off() method I can click on input with no event.

SerhiiNuzhnyi left a reply on Replace Element With Jquery • 1 month ago

Well. Now I have this code

var prev = '';
  $(document).ready(function()
{
    $( ".name, .email, .phone, .city" ).on( "click", function( event ) {
$('.user_data').replaceWith(prev);    
prev= $(this).text();
$(this).html("<input type='text' class='user_data'>").find('input').focus().off(event);

});
});

The problem is when I want to return after I clicked another element to previous element and click on it second time it wont react to click. This because I use .off(event) but I must use it to avoid dissapearing text in input when I try to click inside input field. I know it s a bit hard to understand I can explain later.

SerhiiNuzhnyi left a reply on Replace Element With Jquery • 1 month ago

Cipsas and Cronix you are right both. Thank you. It is usefull.

24th June, 2017

SerhiiNuzhnyi left a reply on Replace Element With Jquery • 1 month ago

This works for me

$( ".name, .email, .phone, .city" ).on( "click", function( event ) {
  $( this ).off( event );
  $(this).empty();
        $(this).html("<input type='text'>").focus();
});

SerhiiNuzhnyi left a reply on Replace Element With Jquery • 1 month ago

Well. If this scope this means html document why $(this).empty(); wont empty entire document but only clicked element?

SerhiiNuzhnyi started a new conversation Replace Element With Jquery • 1 month ago

I have such html code

<div class="col-xs-2 col-md-2 edit_td " >
   <div class='name' ><?php echo $user->name; ?></div>   
  </div>
  <div class="col-xs-2 col-md-2 edit_td " >
<div class='email'> <?php echo $user->email; ?></div>  
  </div>
   <div class="col-xs-2 col-md-2 edit_td " >
<div class='phone'> <?php echo $user->phone; ?></div>  
  </div>
  <div class="col-xs-2 col-md-2 edit_td " >
<div class='city'> <?php echo $user->city; ?></div>  
  </div>

and I m trying to substitute the text which is showing with php to input field on click event with jquery

 $(document).ready(function()
{
     $(document).on("click", ".name, .email, .phone, .city", function()
     {
        $(this).off( "click" );
        $(this).empty();
        $(this).html("<input type='text'>").focus();
    });
});

But when it is replaced I cant focus there cursor. Maybe it triggers click event again and input field constantly is empty after click in input. What could be the solution?

23rd June, 2017

SerhiiNuzhnyi left a reply on Select Same Named Columns From Joined Tables • 1 month ago

Hi, thank you. It works. I searched for eloquent solution but it seemed to me that query builder is easier. I'll test it.

SerhiiNuzhnyi started a new conversation Select Same Named Columns From Joined Tables • 1 month ago

I have such expression to select from tables users and roles

$users= User::join('roles', 'users.id', '=', 'roles.id')
    ->select('id','name','email','phone','city','image','roles.id as role_id', 'roles.name as roles_name')
    ->get();

And it throw me the error in browser

QueryException in Connection.php line 647:
SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'id' in field list is ambiguous (SQL: select `id`, `name`, `email`, `phone`, `city`, `image`, `roles`.`id` as `role_id`, `roles`.`name` as `roles_name` from `users` inner join `roles` on `users`.`id` = `roles`.`id`)

Is any solution here?

9th June, 2017

SerhiiNuzhnyi left a reply on Cant Create User • 1 month ago

Can't argue with you. I'll write it up to be more specific. Thanks again.

SerhiiNuzhnyi left a reply on Cant Create User • 1 month ago

Thank you all. My code now work. As you advised it was mass assignment protection. Thank you for syntax recommendation my code now is

  $data = $request->all();
       
 User::create([
            'name' => $data['name'],
            'email' => $data['email'],
            'password' => bcrypt($data['password']),
            'phone' => $data['phone'],
            'city' => $data['city'] ?? NULL,
            'image' => $data['image'] ?? NULL
        ]);

 return view('admin.register');

SerhiiNuzhnyi left a reply on JQuery • 1 month ago

Somehow

$ajax({
type: "POST",
url: "stock-rate-route",
success: function(data){
 $("#rate").keyup(function(){
    quantity = $("#quantity").val();
    total = data.stock_rate * quantity;
    $("#total").val(total);
    
});
}

SerhiiNuzhnyi started a new conversation Cant Create User • 1 month ago

I have code in controller which receive from registration form data and save to users table. I cant paste all data only first three is inserted while next wont.

    
    $data = $request->all();
    $user = new \App\User;
    
$user::create([
            'name' => $data['name'],
            'email' => $data['email'],
            'password' => bcrypt($data['password']),
            'phone' => $data['phone'],
            'city' => (isset($data['city'])) ? $data['city'] : NULL,
            'image' => (isset($data['image'])) ? $data['image'] : NULL
        ]);

 return view('admin.register');
} ```

5th June, 2017

SerhiiNuzhnyi left a reply on Register New Users In Adminpanel • 1 month ago

Thank you guys, I ll learn it. But how to make registration when it demand me to be logged out while I am logged in as admin. And how to divide view templates for visitor registration and visitor registration by admin, so visitor could fill some fields later while admin could fill entire form.

SerhiiNuzhnyi started a new conversation Register User At Adminpanel • 1 month ago

I wanna register new users when I'm logged in as admin in admin panel. And create user with more fields than provides standard Laravel registration form. What is the way to do it?

26th May, 2017

SerhiiNuzhnyi left a reply on UpdateOrCreate Doesn't Work • 2 months ago

Thank you, everything work now. I've got MassAssignmentException.

SerhiiNuzhnyi started a new conversation UpdateOrCreate Doesn't Work • 2 months ago

I have this code to update or create new row in table 'roles'. I receive $data and use App\Role but code doesn't work

$role = Role::updateOrCreate(
            ['id' => $data['id']],
            ['name' => $data['val']]
        );

14th May, 2017

SerhiiNuzhnyi left a reply on Single Page For Editing Small Table • 2 months ago

Is it some plugin?

SerhiiNuzhnyi started a new conversation Single Page For Editing Small Table • 2 months ago

I get all data from a small table and want to edit data at frontend and save changed rows back to database without reload page. What is the easiest way to do that?

13th May, 2017

SerhiiNuzhnyi left a reply on Cannot Use Object Of Type StdClass As Array • 2 months ago

@Snapey thank you. I guessed what you mean. It works in such way

<?php foreach ($roles as $role):?>
              <li>
                  <?php echo $role->name; ?><br>
              
              </li>
                          <?php endforeach; ?>

SerhiiNuzhnyi left a reply on Cannot Use Object Of Type StdClass As Array • 2 months ago

MaverickChan: your code cause the same error. Snapey: Laravel Framework 5.4.21. I use it in blade as

<?php foreach ($roles as $role):?>
              <li>
                  <?php echo $role['name']; ?><br>
              
              </li>
                          <?php endforeach; ?>

12th May, 2017

SerhiiNuzhnyi started a new conversation Cannot Use Object Of Type StdClass As Array • 2 months ago

I have a function in my controller. Here are three ways to get all data from database table. All work fine but I can pass to View only first. Other two which are commented cause error Cannot use object of type stdClass as array public function roles_list(){ $roles = Role::all(); //$roles = DB::select('SELECT * FROM roles'); //$roles = DB::table('roles')->get(); return view('admin.role')->with(['roles'=>$roles]);; }

Edit Your Profile
Update

Want to change your profile photo? We pull from gravatar.com.