Posts by Marcelo • 769 points
69 posts
-
1
votes1
answer36
viewsA: Sort distance record based on latitude and longitude - Laravel
I figured it out, so here’s the solution for whoever needs it: $request['latitude'] = '-21.12633165824461'; $request['longitude'] = '-47.766933831153125'; $sqlDistance = DB::raw('( 111.045 * acos(…
-
4
votes1
answer36
viewsQ: Sort distance record based on latitude and longitude - Laravel
I have a table companies who has a one to one polymorphic relationship with addresses I have the parameter of latitude and longitude and I would like to order the Commissaries to the distance of the…
-
1
votes1
answer350
views -
0
votes1
answer24
viewsA: Sort by Laravel polymorphic relationship column
I managed to solve it. For those who need it, I did it this way: $orders = Order::with('address')->orderBy(function ($query) { $query->select('distance') ->from('addresses')…
-
1
votes1
answer24
viewsQ: Sort by Laravel polymorphic relationship column
I need to sort the results by column distance relationship between order and address by paging the results. Order: public function address() { return $this->morphOne(Address::class,…
-
-1
votes3
answers647
viewsQ: Storing latitude and longitude Laravel
I am storing in the database the latitude and longitude. When returning this latitude it is returned as string. I used decimal casting to return a number with all decimals but continues to return as…
-
0
votes1
answer393
viewsQ: Compare two object arrays and remove the difference in javascript
I have an array of products and variable size categories. I have to return the array of categories by deleting categories that have no linked product. Categories: [{ id: 1, nome: Categoria 1 }, {…
javascriptasked Marcelo 769 -
0
votes1
answer173
viewsQ: Group products by vuejs categories
I have a component that displays products and I have an H2 where I display the category name. The problem is that the names of the repeated categories appear, since two products belong to the same…
-
0
votes1
answer1945
viewsQ: Paging with Vue.Js
I created a component that does the paging and takes the items sent by the server that are already paginated in 5 per page. The next button works correctly bringing all pages, but the pagination…
-
0
votes1
answer475
viewsQ: Automatic scroll Vue.Js
Clicking on one of the small or large buttons displays the container with the cards (Small Mix and Small Fruit Only). I need the page to scroll down when displaying the footer to cover the cards. I…
-
1
votes1
answer448
viewsA: Datatables server-side Processing with Sweet Alert 2
I was able to solve the problem by modifying the first line of Sweet Alert from: $('.sa-warning').click(function () { for: $("#datatable").on("click", ".sa-warning", function () {…
-
0
votes1
answer448
viewsQ: Datatables server-side Processing with Sweet Alert 2
I am using Datatables with server-side Processing and using Sweetalert2 to confirm before deleting the record. Everything is working except the Sweet Alert that is not displayed when clicking the…
-
0
votes1
answer136
viewsA: Sort Collection through multiple columns
I managed to solve the problem and am leaving the solution in case someone has the same doubt: if ($order === self::ORDER_POINTS) { $collection = $collection->sort( function ($a, $b) { return…
-
0
votes1
answer136
viewsQ: Sort Collection through multiple columns
I need to sort a Collection first through the fieldpoints and then by company_fantasy I tried some ways as this post…
-
1
votes2
answers58
viewsA: Page reloading while using . click Jquery
I managed to solve by adding $(document).on('click', '.btn-remove-row', function(event){ in both roles. <script>"use strict"; $(document).on('click', '.btn-remove-row', function(event){…
-
0
votes2
answers58
viewsQ: Page reloading while using . click Jquery
I have a view that by clicking a button opens a modal and by clicking the modal button inserts a line in a table and is working correctly. Included in this line is a <a class="btn-remove-row"…
-
1
votes1
answer681
viewsA: Pass array in Laravel route
I was able to pass the json_encode() array and then using json_decode() in the controller. <div class="col-12 offset-lg-6"> @php $array = [1, 2]; @endphp <a id="add-cart" href="{{…
-
1
votes1
answer681
viewsQ: Pass array in Laravel route
I need to pass an array to a controller. I did it as below but it returns the error: Missing required parameters for [Route: site.add.cart] [URI: adiciona-carrinho/{product}/{option}]. (View:…
-
2
votes1
answer65
viewsQ: Validation of select without form
I have a view where I have dynamically generated selects and a link. I need to click on the link <a id="add-cart" href="{{ route('site.add.cart', $product) }}" class="btn btn-danger…
-
0
votes1
answer133
viewsQ: Insert return ajax into table
I have a view with a table that has several dynamically generated lines. By clicking the change button opens a modal that I put a value and by ajax I update this value. I need to take this value…
-
1
votes1
answer166
viewsQ: Pass Mysql query to Eloquent Laravel
I have a query that when passing to eloquent returns me syntax error. SELECT order_id FROM timelines WHERE order_id NOT IN (SELECT order_id FROM timelines WHERE supplier_approved_id) AND supplier_id…
-
0
votes1
answer3486
viewsQ: Make consultation with distinct in Laravel
I have the following table: I need to count the amount of records where the supplier_id is equal to 2 but without repeating the column order_id. In this case it would return 1, since it has two…
-
3
votes2
answers208
viewsQ: Mark Selected in option that has the same id brought in array
I have a select $(".methods option") that has 3 options with payment methods and each option has a value that has an ID (in case 1, 2 and 3 respectively). I need to mark as Selected the option that…
-
1
votes1
answer265
viewsQ: Display options with multiple select and mark the options chosen in Laravel
I have a Collection in the variable $paymentMethods with forms of payment: And I have another Collection in the $timelines variable that has a Many to Many relationship with payment methods. I need…
-
0
votes1
answer136
viewsQ: Close PHP socket with telnet
I’m trying to close one socket if you type "exit" through the telnet but the variable $msg is always empty inside the if <?php $host = '127.0.0.1'; $port = 10000; $socket = socket_create(AF_INET,…
-
2
votes0
answers557
viewsQ: Change HTML data attribute with Jquery
I have an input that would like to change the date-min and data-max with the value brought by AJAX by changing the value of select category_id. Ajax is bringing the value correctly, but does not…
-
0
votes0
answers40
viewsQ: Foreach Laravel does not update with tabs navigation
I have a view that has tabs navigation. When implementing a way that when saving or editing a record it goes to the respective tab, the foreach that lists the record has stopped working. I need to…
-
0
votes1
answer589
viewsA: Confirmation before deleting record
I was able to find the solution. In the case lib is Sweetalert for Bootstrap <a id="danger-alert" data-link="{{ route('admin.categories.destroy', $category) }}"><i class="zmdi zmdi-delete…
-
1
votes1
answer589
viewsQ: Confirmation before deleting record
I have a link that opens a modal asking if the user wants to delete the record. On the link I have a href that calls a route to delete. How could I call this route only if I click the delete button?…
-
0
votes1
answer614
viewsQ: Update quantity in dynamic table with Ajax
I have a shopping cart that modifies the quantity through ajax by functions remove and adiciona. I have the function atualizaQtd that by ajax returns the current amount. How could you insert this…
-
2
votes2
answers980
viewsQ: Remove an item from an array in Laravel’s Session
I have an array in a Session and I need to remove only one item. Put session()->forget('cart') it removes all items. What is the correct way to remove only one? Controller namespace…
-
2
votes1
answer1190
viewsQ: Log variable in Laravel
I am registering a name in a modal, sending it to the controller and putting it in the session. When returning to the view there is nothing in the session. What am I doing wrong? Controller…
-
2
votes1
answer3056
viewsQ: Save inputs with PHP/Laravel arrays
I have a dynamically generated table where I insert several products. I’m trying to use a for to save these products, but if I only have one product doesn’t work anymore, you need to have more than…
-
3
votes1
answer1445
viewsQ: Select model methods in the Laravel controller index method?
I have an index method that searches all events in the database and shows in a table Model Event: namespace App\Models; use Illuminate\Database\Eloquent\Model; class Event extends Model { protected…
-
2
votes2
answers369
viewsA: Traverse arrays with dates and compare with the current date
Another way I ended up doing to solve the problem whether payment was made or not: public static function payments() { $date = date('Y-m-d'); $services = Service::all()->toArray(); $overdue = 0;…
-
3
votes2
answers369
viewsQ: Traverse arrays with dates and compare with the current date
I need to create a method that compares in two or more arrays if the current date is greater than the due dates (date_paymentX) that exist in these arrays and returns how many occurrences there are.…
-
2
votes1
answer548
viewsQ: Increment dynamic input name with jquery
I have a table that generates the line dynamically by clicking a button. I need the Names to be incremented when generating a new line. Ex: name="product1" name="amount1" name="price1" name="total1"…
-
0
votes2
answers1674
viewsQ: Multiply dynamic input values
I have a table that generates lines by clicking a button. In these lines there are two inputs (amount and price) that need to take the entered values, multiply and the result display in a column of…
-
1
votes1
answer308
viewsQ: Relationship Many to Many with select multiplo in Laravel
I have the Post and Tag models with a Many to Many relationship. When registering a post the previously registered tags appear normally in select and I can save in the bank. In the edit form I am…
-
0
votes1
answer478
viewsQ: Div with same image height in Bootstrap
I have an image to the left and another 4 blocks to the right. I needed the four blocks to follow the height of the image, even when changing the resolution. HTML: <div…
-
0
votes2
answers421
viewsQ: Convert and save time to database with PHP
I have an input field where the user type an hour (eg "08:00") convert this string with strtotime() and convert again with date() and saved in mysql in TIME format. So far, so good, although I think…
-
7
votes3
answers340
viewsQ: Position caption above div
I am using the bootstrap Carousel with caption. Between the slide image and the caption there is a div with the image of an orange triangle. I need the caption to be above the triangle. I’ve used…
-
0
votes2
answers201
viewsQ: Show and hide caption with jquery
I’m trying to show and hide a div if the slide div has the active class. The problem is that the div always keeps being displayed, even when the bootstrap slide changes and the active class is…
-
1
votes1
answer365
viewsQ: Position image relative to another even changing resolution
I have the logo and a black triangle background. How to position the logo forever stay in the center of the triangle even changing the resolution? <img class="img-responsive triangulo-laranja"…
-
2
votes1
answer940
viewsQ: Problem with search and paging in Laravel?
The code below returns all bank records and also searches for the term entered in input search with pagination. The problem is that by clicking for example on page 2 it already refreshes the page by…
-
-1
votes1
answer407
viewsA: Laravel Authentication by Routes
You can solve this with policies: https://laravel.com/docs/5.4/authorization#Creating-policies…
-
0
votes1
answer444
viewsQ: Error message via middleware Laravel
I am trying to pass an error msg through a middleware. If I use $errors->all() the error appears, but how do I use $errors->has('active')? Or if you could just pass this message from…
-
0
votes1
answer180
views -
0
votes0
answers284
viewsQ: Provide in view polymorphic relationship data Laravel
I have the models Trainer, Modality and Image using Laravel’s Polymorphic Relations https://laravel.com/docs/5.4/eloquent-relationships#polymorphic-Relations I want to make this data available in…
-
1
votes1
answer195
viewsQ: Save multiple images in a php loop
People I have the code below in Laravel that saves a single image and works correctly. But I would like to save multiple images that come from an input that is named:"name[]" Multiple. I think I…