Cronix

Experience

799,200

1090 Best Reply Awards

  • Member Since 4 Years Ago
  • 763 Lessons Completed
  • 3 Favorites

23rd October, 2018

Cronix left a reply on How To Do Batch Update • 5 minutes ago

do a dd($request->engagements); at the top of your controller and show the result.

Is it a regular php array of the ids, like [1, 2]?

Cronix left a reply on Attributes Has Been Defined In Bootstrap Modal Forms Don't Get Dynamic Value In Laravel • 7 minutes ago

The problem is you have the id hardcoded in your form in the modal.

<form method="post" action="{{asset(route('movies.update', $movie->id))}}">

That needs to be dynamic depending on what button you clicked to open the modal. The same goes for the other fields in the modal. See the bootstrap docs on how to do that.

https://getbootstrap.com/docs/4.0/components/modal/#varying-modal-content

Cronix left a reply on Validation Ordering • 13 minutes ago

Maybe for some reason it isn't working because it's an array. Try using a string.

bail|required_if:existing_client,yes|exists:clients,id

Cronix left a reply on Validation Ordering • 22 minutes ago

Cronix left a reply on How To Do Batch Update • 24 minutes ago

I don't know where that would be coming from. I don't see you using foreach() in the code you've shown.

Cronix left a reply on Undefined Variable: Tags • 27 minutes ago

How about explaining when/where the problem occurs? Surely it's not in every single one of those controller methods. You're just dumping your entire controller and saying you have a problem with an undefined variable. You also show the contents of your "create.blade.php", but there is nothing directly using that view (tags.create) in your controller so we don't know what it's referring to. Help narrow down where the problem is. Showing your route definitions would be helpful too.

Cronix left a reply on Login Required After Sometime • 42 minutes ago

@devops It depends on how secure you need your app to be. 1 week is way too long imo. So if you walk away from your computer for 3 days and I access it, I'm already logged in and can access all of your data. There is also the "remember me" feature when you login that you could use.

Please mark as solved since your question has been answered.

Cronix left a reply on How To Do Batch Update • 55 minutes ago

If they both get updated with the exact same data, it would be something like

Engagement::whereIn('id', $request->engagements)->update([
    'key' => $value,
    'key2' => $value2
]);

Cronix left a reply on Create The Relationship One To Many • 2 hours ago

Since you're not following eloquent naming conventions for your id fields (FilterGroupID instead of just id), you need to specify them in all of the relationships. Both the local and foreign keys. If you follow naming conventions, this is unnecessary as laravel can determine the keys on its own.

Also for a one-to-many, it would be hasMany instead of belongsToMany. belongsToMany is for many-to-many. "a filter has many properties". "a property belongs to a filter": https://laravel.com/docs/5.7/eloquent-relationships#one-to-many

Cronix left a reply on Undefined Offset: 0 In Foreach Loop • 3 hours ago

$item['datas']

That's an array, which may or may not always have values since it's a relationship. You're assuming it always will.

Try checking the output of this

foreach ($node as $item) {
    dump($item['datas']); // does every $item contain an array of datas with values?
}

The reason why it's working with dd(), is because dd() kills the loop cycle. It's not iterating through the whole array. It iterates once until it hits the dd() and then stops. So maybe the first one has it and it outputs fine, but maybe on the 2nd iteration there is no element at position 0 in the array.

What you need to figure out is what data_id should be if $item['datas'][0]['pivot']['qanswer_id'] doesn't exist for each item.

22nd October, 2018

Cronix left a reply on Counting Clicks In Laravel • 17 hours ago

Nothing I've said would cause any refreshing, except for the content of the single modal when different videos are viewed.

Cronix left a reply on Counting Clicks In Laravel • 17 hours ago

Once you get a single modal working, you can actually just fire the ajax request from the show.bs.modal event instead of a click event targeting .video1. If you added a data-video-id="{{ $proo->id }}" to the buttons that open the modal

$('#exampleModal').on('show.bs.modal', function (event) {
    var button = $(event.relatedTarget) // Button that triggered the modal

    var video_id = button.data('video-id');
    // fire off ajax request and send video_id

Cronix left a reply on Counting Clicks In Laravel • 18 hours ago

Ok, so you're not just displaying a single video, you're displaying a bunch in the loop. So, this will be a bit harder to do since you're not using a controller to show a single video by it's id.

I think the easiest thing to do would be to use ajax. Since your videos all use a class of video1, I'd set up a click event targeting that class that would retrieve the video id (you'd add a new data property on the video tag that would hold the id of the video) in the click event, fire off an ajax request to an endpoint that sends the video id, and then increment it for that id like was shown above. It's a bit more complex.

However, there's something else I'd do before tackling this feature. Currently you are generating a modal for every single video. That's not the best way to do that. You can have a single modal, and then pass data to it depending on what was clicked to open it.

It looks like you're using bootstrap, so here's how to do that. https://getbootstrap.com/docs/4.0/components/modal/#varying-modal-content

Cronix left a reply on Counting Clicks In Laravel • 19 hours ago

yes its going to a controller

Typically you have a show() method to display something by the id.

public function show($video_id) {
    Video::where('id', $video_id)->increment('counter_field');

    // other stuff...send video to view, etc.
}

So just get the video by the id, and increment whatever field you're using for the view count.

Cronix left a reply on Blade File Not Rendering <script></script> L5.7 • 20 hours ago

Ok, so there's no problem then?

Cronix left a reply on Blade File Not Rendering <script></script> L5.7 • 20 hours ago

Are there any messages in the browser console? Have you tried in incognito mode, or another browser? I'm wondering if you have a browser plugin or something interfering. Do you have other pages where js works?

Cronix left a reply on Blade File Not Rendering <script></script> L5.7 • 21 hours ago

You mean when you "view source" of the generated html, you see everything as it should be but the script tags are entirely removed?

Cronix left a reply on Distinct Not Returning Distinct Results • 21 hours ago

You probably would have more luck if you filed it in the Nova channel instead of the Eloquent one, since this is more specific to Nova.

Cronix left a reply on Blade File Not Rendering <script></script> L5.7 • 21 hours ago

That should be fine. Are your views cached? Did you try php artisan view:clear?

Cronix left a reply on Counting Clicks In Laravel • 21 hours ago

Sure, but it entirely depends on how you're currently doing things. How are people able to view these videos (I assume that's what you want counted is the views)? Is it going through a controller specifying the video id to show? If so, that would be the easiest as you know the video id, and you know someone requested it.

Cronix left a reply on Distinct Not Returning Distinct Results • 21 hours ago

It's also hard for people without nova to answer as we don't know what $this->countByDays($request, $builder) or ->showLatestValue() is/does. Are those Nova methods, or yours?

Cronix left a reply on How Can I Get Multiple Dynamic Products In Dynamic Pages On Laravel • 21 hours ago

Not enough info to answer, really. Can you provide more details? Do you have any code to share?

Cronix left a reply on Distinct Not Returning Distinct Results • 21 hours ago

What are your countByDays() and showLatestValue() methods doing? We can't know if you're doing things correctly without seen the methods you're using. The query isn't actually taking place in any of the code you're showing. It's just a builder instance that you're passing to these mystery methods.

Cronix left a reply on How To Do Batch Update • 22 hours ago

Probably the easiest would be to not specify the id in your route, but do it in the data sent using array syntax.

Like if you sent id[]=1&id[]=2, and in the controller accessed with $request->id, the result would be [1, 2] and you could iterate over it whether it contained only one id or many.

Cronix left a reply on Browser History When Modal Opened (mobile Back Navigation) • 22 hours ago

because the browser buttons only know about url changes that get recorded to the history. The easiest would be to append a hash to the url when the modal button is clicked to open the modal. Then clicking the back button would remove that hash from the url. You'd probably need a way to check the url to see if the hash is present and close the modal if it isn't. You can probably do some of this using the history api: https://developer.mozilla.org/en-US/docs/Web/API/History_API

Cronix left a reply on CommandNotFoundException During Unit Testing • 1 day ago

Try setting client to true. Other than that, I'm not sure with the passport specific stuff. I was just trying to help solve your original question bc you weren't passing parameters correctly when calling artisan via code.

Cronix left a reply on Supervisor: When To Use Numprocs > 1? • 1 day ago

Example: The job sends a mail to each user in a table => Lets set numproces == 3 => This means that 3 parallel processes will try to execute the same job script

No, it means one queue worker/process will get that job, unless you've actually queued it 3x. While that queue worker is tied up processing that job, the next item in the queue would be passed to worker#2 or 3, depending on which one is free.

Cronix left a reply on CommandNotFoundException During Unit Testing • 1 day ago

All parameters, like --client, need to be in the array, like --no-interaction is.

Cronix left a reply on How To Update Table Ccolumn Values When Click Button? • 1 day ago

By passing the vehicle id in the form like I've been saying. Good luck ;)

Cronix left a reply on Supervisor: When To Use Numprocs > 1? • 1 day ago

When a single queue worker can't process the queue fast enough for your needs.

Let's say you have a service like youtube, where users upload videos and then you need to process the videos. Let's say it takes an hour to process a video. That means you'd only be able to process 24 videos per day. What if you need to process 50? May not be the best example, but you see the point.

Cronix left a reply on Change Primary Key • 1 day ago

It also won't work unless your current product_id values are unique in that table, as primary keys are required to be unique. No 2 rows can have the same primary key id. Do you have multiple advertisements that are for the same product_id? If so, you won't be able to do this.

Cronix left a reply on How To Update Table Ccolumn Values When Click Button? • 1 day ago

<a class="btn btn-primary" href="{{route('payments.payment',$vehicles->id)}}" role="button">Go Premium</a>

ok, you're passing the vehicle id to the controller. So capture it and pass it to the view with the form, and put it in a hidden form input like I first showed. What does that controller method look like? You're showing the controller that the form posts to. I'm asking about the controller that is showing that form.

Cronix left a reply on Login Required After Sometime • 1 day ago

The default is 2 hours. You can change the session duration in /config/session.php in the lifetime parameter

Cronix left a reply on How To Update Table Ccolumn Values When Click Button? • 1 day ago

How are you generating that form? Is it tied to a vehicle? You're just showing the form and not the controller that is sending data to that view that has the form. I assume you're showing the form for a particular vehicle? It's really hard to see how everything is working because you're not showing all of the code.

Cronix left a reply on How To Update Table Ccolumn Values When Click Button? • 1 day ago

No any idea?

Not from the description and code you're showing.

now I need update vehicles table adtype column values from 0 to 1

how are these linked? It sounds like you need to pass a vehicle id or something in your form as a field in order to know what vehicle to update it for?

<input type="hidden" name="vehicle_id" value="{{ $vehicle->id }}" />

And then in the controller, retrieve the vehicle by that id and update the column you need?

Cronix left a reply on Difference Between Logout POST And GET Method • 1 day ago

Is your question answered on what the difference between post/get logout is?

Cronix left a reply on Difference Between Logout POST And GET Method • 1 day ago

anything you type in the address bar issues a get request. That's how browsers work. Who cares if you get the error if you manually type it? You'll get one if you manually type any address that is meant to respond to a post/put/patch/delete request. Use the logout form on the page that you should be displaying only to users who are logged in.

Cronix left a reply on Difference Between Logout POST And GET Method • 1 day ago

How can I not get method not allowed on blank /logout form post?

What do you mean? If it's in a form using post method and sending csrf token there shouldn't be an issue.

Cronix left a reply on Difference Between Logout POST And GET Method • 1 day ago

get requests don't validate csrf tokens, so they're less secure.

Cronix left a reply on Password Resets In Laravel • 1 day ago

Easiest thing to do to figure out something is to trace the password reset functionality starting with the ResetPasswordController.

But the short answer is it generates and sends the unique token for the password reset request to the users email, user clicks the link which goes back to the controller, where it validates that the token matches the email address that you enter on the form which allows you to reset the password.

21st October, 2018

Cronix left a reply on Call_user_function(JeffreyWay::class) Returns Null ! • 1 day ago

Not sure about twitter, but he uploaded a new vid here on the 19th (2 days ago). https://laracasts.com/series/laravel-from-scratch-2018/episodes/17

Cronix left a reply on Autoload • 2 days ago

Why is /vendor in your /public dir? It should be in the ids-api dir.

Cronix left a reply on Laravel 5.4 Jquery Can't Inject Id In Edit Link • 2 days ago

Please format your code. There's a link under the reply box for instructions.

Cronix left a reply on Updating A Product Fails • 2 days ago

Try the named route for the resource.

<form method="post" action="{{route('products.update', $id)}}">

20th October, 2018

Cronix left a reply on Cannot Get Login User Data • 3 days ago

@tykus not using the auth middleware shouldn't prevent you from viewing the current logged in user though, only prevent them from accessing the route if they aren't authenticated.

@sanjayacloud I hope you get this resolved. I'm out for a bit but will check back.

Cronix left a reply on Cannot Get Login User Data • 3 days ago

change to

Route::get('/', function () {
    return view('welcome');
});

Route::get('/home', '[email protected]')->name('home');
Route::get('/profile','[email protected]');
Route::resource('profiles', 'ProfileController');

Auth::routes();

Cronix left a reply on Cannot Get Login User Data • 3 days ago

@tykus He is logged in though, or it wouldn't redirect to /home when visiting /login. It would show the login form if he wasn't logged in?

@sanjayacloud please post your entire /routes/web.php file.

Cronix left a reply on Cannot Get Login User Data • 3 days ago

If you go to /login, does it show the login form? If so, you're not logged in.

Cronix left a reply on Google Maps Api For Satellite View • 3 days ago

var map = new google.maps.Map(document.getElementById('map'), {
    center: {lat: 36.964, lng: -122.015},
    mapTypeId: 'satellite'
  });

Sure, you'd query the api to get the coordinates, and when you create the map you just set mapTypeId to 'satellite' https://developers.google.com/maps/documentation/javascript/maptypes

Edit Your Profile
Update

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