SNaRe

SNaRe

Member Since 4 Years Ago

Experience Points
22,665
Total
Experience

2,335 experience to go until the next level!

In case you were wondering, you earn Laracasts experience when you:

  • Complete a lesson — 100pts
  • Create a forum thread — 50pts
  • Reply to a thread — 10pts
  • Leave a reply that is liked — 50pts
  • Receive a "Best Reply" award — 500pts
Lessons Completed
163
Lessons
Completed
Best Reply Awards
6
Best Reply
Awards
  • start-engines Created with Sketch.

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • first-thousand Created with Sketch.

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • 1-year Created with Sketch.

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • 2-years Created with Sketch.

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • 3-years Created with Sketch.

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • 4-years Created with Sketch.

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • 5-years Created with Sketch.

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • school-session Created with Sketch.

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • welcome-newcomer Created with Sketch.

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • full-time-student Created with Sketch.

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • pay-it-forward Created with Sketch.

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • subscriber-token Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer-token Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • lara-evanghelist Created with Sketch.

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.

  • chatty-cathy Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

Level 5
22,665 XP
19 May
4 months ago

SNaRe left a reply on Telescope Subdomain Requests

when I inspected log entries I found this


Consider a function index of an MD5 hash of the value, or use full text indexing. (SQL: insert into \"telescope_entries\" (\"batch_id\", \"content\", \"created_at\", \"type\", \"uuid\") values (8db95834-2c00-4c20-a908-c2c633f12e63, {\"uri\":\"\/musteri-sorulari\",\"method\":\"GET\",\"controller_action\":\"App\\Http\\Controllers\\[email protected]\",\"middleware\":[\"web\",\"auth\"],\"headers\":{\"cookie\":\"_fbp=fb.1.1552337841631.1791084459; _ga=GA1.2.1708644219.1552606182; _hjIncludedInSample=1; _ym_uid=155427865965606187; _ym_d=1554278659; intercom-id-qfo196pa=d2126526-8de7-4e43-bc11-a62b2e31ba50; 

.....

 at /home/forge/akillisatici.com/vendor/laravel/framework/src/Illuminate/Database/Connection.php:664, Doctrine\DBAL\Driver\PDOException(code: 54000): SQLSTATE[54000]: Program limit exceeded: 7 ERROR:  index row size 5016 exceeds maximum 2712 for index \"telescope_entries_content\"

ERROR: SQLSTATE[54000]: Program limit exceeded: 7 ERROR:  index row size 5952 exceeds maximum 2712 for index "telescope_entries_content"

SNaRe started a new conversation Telescope Subdomain Requests

Hi, I have successfully installed telescope. It records requests to my main domain(ex: www.mydomain.com) but doesnt record requests to my subdomains (ex: sudomain.mydomain.com)

I'm using Laravel 5.8 Telescope 2.0

29 Mar
5 months ago

SNaRe started a new conversation How To Add Bread To Postgre View In Voyager

Hi,

I want to create bread of Postgre View Table in Voyager? As far as I searched I couldn't find any way of doing this. Thanks in advance.

23 Mar
6 months ago

SNaRe started a new conversation Php Artisan Work Timeout And Setting Timeout In Job

Hi, I set time out when running workers like php artisan queue:work sqs --sleep=60 --timeout=120

and if a job needs more than 120 I set timeout in job like: public $timeout=300;

My question is which one will override? Does my job has timeout of 300 or 120 seconds?

Thanks in advance.

SNaRe left a reply on Dynamic Number Of Workers

@kobear yes I have 10 different queues.

21 Mar
6 months ago

SNaRe left a reply on Dynamic Number Of Workers

Thank yo for your answer. @munazzil Actually My Question is how to dynamically change number of workers in horizon or directly artisan queue:work command

SNaRe started a new conversation Dynamic Number Of Workers

Hi, Some of the jobs that have run is consuming high cpu on db side. So I would like to dynamically alter number of jobs that are running. By the way Laravel 5.8 and I'm using laravel horizon. Thanks in advance.

16 Mar
6 months ago

SNaRe started a new conversation How To Auto-Scale Queue System ?

Hi,

I'm on forge and using laravel horizon. I can easily scale our workers on forge but our demand fluctuates. I don't want to use redis for queue because of ram limitation. I want to auto-scale our workers and queue system. What do you guys suggest? Thanks in advance. :)

10 Feb
7 months ago

SNaRe started a new conversation With Dd() No Error, Without Trying To Get Property Of Non-object Error

It was my small mistake. Worthless to be stayed as a post. @Jeff please delete

31 Oct
10 months ago

SNaRe left a reply on How To Populate Nested Select Options With Values From Database One After Another

It didn't work, but It showed me the way somehow. Thank you!

Can you please replace the domain name with example.com ? Thank you.

  beforeMount: function() {
    fetch("https://www.example.com/loc/instant")
      .then(result => result.json())
      .then(result => {
       this.result=result;

        this.selected = this.result[0].cityid,
        
        this.ilceleriGetir();
        this.selected2 = this.result[0].countyid
                    
      })
  },

SNaRe left a reply on How To Populate Nested Select Options With Values From Database One After Another

Question. What I developed is populating fields as I select options. What I want is to populate the selected options. So that I can show the user selected options when he wants to edit this option.

SNaRe started a new conversation How To Populate Nested Select Options With Values From Database One After Another

I have a nested select option form that I get data from API on change. It works perfectly for me.

However, I will use it also in an edit form. So that I have to populate the select option values in the form, which I will get from DB ( I can serve those 3 values as json result for fetching ).

You can use this https://www.examplei.com/loc/instant endpoint to get a mock value and set value of select options.

<script src="https://unpkg.com/vue"></script>

<script type="text/javascript">
  window.addEventListener('load', function() {

    var app = new Vue({
      el: '.app',
      name: "IlIlceUygulaması",
      data: {

        iller: {},
        ilceler: {},
        mahalleler: {},

        selected: 0,
        selected2: 0,

        ilSecildi: true,
        ilceSecildi: true,
      },


      methods: {
        illeriGetir() {
          fetch("https://www.example.com/loc/")
            .then(result => result.json())
            .then(result => {
              this.iller = result;
            })
        },
        ilceleriGetir() {
          this.ilSecildi = true;
          fetch(`https://www.example.com/loc/${this.selected}`)
            .then(result => result.json())
            .then(result => {
              this.ilceler = result;
            })
        },
        mahalleleriGetir() {
          this.ilSecildi = true;
          this.ilceSecildi = true;

          fetch(`https://www.example.com/loc/${this.selected}/${this.selected2}`)
            .then(result => result.json())
            .then(result => {
              this.mahalleler = result;
            })
        }
      }
    })
    app.illeriGetir();
  });

</script>


<div class="app">
  <div class="row">
    <div class="col-md-4 mb-3">
      <label for="country">İl</label>
      <select class="custom-select d-block w-100" id="country" required="" v-model="selected" v-on:change="ilceleriGetir()" name="city_id">
                                                    <option v-for="list in iller"
                                                            v-bind:value="list.cityid">
                                                        {{list.cityname}}
                                                    </option>
                                                </select>
      <div class="invalid-feedback">
        Please select a valid country.
      </div>
    </div>
    <div class="col-md-4 mb-3" v-if="ilSecildi">
      <label for="state">İlçe</label>
      <select class="custom-select d-block w-100" id="country" required="" v-on:change="mahalleleriGetir()" v-model="selected2" name="county_id">
                                                    <option v-for="list in ilceler"
                                                            v-bind:value="list.countyid">
                                                        {{list.countyname}}
                                                    </option>
                                                </select>
      <div class="invalid-feedback">
        Please provide a valid state.
      </div>
    </div>
    <div class="col-md-4 mb-3" v-if="ilceSecildi">
      <label for="zip">Mahalle</label>
      <select class="custom-select d-block w-100" id="country" required="" ame="area_id">
                                                    <option v-for="list in mahalleler"
                                                            v-bind:value="list.areaid">
                                                        {{list.areaname}}
                                                    </option>
                                                </select>
      <div class="invalid-feedback">
        Zip code required.
      </div>
    </div>
  </div>
</div>
21 Sep
1 year ago

SNaRe left a reply on How To Dispatch A Job From As I Do From Controller

I have finally found the solution. It's a very silly problem though. The problem is due to the terminal.

export LC_ALL=en_US.UTF-8; export LANG=en_US.UTF-8;

solves the problem

SNaRe left a reply on How To Dispatch A Job From As I Do From Controller

I'm using laravel 5.6 and redis connection I couldn't solved this issue. Any help would be very nice.

17 Sep
1 year ago

SNaRe started a new conversation How To Dispatch A Job From As I Do From Controller

Hi,

I can dispatch my job from controller. But when I try to dispatch from php artisan tinker it gives me error. What could be the problem.

Note: I only use redis::funnel and it functions very well while I dispatch job from controller.



Psy Shell v0.9.6 (PHP 7.2.5-1+ubuntu16.04.1+deb.sury.org+1 — cli) by Justin Hileman
>>> dispatch(new \App\Jobs\someJob(2600))->onQueue('P-4')

=> Illuminate\Foundation\Bus\PendingDispatch {#3168}
>>> dispatch(new \App\Jobs\someJob(2600))->onQueue('P-4')


Predis/ClientException with message 'Command 'iNCR' is not a registered Redis command.'

>>> dispatch(new \App\Jobs\someJob(2600))->onQueue('P-4')
=> Illuminate\Foundation\Bus\PendingDispatch {#3181}

>>> dispatch(new \App\Jobs\someJob(2600))->onQueue('P-4')

Predis/ClientException with message 'Command 'iNCR' is not a registered Redis command.'
PHP Fatal error:  Uncaught Predis\ClientException: Command 'iNCR' is not a registered Redis command. in /home/forge/mydomain.com/vendor/predis/predis/src/Profile/RedisProfile.php:88
Stack trace:
#0 /home/forge/mydomain.com/vendor/predis/predis/src/Client.php(323): Predis\Profile\RedisProfile->createCommand('iNCR', Array)
#1 /home/forge/mydomain.com/vendor/predis/predis/src/Client.php(314): Predis\Client->createCommand('incr', Array)
#2 /home/forge/mydomain.com/vendor/laravel/framework/src/Illuminate/Redis/Connections/Connection.php(96): Predis\Client->__call('incr', Array)
#3 /home/forge/mydomain.com/vendor/laravel/framework/src/Illuminate/Redis/Connections/Connection.php(108): Illuminate\Redis\Connections\Connection->command('incr', Array)
#4 /home/forge/mydomain.com/vendor/laravel/horizon/src/Repositories/RedisJobRepository.php(65): Illuminate\Redis\Connections\Connection->__call('incr', Array)
#5 /home/forge/mydomain.com/vendor/laravel/horizon/src/JobId.php(27): Laravel\Horizon\Repositories\Redis in /home/forge/mydomain.com/vendor/predis/predis/src/Profile/RedisProfile.php on line 88

16 Sep
1 year ago

SNaRe started a new conversation Forge Horizon Daemon Fail Notice

Hi, Sometimes my horizon daemon fails due to lack of ram memory with error of

daemon-37304                     FATAL     Exited too quickly (process log may have details) 

and when it fails.

After restarting in forge panel it normally runs. So tried to simulate the restart of the deamon by terminating horizon. I check the status of horizon in App\Console\Kernel.php and when it fails I run

    shell_exec("cd /home/forge/my_domain.com && php artisan horizon:terminate");

this command. But the it doesn't works. How can I simulate restart daemon in forge's panel. Thanks in advance.

SNaRe started a new conversation How To Make A Script For Daemon

Hi, I have a python script that should always run. Could I just add the script directly as new daemon or Daemon checks anything that I should add to my script? Thanks in advance.

11 Sep
1 year ago

SNaRe left a reply on Forge & Horizon: Process Exited Too Quickly

Hi @eelcol I’am having the same issue. Sometimes horizon stops working and when I look at deamons status

‘’’ daemon-37304 FATAL Exited too quickly (process log may have details)’’’

And when I restart only the php artisan horizon deamon it works. How can I fix this?

01 Aug
1 year ago

SNaRe started a new conversation Sending Request To A Post Controller Function From Another Controller Function

I have a controller like this.

public function barcode_approve(Request $request)
{
    $barcodes = $request->input('barcode_values');
    $upload_ids = $request->input('upload_id');
    ....
}

It is defined as post in route without any problem.

Route::post('my/url','[email protected]_approve');

I would like to use barcode_approve by sending request from controller like

public function push_approve(){

    $request = ['barcode_values' => '23ssdwe','upload_id'=>234234];

    $this->barcode_approve($request);
    .....

} 

But $reqeust->input doesn't give the value when I send it through controller function (push_approve)

How can I send values from another controller function as input in $request?

12 Jul
1 year ago

SNaRe started a new conversation ERR_SPDY_PING_FAILED Error With Uploader Chrome ( DropZone )

I have an uploader based on http://www.dropzonejs.com/

When I upload a file bigger than 3 MB ( 13 MB ) with Chrome, I recieve ERR_SPDY_PING_FAILED error in the console log.

When I upload the file, the progress bar stuck at a certain level. This is when we get this error.

I tried it with Safari, Firefox we don't have this problem.

This is request headers from Chrome

Provisional headers are shown
Accept: application/json
Cache-Control: no-cache
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary4sLYTyIwAAXnftvv
Origin: https://www.example.com
Referer: https://www.example.com/upload/document
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36
X-Requested-With: XMLHttpRequest
------WebKitFormBoundary4sLYTyIwAAXnftvv
Content-Disposition: form-data; name="_token"

GiY0lmkggP4hlyhunGRQOOBa1k1dqsr44ZgHA41e
------WebKitFormBoundary4sLYTyIwAAXnftvv
Content-Disposition: form-data; name="file[0]"; filename="sdf_brz_lin.1.jpg"
Content-Type: image/jpeg


------WebKitFormBoundary4sLYTyIwAAXnftvv--

I googled and found that others also complaining the same problem.

In this stackoverflow post, they proposed some solutions but I couldn't implement their solutions since they are based on other scripts.

https://stackoverflow.com/questions/27740692/request-stalled-for-a-long-time-occasionally-in-chrome/30772776#30772776

They proposed something like

$(document).ready(function() {
    $.keepalive =     
            setInterval(function() {
               $.ajax({
                  url: '/ping.html',
                  cache: false
               });         
            }, 60000);    
});

But I added this snippet to my file but it didn't work. Maybe I need a laravel solution rather than javascript.

I found this for laravel to keep alive.

https://github.com/Influendo/laravel-survivor

I am not sure how implement. Have you had any experience with it?

I just have a www.example.com/upload/document route.

I don't want to say visitors if they use chrome, you cannot upload bigger files than X MB...

11 Jul
1 year ago

SNaRe left a reply on Server Responded With 0 Code Error - Files Bigger Than 2MB


server {

    listen 80;
    server_name .exampe.tc;

    location = / {

        return 301 https://www.example.com/;
    }

    location / {

        try_files $uri $uri/ /index.php?$query_string;
    }

    root /home/forge/example.com/public;
    index index.html index.htm index.php;
    charset utf-8;
    include forge-conf/example.com/server/*;


    location = /favicon.ico {

        access_log off; log_not_found off;
    }
    location = /robots.txt {

        access_log off; log_not_found off;
    }
    error_page 404 /index.php;

    location ~ \.php$ {

        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
        fastcgi_index index.php;
        include fastcgi_params;
    }

    location ~ /\.(?!well-known).* {

        deny all;
    }


}


# FORGE CONFIG (DO NOT REMOVE!)
include forge-conf/example.com/before/*;


fastcgi_read_timeout 14400;


server {

    proxy_connect_timeout 14400;
    proxy_send_timeout 14400;
    proxy_read_timeout 14400;
    send_timeout 14400;


    client_max_body_size 200M;


    listen 443 ssl http2;
    listen [::]:443 ssl http2;
    server_name .example.com;

    if ($http_host = example.com) {

        rewrite (.*) https://www.example.com;
    }
    root /home/forge/example.com/public;

    # FORGE SSL (DO NOT REMOVE!)
    ssl_certificate /etc/nginx/ssl/example.com/330472/server.crt;
    ssl_certificate_key /etc/nginx/ssl/example.com/330472/server.key;

    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers 'dfdf';
    ssl_prefer_server_ciphers on;
    ssl_dhparam /etc/nginx/dhparams.pem;

    add_header X-Frame-Options "SAMEORIGIN";
    add_header X-XSS-Protection "1; mode=block";
    add_header X-Content-Type-Options "nosniff";

    index index.html index.htm index.php;

    charset utf-8;

    # FORGE CONFIG (DO NOT REMOVE!)
    include forge-conf/example.com/server/*;

    location / {

        fastcgi_read_timeout 14400;
        client_max_body_size 200M;

        try_files $uri $uri/ /index.php?$query_string;
    }

    location = /favicon.ico {

        access_log off; log_not_found off;
    }
    location = /robots.txt {

        access_log off; log_not_found off;
    }

    access_log off;
    error_log /var/log/nginx/example.com-error.log error;

    error_page 404 /index.php;

    location ~ \.php$ {

        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
        fastcgi_index index.php;
        include fastcgi_params;

        fastcgi_read_timeout 14400;
    }

    location ~ /\.(?!well-known).* {

        deny all;
    }
}


# FORGE CONFIG (DO NOT REMOVE!)
include forge-conf/example.com/after/*;

SNaRe left a reply on Server Responded With 0 Code Error - Files Bigger Than 2MB

I didn't work @lostdreamer_nl

Where exactly should we put client_max_body_size 200M; in Forge nginx conf?

It is a little bit dynamic nginx file

SNaRe started a new conversation Server Responded With 0 Code Error - Files Bigger Than 2MB

I have been getting "Server responded with 0 code" error as I upload a big file. Files Bigger than 2MB

My server is on Forge. ( I contacted with Forge team)

I have an upload form. It is working on DropZoneJs

I increased the php limits ( I restarted nginx I can see in phpinfo )

post_max_size=100M
upload_max_filesize=100M

I also played with Nginx settings by adding

    client_max_body_size 200M;

But I have been still getting the same error. I don't know what else to do?

I also increased the max_file_upload_size from Forge.

09 Jul
1 year ago

SNaRe started a new conversation Getting Rid Of Error Log When Unauthenticated Redirect Fires

If a user is not registered and tries to reach a page that needs authentication, I redirect the visitor to login with Bolierplate Laravel AuthCode.

However, when I check error log I receive and error. ( It works on client-side without any problems)

Illuminate\Auth\AuthenticationException: Unauthenticated. in /home/forge/xyz.com/vendor/laravel/framework/src/Illuminate/Auth/GuardHelpers.php:40 Stack trace: #0 /home/forge/xyz.com/vendor/laravel/framework/src/Illuminate/Auth/AuthManager.php(292): Illuminate\Auth\SessionGuard->authenticate() #1 /home/forge/xyz.com/vendor/laravel/framework/src/Illuminate/Auth/Middleware/Authenticate.php(57): Illuminate\Auth\AuthManager->__call('authenticate', Array) #2 /home/forge/xyz.com/vendor/laravel/framework/src/Illuminate/Auth/Middleware/Authenticate.php(41): Illuminate\Auth\Middleware\Authenticate->authenticate(Array) #3 /home/forge/xyz.com/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(151): Illuminate\Auth\Middleware\Authenticate->handle(Object(Illuminate\Http\Request), Object(Closure)) #4 /home/forge/xyz.com/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request)) #5 /home/forge/xyz.com/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php(67): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request)) #6 /home/forge/xyz.com/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(151): Illuminate\Foundation\Http\Middleware\VerifyCsrfToken->handle(Object(Illuminate\Http\Request), Object(Closure)) #7 /home/forge/xyz.com/

Code: <?php

namespace App\Http\Controllers\Auth;

use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\AuthenticatesUsers;

class LoginController extends Controller
{
    /*
    |--------------------------------------------------------------------------
    | Login Controller
    |--------------------------------------------------------------------------
    |
    | This controller handles authenticating users for the application and
    | redirecting them to your home screen. The controller uses a trait
    | to conveniently provide its functionality to your applications.
    |
    */

    use AuthenticatesUsers;

    /**
     * Where to redirect users after login.
     *
     * @var string
     */
    protected $redirectTo = '/login';

    /**
     * Create a new controller instance.
     *
     * @return void
     */
    public function __construct()
    {
        $this->middleware('guest')->except('logout');
    }

    public function logout()
    {
        $this->guard()->logout();

        return redirect()->route('login');
    }

}
05 Jul
1 year ago

SNaRe left a reply on SQLSTATE[42S22]: Column Not Found: 1054 Unknown Column 'activation_key' In 'field List'

Maybe it's about caching of configuration settings. If you changed settings in .env file this might be the reason. Did you tried php artisan config:cache command?

30 Jun
1 year ago

SNaRe started a new conversation Forge Nginx Configuration Problem

Hi,

First, I would like to redirect mydomain.com to www.mydomain.com

Secondly, I would like to host many subdomains in my project. For example when visitors visit asd.com and asd2.com they will all see the content in mydomain.com. Another problem could be mydomain.com has default ssl that is provided by forge but asd.com and asd2.com doesn't have.

I added tried the code below but didn't work.

server {
    server_name mydomain.com;
    return 301 $scheme://www.mydomain.com$request_uri;
}

I added the code to projects nginx file after include forge-conf/mutlumusteri.com/before/*;

before

server {
      proxy_connect_timeout       600;
  proxy_send_timeout          600;
......

SNaRe left a reply on Advice For Poor Api Services

So sorry about my so late answer @lostdreamer_nl @CJJ I'm getting the data

07 Jun
1 year ago

SNaRe started a new conversation How To Use Laravel Collection GroupBy Along With Query Pagination? Ask Question

I love using Laravel's groupBy function https://laravel.com/docs/5.6/collections#method-groupby

However, I cannot use it with paginate(x) function since it return a limited number of results. Groupby of SQL Query and Laravel Collections's GroupBy is totally different. If I use groupby in my query it doesn't give me what I want. For instance I just want to type and I got all I want.

$notifications = $notifications->groupBy('order_id');

For example this is my query

    $notifications = DB::table('sent_notifications as a')
        ->join('sent_notification_results as b', 'a.sent_notification_result_id', '=', 'b.sent_notification_result_id')
        ->join('orders as c', 'c.order_id', '=', 'a.order_id')
        ->join('sellers as d', 'c.seller_id', '=', 'd.seller_id')
        ->join('companies as e', 'd.company_id', '=', 'e.company_id')
        ->join('notification_templates as f', 'f.notification_template_id', '=', 'a.notification_template_id')
        ->join('notification_types as g', 'g.notification_type_id', '=', 'f.notification_type_id')
        ->join('default_notification_templates as h', 'h.default_notification_template_id', '=', 'f.default_notification_template_id')
        ->where('e.company_id', $company_id)
        ->select('*')
        ->orderBy('a.created_at','DESC')
        ->paginate(20);
    $pagination_links = $notifications->links();

How can I use Collection's groupby method along with pagination?

05 Jun
1 year ago

SNaRe started a new conversation Disabiling View Cache&query Cache In Specific Controller With Laravel Ask Question

I want to disable view cache for specific controllers since I need to see the latest data in the page.

I don't work with API's unfortunately so that I print some static data into my HTML.

When I render the page it shows me wrong values and I start to think like it is a bug.

How can I completely disable view,query whatever cache for a specific controller?

27 May
1 year ago

SNaRe started a new conversation Notification When Deamon Fails

Hi, I would like to get notification such as Slack, when an deamon fails i.e php artisan horizon.

How can I set it up? I searched so much but found no related content.

Thanks in advance

SNaRe left a reply on Dealing With Poor Api

Any suggestions?

25 May
1 year ago

SNaRe started a new conversation Dealing With Poor Api

Hi, I'm working with a very poor api. It's uptime is approximately %50 and in worst cases it decreases even more. I'm trying to get 100.000 api requests per day. The way api works is first I get the page then I get all items in page.

My question is what is the best way to deal with this this situation.

The solution I have reached so far is I have separated all api calls to different jobs to the queue. So if a job fails it retries again for 9 times but with this %5 of the jobs fails.

09 May
1 year ago

SNaRe started a new conversation Retrieving Old Input Even If Visitor Leaves The Page

I can retrieve the old input with

<input type="text" name="username" value="{{ old('username') }}">

But if I leave the page, the old "username" disappears.

I would like to show the "old" even user visits another page or comes back in the same session until the form is successfully posted.

The use case: Our website is dependent to 3rd party services and sometimes they crash. Our users type a long text and submit. But when it crashes it may take sometime(30 mins), they have to leave the page. But in this case the text disappears.

I don't want to save as draft or something for now. I would like to solve it on the fly like sessions maybe redis.

Please advise.

03 May
1 year ago

SNaRe started a new conversation Getting Last Inserted ID With Laravel Ask Question

I am trying to get the last inserted id when I create a new entry

I don't use ID as primary key, I use something called "notification_template_id" which is defined as protected $primaryKey ='notification_template_id'; in my model.

It creates a row in my DB. I don't have any problems with it BTW.

$create = [
    'subject' => isset($new_subject) ? $new_subject : '',
    'body' => $new_body,
    'is_active' => intval($new_status),
    'default_notification_template_id' => (int)$default_info->default_notification_template_id,
    'notification_type_id' => (int)$requested_info["notification_type_id"],
    'company_id' => (int)$company_id,
];

$notification_template = NotificationTemplate::create($create);
id = $notification_template->notification_template_id;

When I try to get the last id it returns NULL,

I tried another way around,

    $data = new NotificationTemplate;

    $data->subject = isset($new_subject) ? $new_subject : '';
    $data->body = $new_body;
    $data->is_active = intval($new_status);
    $data->default_notification_template_id = (int)$default_info->default_notification_template_id;
    $data->notification_type_id = (int)$requested_info["notification_type_id"];
    $data->company_id = (int)$company_id;
    $data->save();

    $id = $data->notification_template_id;

It returns NULL again

How can I solve this issue

SNaRe started a new conversation Advice For Poor Api Services

I get information from an api services that crashes approximately every 5 minustes. And the amounth of data is very huge about 5gb per day. Could you give any advice from your experiexces? Thanks in advance.

MS7G.png

02 May
1 year ago

SNaRe left a reply on Horizon Doesn't Show Failed Jobs On Forge

Also I couldn't monitor tags. When I click "Monitor Tag" and wrote the tag name clicked "Monitor" nothing happens? Not: Horizon processes 8000 jobs per hour could the reason be related with this ?

SNaRe left a reply on Horizon Doesn't Show Failed Jobs On Forge

Any thoughts what could be the reason?

30 Apr
1 year ago

SNaRe left a reply on Creating Public Url With Hashed Slug Parameter

@Cronix the url is for customers and the page should be accessed without auth so with clicking url they could accessed the page

SNaRe started a new conversation Horizon Doesn't Show Failed Jobs On Forge

In my local, horizon works perfectly and shows failed jobs.

Unfortunately, when I push on github and then forge. I couldn't see failed jobs on horizon dashboard.

When I look chrome developer tools I can see the failed jobs are coming but doesn't shown on the page. What could be the problem? Thanks in advance

I tried "composer dump-autoload -o" but nothing changed.

and my version: Laravel Framework 5.6.7

MoUg.png

28 Apr
1 year ago

SNaRe started a new conversation Creating Public Url With Hashed Slug Parameter

I would like to have a page that can be reached by public but depending on the parameter on the URL, the access should be verified. My goals is to prevent people to see the content by increasing the id. Let me make it clear with an example.

compname.url.com/orderid/23424/{someHashedKey}

So orderid = 23424 is my DB primary key, compname is the unique name of order's company.

My plan is to create a hashed key with orderid and compname with some kind of salted hash.

So that when someone reaches to the page, I will create a hash(md5) from orderid,compname, and a salted hash and match with 'SomehashedKey'

Is this the best way or how should I do this?

25 Apr
1 year ago

SNaRe left a reply on Horizon Doesn't Retry Again

Any help? Thanks in advance

22 Apr
1 year ago

SNaRe left a reply on How To Dynamically Generate Queues In Laravel Horizon

Thanks you all for your kind responses but if I set balance to auto user-2 can have 30 processes but it shouldnt be more than 1.

Do you have a solution for this?

And can I add dynamically queues array like the solution in middleware method?

Thanks a lot

SNaRe left a reply on How To Dynamically Generate Queues In Laravel Horizon

Thanks for your reply :) You said that "I'm not a big fan of this" what could be other solutions ? In my case I have thousands of jobs for every user and these jobs should be processed one by one for every user

SNaRe started a new conversation How To Dynamically Generate Queues In Laravel Horizon

My application requires to have dynamically generated queues with some prefix like

"process_user_1", "process_user_2", "process_user_n"

The main idea is to separate execution of some jobs depends on model ID.

Because the api that I connect allows only 1 connection for a user

Normally I can configure in horizon.php but it should be dynamic e.g. I can have 1000 users so I must have 1000 different queues

What could be the solution?

This is my configuration

'User-1' => [ 'connection' => 'redis', 'queue' => ['User-1'], 'balance' => 'simple', 'processes' => 1, 'tries' => 10, ], 'User-2' => [ 'connection' => 'redis', 'queue' => ['User-2'], 'balance' => 'simple', 'processes' => 1, 'tries' => 10,

SNaRe started a new conversation Horizon Doesn't Retry Again

Hi, I was trying to restart a failed job 2 days ago and it successfully completed the job. On the other hand now I try and doesn't retry the job only the circle turns around and nothing happens what could be the reason? Thanks in advance

19 Apr
1 year ago

SNaRe left a reply on Redirect With Session Doesn't Send Success Or Error

Unfortunately this didn't work. I am wondering why this problem persists.

12 Apr
1 year ago

SNaRe left a reply on Passing A Model From A Function To Another

Since the 1st one had return, I thought I don't need to return anything in the 2nd function. However, it seems that I am mistaken. @Joucke thank you

SNaRe started a new conversation Passing A Model From A Function To Another

I have this Laravel snippet. I cal the function(1) from another function.

It gives me a "blank" page. I think it is something about model binding in here. Since the (1) function requires Request I have to send it inside the (2) But I think I am doing something wrong

function messages_without_product(Request $request,$message_type=0){
...

}


function messages_without_product_answered(Request $request){
    $this->messages_without_product($request,1);
}
11 Apr
1 year ago

SNaRe started a new conversation Redirect With Session Doesn't Send Success Or Error

I am on Laravel 5.6

I try to send success with session to show some success messages.

return redirect('templates')->with('success','Template added successfully');

It used to work perfectly. However, it stopped working now and I couldn't find the reasons why.

When I dd(redirect('templates')->with('success','Template added successfully');) I see success message inside it.

RedirectResponse {#438 ▼
  #request: Request {#43 ▶}
  #session: Store {#279 ▼
    #id: "9Qcvbynta2B3yrDPDGGj2UhPTjDsCgn1857UlQM0"
    #name: "laravel_session"
    #attributes: array:5 [▼
      "_token" => "ngzN7cWaJIlYrQsCmfSdapbT1UnCJ7jxuld3VCeP"
      "_previous" => array:1 [▶]
      "_flash" => array:2 [▶]
      "login_web_59ba36addc2b2f9401580f014c7f58ea4e30989d" => 6
      "success" => "Template Added Successfully"
    ]
    #handler: FileSessionHandler {#280 ▶}
    #started: true
  }

But I try to read it in blade it doesn't show anything at all. As I said it used to work perfectly.

@if (\Session::has('success'))
    sdfsdf

    <script>
        window.onload = function () {
            toastr.success("{{ \Session::get('success') }}");
        }
    </script>
@endif 

I am thinking of my recent changes I put this 3 to middleware in kernel

        \App\Http\Middleware\EncryptCookies::class,
        \Illuminate\Session\Middleware\StartSession::class,
        \App\Http\Middleware\LimitDemoUser::class,

This is my full Kernel.php

<?php

namespace App\Http;

use Illuminate\Foundation\Http\Kernel as HttpKernel;

class Kernel extends HttpKernel
{
    /**
     * The application's global HTTP middleware stack.
     *
     * These middleware are run during every request to your application.
     *
     * @var array
     */
        protected $middleware = [
            \Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class,
            \Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
            \App\Http\Middleware\TrimStrings::class,
            \Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
            \App\Http\Middleware\TrustProxies::class,
            \App\Http\Middleware\EncryptCookies::class,
            \Illuminate\Session\Middleware\StartSession::class,
            \App\Http\Middleware\LimitDemoUser::class,


        ];

    /**
     * The application's route middleware groups.
     *
     * @var array
     */
    protected $middlewareGroups = [
        'web' => [
            \App\Http\Middleware\EncryptCookies::class,
            \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
            \Illuminate\Session\Middleware\StartSession::class,
            // \Illuminate\Session\Middleware\AuthenticateSession::class,
            \Illuminate\View\Middleware\ShareErrorsFromSession::class,
            \App\Http\Middleware\VerifyCsrfToken::class,
            \Illuminate\Routing\Middleware\SubstituteBindings::class,




        ],

        'api' => [
            'throttle:60,1',
            'bindings',
        ],
    ];

    /**
     * The application's route middleware.
     *
     * These middleware may be assigned to groups or used individually.
     *
     * @var array
     */
    protected $routeMiddleware = [
        'auth' => \Illuminate\Auth\Middleware\Authenticate::class,
        'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
        'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class,
        'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
        'can' => \Illuminate\Auth\Middleware\Authorize::class,
        'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
        'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
    ];
}
09 Apr
1 year ago

SNaRe left a reply on UpdateOrCreate Always Create, Never Updates - Laravel Query Builder

I found the problem. I didn't add default_notification_template_id to "insert" part of the query. So that it couldn't find any values. @m-rk thanks for investigating the problem with me.