dimanche 31 octobre 2021

paypal transaction id from express checkout

I am unable to get the transactions id from paypal ExpressCheckout method.

 $provider = new ExpressCheckout;
 $response = $provider->getExpressCheckoutDetails($request->token);
 echo "<pre>";print_r($response);
Array
(
  [TOKEN] => EC-79454119W8713794B
  [BILLINGAGREEMENTACCEPTEDSTATUS] => 1
  [CHECKOUTSTATUS] => PaymentActionNotInitiated
  [TIMESTAMP] => 2021-11-01T04:14:23Z
  [CORRELATIONID] => f00ab9c2819b4
  [ACK] => Success
  [VERSION] => 123
  [BUILD] => 55938276
  [EMAIL] => john@abc.com
  [PAYERID] => 238MG2US77AQY
  [PAYERSTATUS] => unverified
  [FIRSTNAME] => john
  [LASTNAME] => doe
  [COUNTRYCODE] => US
  [ADDRESSSTATUS] => Confirmed
  [CURRENCYCODE] => USD
  [AMT] => 24.99
  [ITEMAMT] => 24.99
  [SHIPPINGAMT] => 0.00
  [HANDLINGAMT] => 0.00
  [TAXAMT] => 0.00
  [DESC] => Order #61 Invoice
  [INVNUM] => 61
  [NOTIFYURL] => https://example.com/ipn/notify
  [INSURANCEAMT] => 0.00
  [SHIPDISCAMT] => 0.00
  [INSURANCEOPTIONOFFERED] => false
  [L_NAME0] => Monthly Unlimited
  [L_QTY0] => 1
  [L_TAXAMT0] => 0.00
  [L_AMT0] => 24.99
  [PAYMENTREQUEST_0_CURRENCYCODE] => USD
  [PAYMENTREQUEST_0_AMT] => 24.99
  [PAYMENTREQUEST_0_ITEMAMT] => 24.99
  [PAYMENTREQUEST_0_SHIPPINGAMT] => 0.00
  [PAYMENTREQUEST_0_HANDLINGAMT] => 0.00
  [PAYMENTREQUEST_0_TAXAMT] => 0.00
  [PAYMENTREQUEST_0_DESC] => Order #61 Invoice
  [PAYMENTREQUEST_0_INVNUM] => 61
  [PAYMENTREQUEST_0_NOTIFYURL] => https://example.com/ipn/notify
  [PAYMENTREQUEST_0_INSURANCEAMT] => 0.00
  [PAYMENTREQUEST_0_SHIPDISCAMT] => 0.00
  [PAYMENTREQUEST_0_SELLERPAYPALACCOUNTID] => abc@gmail.com
  [PAYMENTREQUEST_0_INSURANCEOPTIONOFFERED] => false
  [L_PAYMENTREQUEST_0_NAME0] => Monthly Unlimited
  [L_PAYMENTREQUEST_0_QTY0] => 1
  [L_PAYMENTREQUEST_0_TAXAMT0] => 0.00
  [L_PAYMENTREQUEST_0_AMT0] => 24.99
  [PAYMENTREQUESTINFO_0_ERRORCODE] => 0
)

I need transaction id for making refund. that's why I need transaction id. This is the function I am trying for refund

$response = $provider->refundTransaction($transactionid);


via Chebli Mohamed

vendredi 29 octobre 2021

Laravel public_path is showing entire site URL

I finally figured out I can just use my laravel public folder for storing these PDF files I need to display on a web page, but the way I'm getting them fails to load on the front-end.

I just realized it's because public_path shows the whole URL like C:\user\user1\websites\public\test1.pdf where I'm expecting it to just show /test1.pdf

Why is this code resulting in the full URL like that

    $file1 = 'test1.pdf';
    $file2 = 'test2.pdf';

    if(file_exists(public_path($file1))){
        $files[1] = public_path($file1);
    }

    if(file_exists(public_path($file2))){
        $files[2] = public_path($file2);
    }

    $PDFfiles = json_encode($files);

    dd($PDFfiles);


via Chebli Mohamed

Can't make a public storage folder in laravel 5.2

My laravel project is setup with storage like this:

-storage
  -app
  -services

And I have a filesystem setup for the app folder but I just recently setup a new one for services like so

    services' => [
        'driver'     => 'local',
        'root'       => public_path('services'),
        'visibility' => 'public'
    ],

My issue is that now when I get a file out of that folder and use the URL on the frontend, it says the document can't be found and it's because the URL actually prints out like this:

/storage/testfile.txt

where I'm expecting

/storage/services/testfile.txt

but I can't seem to get the URL to show correctly with this controller code:

    $file1 = 'testfile.txt';
    $file2 = 'test2.txt';

    $url1 = Storage::disk('services')->url($file1);
    $url2 = Storage::disk('services')->url($file2);



    if(Storage::disk('services')->exists($file1)){
        $files[1] = public_path($url1);
    }

    if(Storage::disk('services')->exists($file2)){
        $files[2] = public_path($url2);
    }

    $PDFfiles = json_encode($files);

    dd($PDFfiles);

I don't really know how I can change this to link to a public folder, but I currently have no public driver in my filesystems.php file and in my public folder there is no storage folder at all

I"m running laravel 5.2 so I can't run php artisan storage::link either

How can I fix this so that I can display a file on my webpage with a public URL?



via Chebli Mohamed

Deploy angular app in public folder inside Laravel

I have deployed angular project inside laravel public folder, all the contents of the build is placed inside the public folder.

updated document root like

documentroot: /home/XXXX/public_html/XXXXXXX/public/frontend

.htaccess inside public folder

RewriteEngine On   # Force SSL
    RewriteCond %{HTTPS} !=on
    RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# For existing assets or directories, no redirection is required RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -f [OR] RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -d

RewriteRule ^ - [L]
# if the requested resource doesn't exist, use index.html RewriteRule ^ /index.html

but when i run this url https://test.domain.in/ laravel default routes executes,

when i run https://test.domain.in/public/frontend/ i get

enter image description here

index.html file

<!DOCTYPE html><html lang="en"><head>
    <meta charset="utf-8">
    <title>Test</title>
    <base href="/">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="icon" type="image/x-icon" href="favicon.ico">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.0/dist/css/bootstrap.min.css">
    <link rel="preconnect" href="https://fonts.googleapis.com">
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin="">
    <style type="text/css">@font-face{font-family:'Poppins';font-style:italic;font-weight:100;font-display:swap;src:url(https://fonts.gstatic.com/s/poppins/v15/pxiAyp8kv8JHgFVrJJLmE0tDMPKhSkFEkm8.woff2) format('woff2');unicode-range:U+0900-097F, U+1CD0-1CF6, U+1CF8-1CF9, U+200C-200D, U+20A8, U+20B9, U+25CC, U+A830-A839, U+A8E0-A8FB;}@font-face{font-family:'Poppins';font-style:italic;font-weight:100;font-display:swap;src:url(https://fonts.gstatic.com/s/poppins/v15/pxiAyp8kv8JHgFVrJJLmE0tMMPKhSkFEkm8.woff2) format('woff2');unicode-range:U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;}@font-face{font-family:'Poppins';font-style:italic;font-weight:100;font-display:swap;src:url(https://fonts.gstatic.com/s/poppins/v15/pxiAyp8kv8JHgFVrJJLmE0tCMPKhSkFE.woff2) format('woff2');unicode-range:U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;}@font-face{font-family:'Poppins';font-style:italic;font-weight:200;font-display:swap;src:url(https://fonts.gstatic.com/s/poppins/v15/pxiDyp8kv8JHgFVrJJLmv1pVFteOYktMqlap.woff2) format('woff2');unicode-range:U+0900-097F, U+1CD0-1CF6, U+1CF8-1CF9, U+200C-200D, U+20A8, U+20B9, U+25CC, U+A830-A839, U+A8E0-A8FB;}@font-face{font-family:'Poppins';font-style:italic;font-weight:200;font-display:swap;src:url(https://fonts.gstatic.com/s/poppins/v15/pxiDyp8kv8JHgFVrJJLmv1pVGdeOYktMqlap.woff2) format('woff2');unicode-range:U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;}@font-face{font-family:'Poppins';font-style:italic;font-weight:200;font-display:swap;src:url(https://fonts.gstatic.com/s/poppins/v15/pxiDyp8kv8JHgFVrJJLmv1pVF9eOYktMqg.woff2) format('woff2');unicode-range:U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;}@font-face{font-family:'Poppins';font-style:italic;font-weight:300;font-display:swap;src:url(https://fonts.gstatic.com/s/poppins/v15/pxiDyp8kv8JHgFVrJJLm21lVFteOYktMqlap.woff2) format('woff2');unicode-range:U+0900-097F, U+1CD0-1CF6, U+1CF8-1CF9, U+200C-200D, U+20A8, U+20B9, U+25CC, U+A830-A839, U+A8E0-A8FB;}@font-face{font-family:'Poppins';font-style:italic;font-weight:300;font-display:swap;src:url(https://fonts.gstatic.com/s/poppins/v15/pxiDyp8kv8JHgFVrJJLm21lVGdeOYktMqlap.woff2) format('woff2');unicode-range:U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;}@font-face{font-family:'Poppins';font-style:italic;font-weight:300;font-display:swap;src:url(https://fonts.gstatic.com/s/poppins/v15/pxiDyp8kv8JHgFVrJJLm21lVF9eOYktMqg.woff2) format('woff2');unicode-range:U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;}@font-face{font-family:'Poppins';font-style:italic;font-weight:400;font-display:swap;src:url(https://fonts.gstatic.com/s/poppins/v15/pxiGyp8kv8JHgFVrJJLucXtAOvWDSHFF.woff2) format('woff2');unicode-range:U+0900-097F, U+1CD0-1CF6, U+1CF8-1CF9, U+200C-200D, U+20A8, U+20B9, U+25CC, U+A830-A839, U+A8E0-A8FB;}@font-face{font-family:'Poppins';font-style:italic;font-weight:400;font-display:swap;src:url(https://fonts.gstatic.com/s/poppins/v15/pxiGyp8kv8JHgFVrJJLufntAOvWDSHFF.woff2) format('woff2');unicode-range:U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;}@font-face{font-family:'Poppins';font-style:italic;font-weight:400;font-display:swap;src:url(https://fonts.gstatic.com/s/poppins/v15/pxiGyp8kv8JHgFVrJJLucHtAOvWDSA.woff2) format('woff2');unicode-range:U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;}@font-face{font-family:'Poppins';font-style:italic;font-weight:500;font-display:swap;src:url(https://fonts.gstatic.com/s/poppins/v15/pxiDyp8kv8JHgFVrJJLmg1hVFteOYktMqlap.woff2) format('woff2');unicode-range:U+0900-097F, U+1CD0-1CF6, U+1CF8-1CF9, U+200C-200D, U+20A8, U+20B9, U+25CC, U+A830-A839, U+A8E0-A8FB;}@font-face{font-family:'Poppins';font-style:italic;font-weight:500;font-display:swap;src:url(https://fonts.gstatic.com/s/poppins/v15/pxiDyp8kv8JHgFVrJJLmg1hVGdeOYktMqlap.woff2) format('woff2');unicode-range:U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;}@font-face{font-family:'Poppins';font-style:italic;font-weight:500;font-display:swap;src:url(https://fonts.gstatic.com/s/poppins/v15/pxiDyp8kv8JHgFVrJJLmg1hVF9eOYktMqg.woff2) format('woff2');unicode-range:U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;}@font-face{font-family:'Poppins';font-style:italic;font-weight:600;font-display:swap;src:url(https://fonts.gstatic.com/s/poppins/v15/pxiDyp8kv8JHgFVrJJLmr19VFteOYktMqlap.woff2) format('woff2');unicode-range:U+0900-097F, U+1CD0-1CF6, U+1CF8-1CF9, U+200C-200D, U+20A8, U+20B9, U+25CC, U+A830-A839, U+A8E0-A8FB;}@font-face{font-family:'Poppins';font-style:italic;font-weight:600;font-display:swap;src:url(https://fonts.gstatic.com/s/poppins/v15/pxiDyp8kv8JHgFVrJJLmr19VGdeOYktMqlap.woff2) format('woff2');unicode-range:U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;}@font-face{font-family:'Poppins';font-style:italic;font-weight:600;font-display:swap;src:url(https://fonts.gstatic.com/s/poppins/v15/pxiDyp8kv8JHgFVrJJLmr19VF9eOYktMqg.woff2) format('woff2');unicode-range:U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;}@font-face{font-family:'Poppins';font-style:normal;font-weight:100;font-display:swap;src:url(https://fonts.gstatic.com/s/poppins/v15/pxiGyp8kv8JHgFVrLPTucXtAOvWDSHFF.woff2) format('woff2');unicode-range:U+0900-097F, U+1CD0-1CF6, U+1CF8-1CF9, U+200C-200D, U+20A8, U+20B9, U+25CC, U+A830-A839, U+A8E0-A8FB;}@font-face{font-family:'Poppins';font-style:normal;font-weight:100;font-display:swap;src:url(https://fonts.gstatic.com/s/poppins/v15/pxiGyp8kv8JHgFVrLPTufntAOvWDSHFF.woff2) format('woff2');unicode-range:U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;}@font-face{font-family:'Poppins';font-style:normal;font-weight:100;font-display:swap;src:url(https://fonts.gstatic.com/s/poppins/v15/pxiGyp8kv8JHgFVrLPTucHtAOvWDSA.woff2) format('woff2');unicode-range:U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;}@font-face{font-family:'Poppins';font-style:normal;font-weight:200;font-display:swap;src:url(https://fonts.gstatic.com/s/poppins/v15/pxiByp8kv8JHgFVrLFj_Z11lFd2JQEl8qw.woff2) format('woff2');unicode-range:U+0900-097F, U+1CD0-1CF6, U+1CF8-1CF9, U+200C-200D, U+20A8, U+20B9, U+25CC, U+A830-A839, U+A8E0-A8FB;}@font-face{font-family:'Poppins';font-style:normal;font-weight:200;font-display:swap;src:url(https://fonts.gstatic.com/s/poppins/v15/pxiByp8kv8JHgFVrLFj_Z1JlFd2JQEl8qw.woff2) format('woff2');unicode-range:U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;}@font-face{font-family:'Poppins';font-style:normal;font-weight:200;font-display:swap;src:url(https://fonts.gstatic.com/s/poppins/v15/pxiByp8kv8JHgFVrLFj_Z1xlFd2JQEk.woff2) format('woff2');unicode-range:U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;}@font-face{font-family:'Poppins';font-style:normal;font-weight:300;font-display:swap;src:url(https://fonts.gstatic.com/s/poppins/v15/pxiByp8kv8JHgFVrLDz8Z11lFd2JQEl8qw.woff2) format('woff2');unicode-range:U+0900-097F, U+1CD0-1CF6, U+1CF8-1CF9, U+200C-200D, U+20A8, U+20B9, U+25CC, U+A830-A839, U+A8E0-A8FB;}@font-face{font-family:'Poppins';font-style:normal;font-weight:300;font-display:swap;src:url(https://fonts.gstatic.com/s/poppins/v15/pxiByp8kv8JHgFVrLDz8Z1JlFd2JQEl8qw.woff2) format('woff2');unicode-range:U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;}@font-face{font-family:'Poppins';font-style:normal;font-weight:300;font-display:swap;src:url(https://fonts.gstatic.com/s/poppins/v15/pxiByp8kv8JHgFVrLDz8Z1xlFd2JQEk.woff2) format('woff2');unicode-range:U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;}@font-face{font-family:'Poppins';font-style:normal;font-weight:400;font-display:swap;src:url(https://fonts.gstatic.com/s/poppins/v15/pxiEyp8kv8JHgFVrJJbecnFHGPezSQ.woff2) format('woff2');unicode-range:U+0900-097F, U+1CD0-1CF6, U+1CF8-1CF9, U+200C-200D, U+20A8, U+20B9, U+25CC, U+A830-A839, U+A8E0-A8FB;}@font-face{font-family:'Poppins';font-style:normal;font-weight:400;font-display:swap;src:url(https://fonts.gstatic.com/s/poppins/v15/pxiEyp8kv8JHgFVrJJnecnFHGPezSQ.woff2) format('woff2');unicode-range:U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;}@font-face{font-family:'Poppins';font-style:normal;font-weight:400;font-display:swap;src:url(https://fonts.gstatic.com/s/poppins/v15/pxiEyp8kv8JHgFVrJJfecnFHGPc.woff2) format('woff2');unicode-range:U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;}@font-face{font-family:'Poppins';font-style:normal;font-weight:500;font-display:swap;src:url(https://fonts.gstatic.com/s/poppins/v15/pxiByp8kv8JHgFVrLGT9Z11lFd2JQEl8qw.woff2) format('woff2');unicode-range:U+0900-097F, U+1CD0-1CF6, U+1CF8-1CF9, U+200C-200D, U+20A8, U+20B9, U+25CC, U+A830-A839, U+A8E0-A8FB;}@font-face{font-family:'Poppins';font-style:normal;font-weight:500;font-display:swap;src:url(https://fonts.gstatic.com/s/poppins/v15/pxiByp8kv8JHgFVrLGT9Z1JlFd2JQEl8qw.woff2) format('woff2');unicode-range:U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;}@font-face{font-family:'Poppins';font-style:normal;font-weight:500;font-display:swap;src:url(https://fonts.gstatic.com/s/poppins/v15/pxiByp8kv8JHgFVrLGT9Z1xlFd2JQEk.woff2) format('woff2');unicode-range:U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;}@font-face{font-family:'Poppins';font-style:normal;font-weight:600;font-display:swap;src:url(https://fonts.gstatic.com/s/poppins/v15/pxiByp8kv8JHgFVrLEj6Z11lFd2JQEl8qw.woff2) format('woff2');unicode-range:U+0900-097F, U+1CD0-1CF6, U+1CF8-1CF9, U+200C-200D, U+20A8, U+20B9, U+25CC, U+A830-A839, U+A8E0-A8FB;}@font-face{font-family:'Poppins';font-style:normal;font-weight:600;font-display:swap;src:url(https://fonts.gstatic.com/s/poppins/v15/pxiByp8kv8JHgFVrLEj6Z1JlFd2JQEl8qw.woff2) format('woff2');unicode-range:U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;}@font-face{font-family:'Poppins';font-style:normal;font-weight:600;font-display:swap;src:url(https://fonts.gstatic.com/s/poppins/v15/pxiByp8kv8JHgFVrLEj6Z1xlFd2JQEk.woff2) format('woff2');unicode-range:U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;}@font-face{font-family:'Poppins';font-style:normal;font-weight:700;font-display:swap;src:url(https://fonts.gstatic.com/s/poppins/v15/pxiByp8kv8JHgFVrLCz7Z11lFd2JQEl8qw.woff2) format('woff2');unicode-range:U+0900-097F, U+1CD0-1CF6, U+1CF8-1CF9, U+200C-200D, U+20A8, U+20B9, U+25CC, U+A830-A839, U+A8E0-A8FB;}@font-face{font-family:'Poppins';font-style:normal;font-weight:700;font-display:swap;src:url(https://fonts.gstatic.com/s/poppins/v15/pxiByp8kv8JHgFVrLCz7Z1JlFd2JQEl8qw.woff2) format('woff2');unicode-range:U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;}@font-face{font-family:'Poppins';font-style:normal;font-weight:700;font-display:swap;src:url(https://fonts.gstatic.com/s/poppins/v15/pxiByp8kv8JHgFVrLCz7Z1xlFd2JQEk.woff2) format('woff2');unicode-range:U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;}</style>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<style>*{margin:0;padding:0;box-sizing:border-box;font-family:Poppins,sans-serif}</style><link rel="stylesheet" href="styles.53fb677d8b432b70b604.css" media="print" onload="this.media='all'"><noscript><link rel="stylesheet" href="styles.53fb677d8b432b70b604.css"></noscript></head>

<body>
    <app-root></app-root>


    <script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@4.6.0/dist/js/bootstrap.bundle.min.js"></script>
    <script src="https://kit.fontawesome.com/ce4ce84306.js" crossorigin="anonymous"></script>
    <script>
    </script>
<script src="runtime.9a4430f7366c332babeb.js" defer></script><script src="polyfills.b4cc4407230a7c73f572.js" defer></script><script src="main.50f4d85f3709c0393363.js" defer></script>

</body></html>

Any help is highly appreciated

Thanks



via Chebli Mohamed

AWS S3 bucket in laravel storage still resulting in 401

I'm trying to get an S3 bucket working where I can read from it in my laravel storage file system so that I can get the URL for 2 PDF files and display the PDF on a web page

The issue is that I can't access the object url.

I ran into a cURL 60 error on my dev box due to SSL issue so I changed the scheme to http and now I get 401 unauthorized errors. The bucket and objects are even made public now, and I still have my key and secret in my driver settings here:

    's3_docs' => [
        'driver' => 's3',
        'scheme' => 'http',
        'key'    => '{key}',
        'secret' => '{secret}',
        'region' => 'us-east-1',
        'bucket' => 'documents'
    ],

This is also in my CORS setting for the bucket:

[
{
    "AllowedHeaders": [
        "*"
    ],
    "AllowedMethods": [
        "POST",
        "GET",
        "PUT",
        "DELETE",
        "HEAD"
    ],
    "AllowedOrigins": [
        "*"
    ],
    "ExposeHeaders": []
}
]

I've tried all I can think of or know to do but this code is still landing in a 401:

controller.php

    $file1 = 'test1.pdf';
    $file2 = 'test2.pdf';

    if(Storage::disk('s3_docs')->exists($file1)){
        $files[1] = Storage::disk('s3_docs')->url($file1);
    }

    if(Storage::disk('s3_docs')->exists($file2)){
        $files[2] = Storage::disk('s3_docs')->url($file2);
    }

    $PDFfiles = json_encode($files);

    //dd($PDFfiles);


via Chebli Mohamed

laravel 5.8 form::model not working, Post form is sent as Get

I have an error in one of my forms, all the others work but in particular I cannot edit in this one since it does not send the post from a form created with Form :: model (), it took me a while to realize that this was the problem, although I have defined the form as POST the data is sent as GET and it does not find the route since it is defined as POST.

This is my failed code:

{!! Form::model($nota, [
'method' => 'POST',
'url' => ['/admin/notas', $nota->id],
'class' => 'form-horizontal',
'files' => true]) !!}

@include('admin.notas.form', ['formMode' => 'edit'])

{!! Form::close() !!}

But later I realized that if I copy the html generated by this code and paste it raw, there it works!

<form method="POST" action="https://mydomain/admin/notas/" accept-charset="UTF-8" class="form-horizontal" enctype="multipart/form-data">
@csrf

@include('admin.notas.form', ['formMode' => 'edit'])
</form>

It is worth mentioning that this form allowed to edit correctly beforehand, and that in localhost (WAMP) it works correctly, I already confirmed that my model, controller and routes are fine, but everything fails from the submit and does not reach the route defined as Post because it is sent as Get.



via Chebli Mohamed

Null response instead huge JSON in Laravel 5.6

I'm working on a project written in Laravel 5.6 and I need to return a huge JSON (close to 5MB). It contains two keys: hasMore (bool) and data (rendered view). I debugged it (via dd()) and everything works fine until return. Browser sees this answer as blank. Anyone have an idea how to fix it?



via Chebli Mohamed

jeudi 28 octobre 2021

How to get next 15th minute of time from given time in PHP

Is there a way of getting the next 15th minutes from given time?

For Example

  1. if input is 2021-08-26 12:00:37 then output should be 2021-08-26 12:15:00
  2. if input is 2021-08-26 12:30:37 then output should be 2021-08-26 13:15:00


via Chebli Mohamed

Push Notification not working after move my Laravel code from one server to another

Please help me. After moved, my Laravel project from one server to another push notification is not working. I am using Firebase for push notification

In log this response is coming:

[2021-10-28 11:11:58] local.DEBUG: {"connection":null,"queue":null,"chainConnection":null,"chainQueue":null,"delay":{"date":"2021-10-28 11:12:03.901592","timezone_type":3,"timezone":"UTC"},"chained":[]}

After moving code to another server I ran these commands first:

composer dumpautoload
php artisan config:cache



via Chebli Mohamed

Deploy angular and laravel application on server

I have a laravel and angular application it's structure is

Sample_Project
|_Laravel_backend
|_Angular_frontend

This is working on my local system, but i want to upload it on server, On server i have to upload it in sub domain so it should be inside public_html subfolder.

Any Suggestion Thanks



via Chebli Mohamed

Hosting Angular and Laravel Application

I have a laravel and angular application structure is as follows :

projectname
|_backend (laravel)
|_frontend (Angular)

Angular app contains dist folder that is created after build. As I'm new to angular I want to know how I can host it on server. I will host it inside public_html sub folder. Thanks



via Chebli Mohamed

why i am getting this error webpack compiled with 1 error?

I am trying to installing my project but when i run this command npm run production it raises this error. I am not sure that what mistake i have done on it because previously it was working fine but suddenly i got this error and I'm stocking on this. So what should id do now?

    ERROR in ./resources/App.vue?vue&type=style&index=0&lang=scss& (./node_modules/css-loader/dist/cjs.js??clonedRuleSet-11[0].rules[0].use[1]!./node_modules/vue-loader/lib/loaders/stylePostLoader.js!./node_modules/laravel-mix/node_modules/postcss-loader/dist/cjs.js??clonedRuleSet-11[0].rules[0].use[2]!./node_modules/sass-loader/dist/cjs.js??clonedRuleSet-11[0].rules[0].use[3]!./node_modules/vue-loader/lib/index.js??vue-loader-options!./resources/App.vue?vue&type=style&index=0&lang=scss&)
Module build failed (from ./node_modules/laravel-mix/node_modules/postcss-loader/dist/cjs.js):
TypeError: Cannot read property 'toLowerCase' of undefined
    at /var/www/project/dev/back/releases/513/resources/App.vue:61595:1
    at hasInherit (/var/www/project/dev/back/releases/513/node_modules/laravel-mix/node_modules/postcss-merge-longhand/dist/lib/canMerge.js:16:39)
    at Array.some (<anonymous>)
    at _default (/var/www/project/dev/back/releases/513/node_modules/laravel-mix/node_modules/postcss-merge-longhand/dist/lib/canMerge.js:23:13)
    at /var/www/project/dev/back/releases/513/node_modules/laravel-mix/node_modules/postcss-merge-longhand/dist/lib/decl/borders.js:234:33
    at mergeRules (/var/www/project/dev/back/releases/513/node_modules/laravel-mix/node_modules/postcss-merge-longhand/dist/lib/mergeRules.js:44:11)
    at /var/www/project/dev/back/releases/513/node_modules/laravel-mix/node_modules/postcss-merge-longhand/dist/lib/decl/borders.js:233:29
    at Array.forEach (<anonymous>)
    at Object.merge (/var/www/project/dev/back/releases/513/node_modules/laravel-mix/node_modules/postcss-merge-longhand/dist/lib/decl/borders.js:231:7)
    at /var/www/project/dev/back/releases/513/node_modules/laravel-mix/node_modules/postcss-merge-longhand/dist/index.js:20:13
    at Array.forEach (<anonymous>)
    at /var/www/project/dev/back/releases/513/node_modules/laravel-mix/node_modules/postcss-merge-longhand/dist/index.js:18:23
    at /var/www/project/dev/back/releases/513/node_modules/postcss/lib/container.js:96:18
    at /var/www/project/dev/back/releases/513/node_modules/postcss/lib/container.js:55:18
    at Root.each (/var/www/project/dev/back/releases/513/node_modules/postcss/lib/container.js:41:16)
    at Root.walk (/var/www/project/dev/back/releases/513/node_modules/postcss/lib/container.js:52:17)
    at Root.walkRules (/var/www/project/dev/back/releases/513/node_modules/postcss/lib/container.js:94:19)
    at OnceExit (/var/www/project/dev/back/releases/513/node_modules/laravel-mix/node_modules/postcss-merge-longhand/dist/index.js:17:11)
    at LazyResult.runAsync (/var/www/project/dev/back/releases/513/node_modules/postcss/lib/lazy-result.js:431:21)
    at async Object.loader (/var/www/project/dev/back/releases/513/node_modules/laravel-mix/node_modules/postcss-loader/dist/index.js:97:14)

and my package.json

{
    "private": true,
    "scripts": {
        "dev": "npm run development",
        "development": "mix",
        "watch": "mix watch ",
        "watch-poll": "mix watch -- --watch-options-poll=1000",
        "hot": "mix watch --hot",
        "prod": "npm run production",
        "production": "mix --production"
    },
    "dependencies": {
        "@babel/polyfill": "^7.4.4",
        "@ckeditor/ckeditor5-build-classic": "^25.0.0",
        "@ckeditor/ckeditor5-upload": "^27.1.0",
        "@ckeditor/ckeditor5-vue2": "^1.0.5",
        "@fortawesome/fontawesome-free": "^5.15.3",
        "@mdi/font": "^3.6.95",
        "@popperjs/core": "^2.9.1",
        "@riophae/vue-treeselect": "^0.4.0",
        "animate.css": "^4.1.0",
        "apexcharts": "^3.26.0",
        "axios": "^0.19.2",
        "axios-mock-adapter": "^1.18.1",
        "bootstrap": "^4.5.0",
        "bootstrap-vue": "^2.13.0",
        "clipboard": "^2.0.8",
        "core-js": "^3.9.1",
        "deepmerge": "^4.2.2",
        "js-cookie": "^2.2.1",
        "laravel-echo": "^1.11.0",
        "laravel-mix-alias": "^1.0.2",
        "laravel-vue-datatable": "^0.6.0",
        "laravel-vue-pagination": "^2.3.1",
        "line-awesome": "^1.3.0",
        "object-path": "^0.11.4",
        "object-to-formdata": "^4.1.0",
        "portal-vue": "^2.1.7",
        "pusher-js": "^7.0.3",
        "roboto-fontface": "*",
        "socicon": "^3.0.5",
        "sweetalert2": "^9.10.12",
        "tooltip.js": "^1.3.2",
        "v-mask": "^2.2.4",
        "vee-validate": "^3.4.5",
        "vform": "^1.0.1",
        "vue": "^2.6.11",
        "vue-apexcharts": "^1.5.3",
        "vue-axios": "^2.1.4",
        "vue-clipboard2": "^0.3.1",
        "vue-cropperjs": "^4.1.0",
        "vue-highlight.js": "^3.1.0",
        "vue-i18n": "^8.24.2",
        "vue-inline-svg": "^1.3.0",
        "vue-loading-overlay": "^3.4.2",
        "vue-perfect-scrollbar": "^0.2.1",
        "vue-router": "^3.1.5",
        "vue-select": "^3.11.2",
        "vue2-dropzone": "^3.6.0",
        "vue2-filters": "^0.13.0",
        "vue2-perfect-scrollbar": "^1.5.0",
        "vue2-scrollspy": "^2.3.1",
        "vue2-smooth-scroll": "^1.5.0",
        "vuedraggable": "^2.24.3",
        "vuelidate": "^0.7.5",
        "vuetify": "^2.4.8",
        "vuex": "^3.3.0",
        "vuex-persistedstate": "^4.0.0-beta.3",
        "webpack": "^5.9.0"
    },
    "devDependencies": {
        "@vue/cli-plugin-babel": "^4.5.12",
        "@vue/cli-plugin-eslint": "^4.5.12",
        "@vue/cli-service": "^4.5.12",
        "@vue/eslint-config-prettier": "^4.0.1",
        "axios": "^0.21.1",
        "babel-eslint": "^10.0.3",
        "bootstrap": "^4.0.0",
        "cross-env": "^7.0.3",
        "css-loader": "^5.2.7",
        "eslint": "^5.16.0",
        "eslint-plugin-prettier": "^3.1.3",
        "eslint-plugin-vue": "^5.0.0",
        "jquery": "^3.6.0",
        "laravel-mix": "^6.0.35",
        "lodash": "^4.17.21",
        "popper.js": "^1.12",
        "postcss": "^8.2.8",
        "replace-in-file-webpack-plugin": "^1.0.6",
        "resolve-url-loader": "^3.1.2",
        "sass": "^1.32.8",
        "sass-loader": "^8.0.2",
        "vue": "^2.5.17",
        "vue-cli-plugin-vuetify": "^2.3.1",
        "vue-loader": "^15.9.5",
        "vue-template-compiler": "^2.6.11",
        "vuetify-loader": "^1.3.0",
        "webpack-cli": "^3.3.12",
        "webpack-messages": "^2.0.4"
    }
}


via Chebli Mohamed

Hey Folks! Need guidance on developing page builder using Laravel and VUE js [closed]

Hello Everyone I hope you are having a great week. The thing is I wanted to develop a custom page builder like elementor; in Laravel and VUE js. I have no clue how to start this for example I have identified a few packages i.e. https://github.com/HansSchouten/PHPageBuilder. Now I don't know exactly how I will kick start the project, for example how the database will be used in such a project. If anyone has ever worked on such projects then your guide will be really helpful. Thanks



via Chebli Mohamed

Getting this error is laravel vue tailwind project

compile error

Its the error I am getting when I running npm run watch.



via Chebli Mohamed

mardi 26 octobre 2021

Assets not getting parsed in laravel

I have laravel 7.3 installed

  <link href="" rel="stylesheet" />
  <link href="" rel="stylesheet" />

assessing public folder from view

but getting 404 Not found.

Screenshot Attached enter image description here



via Chebli Mohamed

lundi 25 octobre 2021

Laravel Artisan event:generate command throwing a Fatal error

I'm following the official documentation for Laravel 5.7 on the events registration and generation: https://laravel.com/docs/5.7/events#generating-events-and-listeners

I have an EventServiceProvider with the following events defined:

<?php

namespace App\Providers;

use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;

class EventServiceProvider extends ServiceProvider
{

    /**
     * The event handler mappings for the application.
     *
     * @var array
     */
    protected $listen = [
        'App\Events\FormBeforeCreate' => [
            'App\Listeners\WebhookBeforeCreate',
        ],
        'App\Events\FormAfterCreate' => [
            'App\Listeners\NotifyAfterCreate',
            'App\Listeners\WebhookAfterCreate',
        ],
        'App\Events\FormBeforeUpdate' => [
            'App\Listeners\WebhookBeforeUpdate',
        ],
        'App\Events\FormAfterUpdate' => [
            'App\Listeners\NotifyAfterUpdate',
            'App\Listeners\WebhookAfterUpdate',
        ],
        'App\Events\FormBeforeDelete' => [
            'App\Listeners\WebhookBeforeDelete',
        ],
        'App\Events\FormAfterDelete' => [
            'App\Listeners\NotifyAfterDelete',
            'App\Listeners\WebhookAfterDelete',
        ],
        'App\Events\FormBeforeSave' => [
            'App\Listeners\WebhookBeforeSave',
        ],
        'App\Events\FormAfterSave' => [
            'App\Listeners\NotifyAfterSave',
            'App\Listeners\WebhookAfterSave',
        ],
    ];

    /**
     * The subscriber classes to register.
     *
     * @var array
     */
    protected $subscribe = [
        'App\Listeners\UserEventSubscriber',
    ];

    /**
     * Register any other events for your application.
     *
     * @return void
     */
    public function boot()
    {
        parent::boot();
    }
}

The error:

When I run the command php artisan event:generate I get the following error:

PHP Fatal error:  Call to a member function listens() on null in /app/vendor/laravel/framework/src/Illuminate/Foundation/Console/EventGenerateCommand.php on line 35

                                                           
  [Symfony\Component\Debug\Exception\FatalErrorException]  
  Call to a member function listens() on null

According to the doc, it should do this:

This command will generate any events or listeners that are listed in your EventServiceProvider. Events and listeners that already exist will be left untouched

I don't understant what I've missed since I didn't find any similar error by searching the web



via Chebli Mohamed

Image Upload Not working only for some of the mobile devices. "Failed to open stream: is a directory"

Image Upload Not working only for some of the mobile devices. The same link when opened in desktop or iPhone and some android devices its working fine. But for some mobiles all the browsers its not working and giving the below error.

"Failed to open stream: is a directory"

The code to save image is as follows :-

$data['scan_file']->storeAs('scan_file', "facetest-".str_replace(' ', '',$_FILES["scan_file"]["name"]));



via Chebli Mohamed

vendredi 22 octobre 2021

Composer not updating in laravel

I'm trying to run composer install on the terminal of cpanel but getting this error

Problem 1
    - Root composer.json requires nunomaduro/collision ^5.10 -> satisfiable by nunomaduro/collision[v5.10.0].
    - nunomaduro/collision v5.10.0 requires php ^7.3 || ^8.0 -> your php version (7.2.34) does not satisfy that requirement.
  Problem 2
    - laravel/framework[v8.54.0, ..., 8.x-dev] require php ^7.3|^8.0 -> your php version (7.2.34) does not satisfy that requirement.
    - Root composer.json requires laravel/framework ^8.54 -> satisfiable by laravel/framework[v8.54.0, ..., 8.x-dev].

I have already updated php version to PHP 7.3 (ea-php73) but still getting this error. Is there any way to properly run without updating php version

In error log i'm also getting this error:

PHP Fatal error: Uncaught TypeError: Argument 1 passed to Illuminate\Log\Logger::__construct() must be an instance of Psr\Log\LoggerInterface, instance of Monolog\Logger given, called in /home/----/vendor/laravel/framework/src/Illuminate/Log/LogManager.php on line 187 and defined in /home/----/vendor/laravel/framework/src/Illuminate/Log/Logger.php:43

Thanks



via Chebli Mohamed

how can i solve this error?, snappy usage

I've tried to find a way to solve this error, but haven't found it yet

```Declaration of Barryvdh\Snappy\IlluminateSnappyPdf::getFileContents($filename) must be compatible with Knp\Snappy\AbstractGenerator::getFileContents(string $filename): string```

above there is an error that i can't to solve



via Chebli Mohamed

jeudi 21 octobre 2021

Get 50k rows faster with subqueries - Laravel 5.6

The below query is to get the candidate's details from the table which has 50k rows. Including jobs, regions, and employment types. A candidate has basic details with employment type, jobs, regions are in another table with foreign key relation.

$candidates =  DB::table('candidates')
->join('role_users', function($join) use($datas) {
    $join->on('candidates.user_id', '=', 'role_users.user_id');
    $join->where('role_users.role_id', 6);

    if (isset($datas->login_time) && $datas->login_time != "") {
        $type = $datas->login_time;
        $dateRanges = getDateRanges($datas->login_time);
        if ($type == 1) {
            $join->whereNull('role_users.login_at');
        } else if ($type == 6) {
            $join->whereDate('role_users.login_at', '<', $dateRanges['start']);
        } else if ($type != 1 && $type != 6) {
            $join->whereBetween('role_users.login_at', [$dateRanges['start'], $dateRanges['end']]);
        }
    }
})
->join('candidate_statuses', 'candidates.candidate_status_id', '=', 'candidate_statuses.id')
->join('employment_types', 'candidates.employment_types_id', '=', 'employment_types.id')
->select(
    'candidates.id', 
    'candidates.user_id', 
    'candidates.candidate_code', 
    'candidates.first_name', 
    'candidates.last_name', 
    'candidates.full_name as name', 
    'candidates.profile_img',
    'candidates.employment_types_id', 
    'employment_types.title AS employment_type',
    DB::raw("(SELECT GROUP_CONCAT(candidate_jobs.job_id SEPARATOR ',') FROM candidate_jobs WHERE candidate_jobs.candidate_id = candidates.id) as job_ids"),
    DB::raw("(SELECT GROUP_CONCAT(regions.name SEPARATOR ',') FROM candidate_regions INNER JOIN regions ON regions.id=candidate_regions.region_id WHERE candidate_regions.candidate_id = candidates.id) as regions"),
    'candidates.formatted_mobile_number',
    'candidates.place',
    'candidates.post_code',
    'role_users.email',
    'role_users.login_at',
    'role_users.email',
    'candidates.has_access',
    'candidates.is_deleted')
->where(function ($query) use($datas, $request, $regCandidates, $jobCandidates, $status){
    
    if ($datas->employment_types) {
        $query->whereIn('candidates.employment_types_id', $datas->employment_types);
    }
    if ($status) {
        $query->whereIn('candidates.candidate_status_id', $status);
    }
    if ($datas->access === 1 || $datas->access=== 0) {
        $access = strval($datas->access);
        $query->where('candidates.has_access', $access);
    }
    if ($datas->candidates) {
        $query->whereIn('candidates.id', $datas->candidates);
    }
    if ($regCandidates) {
        $query->whereIn('candidates.id', $regCandidates);
    }
    if ($jobCandidates) {
        $query->whereIn('candidates.id', $jobCandidates);
    }
    if ($request->search) {
        $query->where('candidates.full_name', 'like', "%{$request->search}%");
        $query->orWhere('candidates.place', 'like', "%{$request->search}%");
        $query->orWhere('candidates.post_code', 'like', "%{$request->search}%");
        $query->orWhere('candidates.candidate_code', 'like', "%{$request->search}%");
        $query->orWhere('candidates.formatted_mobile_number', 'like', "%{$request->search}%");
    }
})
->where('candidates.candidate_status_id', '!=' , 6)
->where('candidates.is_deleted', $request->is_deleted)
->orderBy('candidates.first_name')
->groupBy('candidates.id')
->paginate($request->total);

if (count($candidates) > 0) {
    $candidates->map(function ($candidate) { 
        $job_ids = $candidate->job_ids != null 
                            ? explode(',', $candidate->job_ids)
                            : []; 
        $candidate->jobs = [];
        $candidate->has_access = $candidate->has_access == 1 ? true : false;
        $candidate->login_at = $candidate->login_at ? date('d-m-Y h:i A', strtotime($candidate->login_at)) : 'Never logged in';
        if($job_ids){
            $jobs = DB::table('jobs')->whereIn('id', $job_ids);
            $candidate->jobs = $jobs->get(['name', 'color']);
            $candidate->csvjobs = $jobs->pluck('name')->all();
        }
        $candidate->regions = $candidate->regions != null 
                            ? explode(',', $candidate->regions)
                            : []; 
        return $candidate;
    });
}

It takes 2/ 3 seconds to get the result in my local machine but in production takes too long time. Can anyone please help?



via Chebli Mohamed

How to setup Grpc in Laravel 5.4

I am trying to setup Grpc using this tutorial grpc . Is it anyone can give the details, how it setup in Larevel 5.4



via Chebli Mohamed

Fastly insert 200+ data to the tables with relationship - Laravel 5.6

Table: vacancies

id int unsigned Auto Increment code varchar(191) NULL
start_time timestamp NULL
end_time timestamp NULL
business_unit_id int unsigned
job_id int unsigned
on_date date
break int NULL
shift_id int unsigned
total_numbers int

Table: vacancy_details

id int unsigned Auto Increment vacancy_id int unsigned
day_id int unsigned
shift_id int unsigned
rate_type enum('flat_rate','hourly_rate') [hourly_rate]
start_time timestamp NULL
end_time timestamp NULL
break int NULL
total_hours decimal(10,2) NULL client_rate decimal(8,2) NULL

Table: vacancy_staff_rates

id int unsigned Auto Increment vacancy_id int unsigned
vacancy_detail_id int unsigned NULL
employment_type_id int unsigned
staff_rate decimal(8,2) NULL

public function store_multiple($subdomain, Request $request){
    if($request){
        $payloads = $request->data;
        foreach($payloads as $payload){
            $payload = (object) $payload;
            //insertion(3 tables) and all the calculations and logic are doing in this add_vacancy()
            $vacancy = Vacancy::add_vacancy($payload);
        }
    }
}

These are the 3 tables. When I'm adding 10 or 20 the insertion is fast but comes 100 or plus it's taking more time. Can anyone suggest a way to do it fatser?



via Chebli Mohamed

Laravel - Vue js application not showing data properly

working with Vue js and Laravel REST API. database is mysql. but when try show ContactList it is not displaying here.. web.php

Route::prefix('api')->group(function() {
    //get contact
    Route::get('getContacts','ContactController@getContacts');
});

ContactController.php

class ContactController extends Controller
{
    public function getContacts() {
        $contacts = Contact::all();
        return $contacts;
    }
}

ContactList.vue

  <tbody v-for="contact in contacts" :key="contact.id">
                <tr>
                    <th scope="row"></th>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td><button class="btn btn-danger btn-sm">Delete</button></td>

                </tr>
            </tbody>

        </table>
    </div>
</template>

<script>
export default {
    name:'Contact',
    created() {
        this.loadData();

    },
    methods: {
        loadData() {
            let url = this.url + '/api/getContacts';
            this.axios.get(url).then(response => {
                this.contacts = response.data
                console.log(this.contacts);
            });
        
        
        },
        mounted() {
            console.log('Contact List Component Mounted');
        },
        data() {
            return {
                url: document.head.querySelector('meta[name="url"]').content,
                contacts:[]
            }
        }
    }
}
</script>

console displaying following error **[Vue warn]: Property or method "contacts" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property. See: https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties.

found in

---> at resources/js/components/ContactList.vue **



via Chebli Mohamed

mercredi 20 octobre 2021

while select an image the file object comes with error and the mime type was "application/octet-stream" size is 0 but actual size is 30kb laravel

"file" => UploadedFile {#911

-test: false
-originalName: "smalllogo.png"
-mimeType: "application/octet-stream"
-size: 0
-error: 6
#hashName: null
path: ""
filename: ""
basename: ""
pathname: ""
extension: ""
realPath: "/var/www/html/apartshub"
aTime: 1970-01-01 00:00:00
mTime: 1970-01-01 00:00:00
cTime: 1970-01-01 00:00:00
inode: false
size: false
perms: 00
owner: false
group: false
type: false
writable: false
readable: false
executable: false
file: false
dir: false
link: false

}

when select an image and dd($request->file('file)) returns this i tried changes in php.ini file max_image_upload.but it works when i put this project into another server.php v 7.0,laravel 5.6



via Chebli Mohamed

Connection Could not be established with host smtp.gmail.com - Laravel

I'm trying to send email by using gmail(personal email address) but failed as below error. there is no error when I using a public network to send the email but failed when I using office network that comes with firewall setting.

I have tried the method to set the the mail_mailer to "sendmail" but still failed. Really appreciate if someone can help on this.

Below is my code in .env and also mail.php

code in .env

APP_NAME=KPI
APP_ENV=local
APP_KEY=base64:0SydcKbNLuXKE5PQgxlHIDWS/EGi8Sle2SrN2R+AGUo=
APP_DEBUG=true
APP_URL=http://localhost

LOG_CHANNEL=stack
LOG_LEVEL=debug

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=kpi
DB_USERNAME=root
DB_PASSWORD=

BROADCAST_DRIVER=log
CACHE_DRIVER=file
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120

MEMCACHED_HOST=127.0.0.1

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=example@gmail.com
MAIL_PASSWORD=example12345
MAIL_ENCRYPTION=tsl
MAIL_FROM_ADDRESS=example@gmail.com
MAIL_FROM_NAME="${APP_NAME}"

AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=

PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=mt1

MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"

code in mail.php

<?php

return [

    'default' => env('MAIL_DRIVER', 'smtp'),

    'mailers' => [
        'smtp' => [
            'transport' => 'smtp',
            'host' => env('MAIL_HOST', 'smtp.mailgun.org'),
            'port' => env('MAIL_PORT', 465),
            'encryption' => env('MAIL_ENCRYPTION', 'tsl'),
            'username' => env('MAIL_USERNAME'),
            'password' => env('MAIL_PASSWORD'),
            'timeout' => null,
            'auth_mode' => null,
        ],

        'ses' => [
            'transport' => 'ses',
        ],

        'mailgun' => [
            'transport' => 'mailgun',
        ],

        'postmark' => [
            'transport' => 'postmark',
        ],

        'sendmail' => [
            'transport' => 'sendmail',
            'path' => '/usr/sbin/sendmail -bs',
        ],

        'log' => [
            'transport' => 'log',
            'channel' => env('MAIL_LOG_CHANNEL'),
        ],

        'array' => [
            'transport' => 'array',
        ],
    ],

   

    'from' => [
        'address' => env('MAIL_FROM_ADDRESS', 'hello@example.com'),
        'name' => env('MAIL_FROM_NAME', 'Example'),
    ],
    
    'stream' => [
        'ssl' => [
            'allow_self_signed' => true,
            'verify_peer' => false,
            'verify_peer_name' => false,
        ],
    ],


    'markdown' => [
        'theme' => 'default',

        'paths' => [
            resource_path('views/vendor/mail'),
        ],
    ],

];

Error message



via Chebli Mohamed

What is the solution to the slider problem?

What is the solution to the problem that the slider does not show pictures on the mobile phone, but it appears naturally on the computer? Here is the link to the website to view the slides https://fidoctor.net



via Chebli Mohamed

how do I store data in cookies?

so this is my bootstrap modal I have a Controller from where m getting email list I want to set the selected email group as default dropdown using cookies suppose for example if i have Group 1 and Group 2 which contains list of email when a user sends or submits this form i want this modal to remember the previously selected Groups from dropdown

                <!-- Modal content-->
                <div class="modal-content">
                    <div class="modal-header">

                        <h4 class="modal-title">Send Report</h4>
                    </div>
                    <div class="modal-body">
                        <form>
                            <div>

                                <div class="row">

                                    <div class="mb-3 col">
                                        <label for="to-list" class="col-form-label"> To:</label>
                                        <!-- <input type="text" class="form-control" id="to-list" value=""> -->
                                        <textarea class="form-control" type="text" id="to-list" rows="3"></textarea>

                                    </div>
                                    <div class="input-group col ">
                                        <label for="to-name" class="col-form-label"> Select Group:</label>
                                        <select name="Group" listTarget='to-list' id="toList" class="list-btn form-control form-control-sm" >
                                            <option value="none" selected hidden></option>
                                            @foreach($emailgroups as $emailgroup)
                                            <option value=""></option>
                                            @endforeach
                                        </select>
                                    </div>

                                </div>
                                <div class="row">
                                    <div class="mb-3 col">
                                        <label for="cc-list" class="col-form-label"> Cc:</label>

                                        <textarea class="form-control" type="text" id="cc-list" rows="3"></textarea>
                                    </div>
                                    <div class="input-group col ">
                                        <label for="bcc-name" class="col-form-label"> Select Group:</label>
                                        <select name="Group" target='cc-list' class="list-btn form-control form-control-sm" id="ccList">
                                            <option value="none" selected hidden>select group</option>
                                            <option value="none" selected hidden></option>
                                            @foreach($emailgroups as $emailgroup)
                                            <option value=""></option>
                                            @endforeach
                                        </select>
                                    </div>

                                </div>
                                <div class="row">
                                    <div class="mb-3 col">
                                        <label for="bcc-list" class="col-form-label"> Bcc:</label>

                                        <textarea class="form-control" type="text" id="bcc-list" rows="3"></textarea>
                                    </div>
                                    <div class="input-group col ">
                                        <label for="bcc-name" class="col-form-label"> Select Group:</label>
                                        <select name="Group" class="list-btn form-control form-control-sm" id="bccList">
                                            <option value="none" selected hidden></option>
                                            @foreach($emailgroups as $emailgroup)
                                            <option value=""></option>
                                            @endforeach
                                        </select>
                                    </div>
                                </div>
                            </div>
                            <!-- <div class="mb-3">
                                <label for="recipient-name" class="col-form-label"> Add Recipient:</label>
                                <input type="text" class="form-control" id="recipient-name">
                            </div>
                             <div class="mb-3" id="show-recipient">

                            </div> -->
                        </form>
                    </div>
                    <div class="modal-footer">

                        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                        <button type="button" class="btn btn-primary" id="send-report">Send Report</button>
                    </div>
                </div>

            </div>
        </div>


via Chebli Mohamed

mardi 19 octobre 2021

"Encoding failed" FFMPEG laravel ProtoneMedia\\LaravelFFMpeg\\Exporters\\EncodingException(code: 0):

tried to upload a video with ffmpeg, got an error

(ProtoneMedia\\LaravelFFMpeg\\Exporters\\EncodingException(code: 0): Encoding failed at /app/vendor/pbmedia/laravel-ffmpeg/src/Exporters/EncodingException.php:12)

the strange thing is that there are only a few videos that can and can't be uploaded like an example data with video:

  1. test-video1.mp4 (success)
  2. test-video2.mp4 (failed)

Implementation


$mediaName= "425d17680ae04eb853d4c2e1da24a5aa.mp4"
$mediadisk= "media"
$tmpPath = $file->store('/tmp', temp_disk'));
$pathPrefix = 'member/2';

        $ffMpeg = FFMpeg::fromDisk(config('temp_disk'))->open($tmpPath);

        $dimension = $ffMpeg->getVideoStream()->getDimensions();

        $ffMpeg
            ->export()
            ->toDisk($mediadisk)
            ->save($videoPath = "{$pathPrefix}/videos/{$mmediaName}")
            ->getFrameFromSeconds(5)
            ->export()
            ->toDisk($thumbnailDisk = config('asset-inventory.image_disk'))
            ->save($thumbnailPath = $pathPrefix . '/media/thumbnail/' . $mediaName . '.png');

        return [
            'path' => $videoPath,
            'thumbnail_disk' => $thumbnailDisk,
            'thumbnail_path' => $thumbnailPath,
            'duration' => $ffMpeg->getDurationInSeconds(),
            'width' => $dimension->getWidth(),
            'height' => $dimension->getHeight()
        ];

Result :

ffmpeg failed to execute command '/usr/bin/ffmpeg' '-y' '-i'

"[object] (ProtoneMedia\\LaravelFFMpeg\\Exporters\\EncodingException(code: 0): Encoding failed at /app/vendor/pbmedia/laravel-ffmpeg/src/Exporters/EncodingException.php:12)
[stacktrace]
#0 /app/vendor/pbmedia/laravel-ffmpeg/src/Exporters/MediaExporter.php(172): ProtoneMedia\\LaravelFFMpeg\\Exporters\\EncodingException::decorate(Object(FFMpeg\\Exception\\RuntimeException))

FFMPEG Version :

ffmpeg version 4.3.2-0+deb11u2 Copyright (c) 2000-2021 the FFmpeg developers
built with gcc 10 (Debian 10.2.1-6)
configuration: --prefix=/usr --extra-version=0+deb11u2 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-pocketsphinx --enable-libmfx --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
libavutil      56. 51.100 / 56. 51.100
libavcodec     58. 91.100 / 58. 91.100
libavformat    58. 45.100 / 58. 45.100
libavdevice    58. 10.100 / 58. 10.100
libavfilter     7. 85.100 /  7. 85.100
libavresample   4.  0.  0 /  4.  0.  0
libswscale      5.  7.100 /  5.  7.100
libswresample   3.  7.100 /  3.  7.100
libpostproc    55.  7.100 / 55.  7.100```


via Chebli Mohamed

lundi 18 octobre 2021

i am getting this error while generating PDF with laravel

Undefined offset: 1 (View: /var/www/html/bds/livesystems/aegispest.bigdreams.in/resources/views/pdf/normal_invoice_table.blade.php) (View: /var/www/html/bds/livesystems/aegispest.bigdreams.in/resources/views/pdf/normal_invoice_table.blade.php)

this is the error I'm getting

  <div class="col-xs-2 b-r">
        <h4 class="text-center"> <?php echo e(Company::frequency_no($qtys[$i]) ?? 1); ?> <?php echo e($invoice->category == 'custom' ?  '' :'Service'); ?><?php echo e((Company::frequency_no($qtys[$i]) ?? 1) > 1 ? 's':''); ?><?php echo e($invoice->category == 'custom' ? ($unit_name[$i] ?? '') :''); ?></h4>


via Chebli Mohamed

Getting error "Target Class Not Found" while trying to use old way of calling controllers at web.php

I'm using Laravel 8 and I wanted to use the old way of calling controller and routes in web.php.

So instead of saying this:

Route::get('/home', [App\Http\Controllers\HomeController::class, 'index'])->name('home');

I would call the Controller like this:

Route::get('/home', 'HomeController@index')->name('home');

So I added this to AppServiceProvider.php:

public function boot()
    {
        Route::prefix('web')
            ->middleware('web')
            ->namespace('App\Http\Controllers') // <---------
            ->group(base_path('routes/web.php'));
    }

But it doesn't seem to be working because I'm getting this error:

Target class [HomeController] does not exist.

So how can I call my Controller at web.php like the old style which was used in Laravel 5 versions?



via Chebli Mohamed

Based on array key set if condition in controller laravel function

I have filter section on page in that various filter will be there. When i click on that filters I am getting below array in controller function dd($request)

+request: Symfony\Component\HttpFoundation\InputBag {#52
    #parameters: array:2 [
      "resolution" => array:1 [
        0 => "HD"
      ]
      "categorypro" => array:2 [
        0 => "11"
        1 => "12"
      ]
    ]
  }

So i want add condition as follows:

  1. When i select resolution filter then going only resolution condition
  2. When i select categorypro filter then going only resolution condition
  3. IF select both resolution and categorypro filter then going in other codition

If am trying below codition in controller

function filter_each_video(Request $request){
    if(request()->ajax()){

        if($request->has('resolution') && ($request->get('resolution')!= null)){
                echo "1";
            }
        elseif($request->has('categorypro') && ($request->get('categorypro')!= null)){
                echo "2";   
            }
        elseif(($request->has('categorypro') && ($request->get('categorypro')!= null)) & ($request->has('resolution') && ($request->get('resolution')!= null)))
        {
                echo "3";
        }
    }
}

In my codition if i select both the filters categorypro and resolution then its not going in both the condition in echo "3".

If anyone have idea how to do this then let me know. If any changes or something wrong in code then let me know



via Chebli Mohamed

Can't access object values in Laravel blade loop

I'm facing strange behavior when trying to access object values in Laravel blade.

My data looks like the following:

<?php


array:11 [▼
  "Monday, 18.10.2021" => array:6 [▶
    1 => array:1 [▶
      0 => {#1532 ▶
        +"id": 252
        +"status": 1
        +"heading": "Online Event für Test #1"
        +"customer": "Test #1"
        +"event_type_id": 12
        +"slug": "event_11111"
        +"datetime": "2021-10-18 10:00:00"
        +"name": "Online Event"
        +"duration": 3
      }
    ]
    2 => array:1 [▶
      0 => {#1501 ▶
        +"id": 252
        +"status": 1
        +"heading": "Online Event für Test #1"
        +"customer": "Test #1"
        +"event_type_id": 12
        +"slug": "event_11111"
        +"datetime": "2021-10-18 10:00:00"
        +"name": "Online Event"
        +"duration": 3
      }
    ]
    3 => []
    5 => []
    6 => []
    31 => []
  ]
  "Tuesday, 19.10.2021" => array:6 [▶
    1 => []
    2 => []
    3 => []
    5 => []
    6 => []
    31 => []
  ]
  "Wednesday, 20.10.2021" => array:6 [▶
    1 => []
    2 => []
    3 => []
    5 => []
    6 => []
    31 => []
  ]
  "Thursday, 21.10.2021" => array:6 [▶
    1 => []
    2 => []
    3 => []
    5 => []
    6 => []
    31 => []
  ]
  "Friday, 22.10.2021" => array:6 [▶
    1 => array:1 [▶
      0 => {#1637 ▶
        +"id": 253
        +"status": 1
        +"heading": "Online Event für Test #2"
        +"customer": "Test #2"
        +"event_type_id": 12
        +"slug": "event_22222"
        +"datetime": "2021-10-22 14:00:00"
        +"name": "Online Event"
        +"duration": 5
      }
    ]
    2 => array:1 [▶
      0 => {#1615 ▶
        +"id": 253
        +"status": 1
        +"heading": "Online Event für Test #2"
        +"customer": "Test #2"
        +"event_type_id": 12
        +"slug": "event_22222"
        +"datetime": "2021-10-22 14:00:00"
        +"name": "Online Event"
        +"duration": 5
      }
    ]
    3 => []
    5 => []
    6 => []
    31 => []
  ]
  "Saturday, 23.10.2021" => array:6 [▶
    1 => []
    2 => []
    3 => []
    5 => []
    6 => []
    31 => []
  ]
  ....

And my blade file like this:

<?php

             @foreach($overview_pivot as $datetime => $users)
                <tr>
                  <td></td>
                  @foreach($users as $user_id => $user_events_array)
                  <td>
                    @foreach($user_events_array as $events)
                      <ul class="list-group list-group-flush" data-toggle="checklist">
                        @foreach($events as $event)

                           //Works fine
                            

                           //Error
                            
                        
                        @endforeach
                      </ul>
                    @endforeach

                  </td>
                  @endforeach
                </tr>

              @endforeach

Problem:

When I try accessing the object everything works fine, but when I try to echo object values (e.g. ). I get the error "Trying to get property 'id' of non-object".

Any idea what's wrong with my code?



via Chebli Mohamed

dimanche 17 octobre 2021

Laravel Nova limit the results in indexQuery

I ran intro a situation where I need to limit the results of a resource to only 3 results. To be more specific, based on the logged user role, I need to limit the results only to 3 for security reasons and at the moment this is not working:

public static function indexQuery(NovaRequest $request, $query)
{
    if(auth()->user()->role != 'admin') return $query->limit(3);

    return $query;
}

The result:

enter image description here

Looks like the condition is not taken into consideration.



via Chebli Mohamed

Is it possible to tamper with data ID edit page (laravel)

I have a question that has been bugging me for a while. Is it possible for a hacker to tamper with data during update? Like change the id number on edit.blade.php page form action using inspect element And if "Yes" how can it be prevented

Will really appreciate it if u can help with an answer?



via Chebli Mohamed

Laravel whereHas Returns all records

ı have have 3 tables in my projects they are -Products(can have Multiple Variants ) -Variants (belongsto product) -product_attributes (this have product_id,attribute_id,value_id)

ı want to filter variants from a product by value ids thats comes from form request as example (1,2,6) ı have tried like this :

$poruduct_id=$request->product_id; $value_ids=$request->value_ids
$searched_variants=Variant::whereHas( 'product.attributeValues' , function ($query) use($value_ids,$product_id){ $query->whereIn('value_id',[$value_ids]); })->where('product_id',$product_id)->get();

dd($searched_variants);

but the problem is the query returns all records from the product .. what is the solition to filter exacly the values that the product Variants have ? thank u



via Chebli Mohamed

samedi 16 octobre 2021

override CSRF in form:open

I am using Litespeed and its cache for my larval app I have installed the package litespeed/lscache-laravel

I am generating csrf as

@if(env('ESI_ENABLED'))
<input type="hidden" frm="cache" name="_token" value='<esi:include src="/csrf"  />'>
@else
<input type="hidden" id="_token" value="">
@endif

this works fine.

but the issue is

{!! Form::open(['route'=>'signin.post','method'=>'post']) !!}

this adds csrf hidden input automatically so how do I override it to add my own ?



via Chebli Mohamed

Array on where clause laravel

I have an array of values I want to pass into my where clause when querying a model

How do I achieve this?

I have $categorypro variable getting below array in this format

Array
(
    [0] => 4
    [1] => 8
    [1] => 5
)

Currently I am doing this in controller but not getting proper data some category

Below is my controller code :

function filter_each_video(Request $request){
        if(request()->ajax()){
if($request->has('categorypro') && ($request->get('categorypro')!= null)){
                $categorypro = $request->get('categorypro');
                $item = Item::whereIn('category_id', $categorypro)->get();
            }
}
}

If any one have better idea then let me know . Or something wrong in this then give some idea



via Chebli Mohamed

vendredi 15 octobre 2021

how to fix '403 Forbidden error' after hosting laravel project in cpanel?

My project before it was in 'nginx server', now I downloaded and hosted to cpanel server. When I opened website in home page it shows error specified in below attached image. and there is no error in log.

403 error

laravel version laravel version

PHP version 7.4

and given permission to storage and bootstrap 0755.

please if anyboday know to fix it, please do help me.



via Chebli Mohamed

Laravel queue stopped suddenly with any error code

I have an annoying issue with laravel queue

First of all i have a cron job ran every 6 hours and this cron job add more than 70 job in the database

after that queue start dispatching the jobs but after 49 or 50 jobs, the laravel queue stopped suddenly and the laravel log sometimes record this error

[2021-10-15 16:45:06] production.ERROR: The process has been signaled with signal "1". {"exception":"[object] (Symfony\\Component\\Process\\Exception\\ProcessSignaledException(code: 0)

i'm using this command to run the queue

php artisan queue:listen

and also tried this

php artisan queue:work


via Chebli Mohamed

Laravell placeholder color

I am new to Laravell. This is my code.


Kindly guide me, how I can add placeholder color.



via Chebli Mohamed

I'm having Storing Items from my Cart to the Database

I've made an ecommerce platform and I want to store the users order whenever they select a product and make a purchase. I've already made the order model and migrations. But I don't know how to push the users order to the mysql db through the OrderController. I'm not typing in the orders so I appear to be facing issues. Can someone kindly offer me any assistance if they know how.

**Order Model**

protected $table = "orders";
protected $fillable = ["product_name","price","total","qty","paid","delivered","user_id"];

**Migrations**

public function up()
{
    Schema::create('orders', function (Blueprint $table) {
        $table->id();
        $table->string('product_name');
        $table->decimal('price',8,2)->nullable;
        $table->decimal('total',8,2)->nullable;
        $table->integer('qty')->default(0);
        $table->boolean('paid')->default(0);
        $table->boolean('delivered')->default(0);
        $table->unsignedBigInteger('user_id');
        $table->timestamps();
    });
}


via Chebli Mohamed

jeudi 14 octobre 2021

Is there any function in sql to apply customize fields values and get those values in where clause

for example i have data in sql table like this id event_name duration 1 Demo 20-mins 2 Party 5-hours 3 Camp 4-days

and I'm getting the mins , so i want to update these fields first in the mins than put them in the where clause like below

$product_result->where(CommonHelper::getProductDuration('duration'),"=", $request->duration);


via Chebli Mohamed

AMQP error while attempting pushRaw: ACCESS_REFUSED - operation not permitted on the default exchange

I have this application in Laravel 5.5 with PHP7.0. I am using this package vyuldashev/laravel-queue-rabbitmq

for pushing and receiving jobs from RabbitMQ. Here is my config:

'worker' => [
            'driver' => 'rabbitmq',
            'factory_class' => \Enqueue\AmqpLib\AmqpConnectionFactory::class,
            'host' => env('RABBITMQ_HOST'),
            'port' => env('RABBITMQ_PORT'),
            'vhost' => env('RABBITMQ_VHOST'),
            'login' => env('RABBITMQ_LOGIN'),
            'password' => env('RABBITMQ_PASSWORD'),
            'queue' => env('RABBITMQ_JOB_QUEUE') . ',' . env('RABBITMQ_PROCESSED_QUEUE'),
            'options' => [
                'exchange' => [
                    'name' => env('RABBITMQ_EXCHANGE_NAME', null),
                    'declare' => env('RABBITMQ_EXCHANGE_DECLARE', true),
                    'type' => env('RABBITMQ_EXCHANGE_TYPE', \Interop\Amqp\AmqpTopic::TYPE_DIRECT),
                    'passive' => env('RABBITMQ_EXCHANGE_PASSIVE', false),
                    'durable' => env('RABBITMQ_EXCHANGE_DURABLE', true),
                    'auto_delete' => env('RABBITMQ_EXCHANGE_AUTODELETE', false),
                    'arguments' => env('RABBITMQ_EXCHANGE_ARGUMENTS'),
                ],
                'queue' => [
                    'name' => env('RABBITMQ_EXCHANGE_NAME', env('RABBITMQ_JOB_QUEUE') . ',' . env('RABBITMQ_PROCESSED_QUEUE')),
                    'declare' => env('RABBITMQ_QUEUE_DECLARE', true),
                    'bind' => env('RABBITMQ_QUEUE_DECLARE_BIND', true),
                    'passive' => env('RABBITMQ_QUEUE_PASSIVE', false),
                    'durable' => env('RABBITMQ_QUEUE_DURABLE', true),
                    'exclusive' => env('RABBITMQ_QUEUE_EXCLUSIVE', false),
                    'auto_delete' => env('RABBITMQ_QUEUE_AUTODELETE', false),
                    'arguments' => env('RABBITMQ_QUEUE_ARGUMENTS'),
                ],
            ],
        ],

Now as you can see in the "queue" index I have defined two queues. In the lower part of the config the index "queue" contains an array with "name" as having the same two queues. It works fine on my local env but on test server it throws this error:

AMQP error while attempting pushRaw: ACCESS_REFUSED - operation not permitted on the default exchange

Now this is my requirement that the same worker is monitoring two queues. I have to do it. How can I achieve this? Any solutions?



via Chebli Mohamed

how do i ingoer inputs that dosn't have a data in update method

i have a form to update user data name and email and username the qustion is if user want to update only user how i keep same email and name or change only name in my case the valdetion required all inputs this is my controller

 public function update(Request $request, $username )
{
    if($username != Auth::user()->username){
        return abort('401');
    }

    $request->validate([

        'name' => 'min:10|max:50|required',
        'username' => 'unique:users|max:30|min:3|required',
        'email' => 'email|unique:users|max:200|required',

    ]);
    $checkuserindb = User::findOrFail(Auth::user()->id);

        $checkuserindb->update([
            'name' => $request->name,
            'username' => $request->username,
            'email' => $request->email
        ]);
        return redirect()->route('userProfile', $request->username)->with('message', 'your account has been updated!');



}


via Chebli Mohamed

import excel sheet in Laravel display some error can any one help me

SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'name' cannot be null (SQL: insert into users (name, email, password, updated at, created at) values (?, ?, $2y$10$dXRS9INabV4phXE9hmrQCeNrgaPF0sQvJj9Pe1XfR/vTL/Z6D228K, 2021-10-14 05:55:22, 2021-10-14 05:55:22))



via Chebli Mohamed

mercredi 13 octobre 2021

(1/1) ErrorException Undefined offset: 96 cuando intento guardar me sale este error por pantalla

intento agregar esa fila con todos [ 0, 0,0,0,0,0,0,] pero cuando intento guardar no guarda y sale este error. enter image description here enter image description here

enter image description here

if (isset($request->journal_entry_id)) { foreach ($request->journal_entry_id as $index => $journal_entry_id) { $history = JournalEntryHistory::where('journal_entry_id', '=', $journal_entry_id) ->where('client_id', '=', $client->id) ->where('year', '=',$request->year) ->groupBy('order') ->select(DB::raw('SUM(value) as value')) ->get();

            for ($i = 0; $i < 12; $i++) {
                $value = $request->journal_entry_value[($index * 12) + $i];
                $history_value = count($history) > $i ? $history[$i]->value : 0;
              
               

                $journal_entry_history = new JournalEntryHistory();
                $journal_entry_history->client_id = $client->id;
                $journal_entry_history->journal_entry_id = $journal_entry_id;
                $journal_entry_history->month = $data['inventory_date_month'][$i];
                $journal_entry_history->value = $value - $history_value[0];
                $journal_entry_history->overages = 0;
                $journal_entry_history->created_at = Carbon::now();
                $journal_entry_history->order = $i + 1;
                $journal_entry_history->year = $request->year;
                $journal_entry_history->save();
            }
        }
    }


via Chebli Mohamed

create string route in script blade laravel

I´m traying to create function with function onClick(parameter) that call one function and redirect to one route in laravel, but my problem it´s that this route have 3 parameter.

Route::get('llamadas/estadisticas/pasadas/{operator}/{fromDate},{toDate}', 'EstadisticaLlamadaController@getStateCallCommercial')->name('llamadas.estadisticas.pasadas');

my function it´s:

function redirectFunction(operator)
    {
        let fromDate = $("#fromDate").val();
        let toDate = $("#toDate").val();
        
        var yearStart = fromDate.substring(0,4);
        var monthStart = fromDate.substring(5,7);
        var dayStart = fromDate.substring(8,10);

        var yearEnd = toDate.substring(0,4);
        var monthEnd = toDate.substring(5,7);
        var dayEnd = toDate.substring(8,10);

        fromDate = dayStart + "-" + monthStart + "-" + yearStart;
        toDate = dayEnd + "-" + monthEnd + "-" + yearEnd;

        var url = "";
        url = url.replace(':operator', operator);
        url = url.replace(':fromDate', fromDate);
        url = url.replace(':toDate', toDate);
        console.log(url);
        //window.location.href = url;
    }

i need set this parameter in my route. I´m using url because i can´t use route, always return that parameter it´s incorrect. I know that it´s better to use Route

i need create this route for send this data to my controller that execute query and return this results to blade to generate statistics with chart.js and i need all parameter. But i cant generate nothing if i don´t send good my data.

now i´m returning this:

http://localhost:5080/gdsRepository/public/admin.llamadas.estadisticas.pasadas/%3Aoperator/%3AfromDate/%3AtoDate

if i do:

var url = "";

return this:

http://localhost:5080/gdsRepository/public/admin.llamadas.estadisticas.pasadas/%22%2Boperator%2B%22/%22%2BfromDate%2B%22/%22%2BtoDate%2B%22

anybody can help me, please??

thanks for readme and help me



via Chebli Mohamed

Whenever I run npm run prod in laravel 8 root.. I receive this message [closed]

webpack compiled successfully The toast encountered an error. Please make sure that the app id is set correctly. Command Line: E:\xammp\htdocs\blog\node_modules\node-notifier\vendor\snoreToast\snoretoast-x64.exe -appID "Laravel Mix" -pipeName \.\pipe\notifierPipe-be3c4644-6dd8-4bea-8944-cbfac6e8d1f7 -p E:\xammp\htdocs\blog\node_modules\laravel-mix\icons\laravel.png -m "Build successful" -t "Laravel Mix" هر گاه دستور npm run prod اجرا میکنم عملیات درست پیش میره و خروجی میگیرم اما این خطا بعدش ظاهر میشه علتش؟



via Chebli Mohamed

How to display json collection data convert in array in display in blade file laravel

I want to display json data into the blade file . I am getting data in json format. I am not getting how to convert json data and display

Below is my contoller :

$item = Item::where('active_status', 1)->where('status', "1");
$formats = DB::table('items')->select('format')->distinct()->get();
$fps = DB::table('items')->select('fps')->distinct()->get();

return view('frontend.pages.explore', compact('data','formats','fps'));
         

Blade file as follows:

    <div class="filter-btn">
    
    @foreach(json_decode($formats, true) as $data)
        
        <a class="btn btn-white-outline display-4" href=""></a>
    @endforeach
   </div>

In i am getting below output :

[{"format":null},{"format":"4K"},{"format":"HD"}]

SO i want display this value in tag.

Anyone have idea then let me know



via Chebli Mohamed

mardi 12 octobre 2021

send notification without using User model

How can I send a notification without having to use the user model?

   public function SendSeguimiento(Request $request){


   $toUser = Clientes::find(2);


    

   Notification::send($toUser, new Seguimiento($toUser));
    // $pageName = 'widgets';
    return redirect()->route("clientes");
}

i try to send a notification to the email of the table 'Clientes' in row 2

database: enter image description here

Error:

enter image description here

help pls



via Chebli Mohamed

Laravel - why a 419 response when request size is too large?

When we make a request to our database with a nine hundred or more IDs in the request body we are hit with a 419 | Page Expired response. However when we make the same request with 800 or fewer IDs the request executes successfully. Why would a large request size throw a 419 error?

On the frontend we add IDs to the request and the request object looks like this:

class MyCustomRequest extends FormRequest
{
    public function authorize(): bool
    {
        return true;
    }

    public function rules(): array
    {
        return [
            'object_ids'   => 'required|array|min:1',
            'object_ids.*' => 'required|integer',
        ];
    }
}

I don't think it has to do with our session_lifetime is defaulted to 24 hours. The 419 response comes back pretty quickly too:

'lifetime' => env('SESSION_LIFETIME', 86400),

Any idea why we are getting 419 response when there are 900 or more object_ids present in the request?



via Chebli Mohamed

Laravel :doesn't have a default value

SQLSTATE[HY000]: General error: 1364 Field 'product_name' doesn't have a default value

<?php

namespace App\Http\Controllers;


use Illuminate\Http\Request;
use App\product;

class productController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        $data = [];
        $data['title'] = "index page";
        return view('product.index', $data);
    }

    /**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function create()
    {
        $data = [];
        $data['title'] = "create page";
        return view('product.create', $data);
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function store(Request $request)
    {
        $data = $request->all();
        //    $product=new product();  
        //    $product->product_name=$data['pro_name'];  /
        //    $product->description=$data['description'];
        //    $product->Starting_Date_and_Time=$data['SDAT'];
        //    $product->Ending_Date_and_Time=$data['EDAT'];
        //    $product->save();
        $product = product::create($data);   
        dd($product);
    }

    /**
     * Display the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function show($id)
    {
        //
    }

    /**
     * Show the form for editing the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function edit($id)
    {
        return view('product.edit');
    }

    /**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function update(Request $request, $id)
    {
        //
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function destroy($id)
    {
        return 'product delete';
    }
}


via Chebli Mohamed

lundi 11 octobre 2021

Parse date format in laravel carbon

I am tryin to parse date format using laravel carbon. Here I tried

dd(Carbon::parse('2021-10-12T09:20:27:915 GMT+0600')->format('Y-m-d h:i:s'));

It shows DateTime::__construct(): Failed to parse time string (2021-10-12T09:20:27:915 GMT+0600) at position 19 (:): Unexpected

Thanks in advance



via Chebli Mohamed

Displaying API Data through a blade view

there's a problem I've facing for the past couple of weeks. Although I've made a little bit of progress, displaying saved data from an API seems to be something that I'll be struggling with since it's the first time I've ever used an API.

I'm using a payment API which is supposed to store the customers payment detail(s) in the mysql database. That includes the transaction id, amount and their phone number as you can see here. The transaction id is saved on the 'mpesa_trans_id'

I want to take the latest transaction Id that's been saved when the customer pays, and display it on the customers view as shown here although it isn't showing here.

Here's the code for the controller that's supposed to be handling the transaction id.

//Confirming the transaction Id that's stored in the database:

    public function confirmPayment(Request $request){
    $request->validate(['transactionId'=>'required']);
    $transId = $request->transactionId;
    $exists = Payment::where('mpesa_trans_id',$transId)->latest()->first();
    //Here you can redirect to the same page, because the payment is not successful or the transaction id provided does not match any payment
    if(!$exists){
        $error= ["success"=>false, "error"=>"Unable to confirm your transaction code. Please contact admin.. :)"];
        session($error);
        return back();
    }
    $message = ["success"=>true, "message"=>"Payment successful!"];
    session($message);
    return view('/confirm', ['transId' => $transId]);
}

//Confirmation blade

        <div class="login-inner-block">
                    @foreach($pays as $pay)
                        <div class="frm-grp">
                            <label>@lang('Transaction Id')</label>
                            <input type="text" name="transactionId" value="" placeholder="@lang('Example: OIB9FQP9H7')">
                            <span class="text-box">Your Transaction Id Is</span>
                            <span></span>
                    @endforeach
                        </div>
                    
                    <div class="btn-area text-center">
                        <button type="submit"  class="submit-btn">@lang('Confirm Payment')</button>
                    </div>
                    <br>

When I was entering the transaction id through the text box, everything was working fine. But now, I want to display the transaction Id automatically without entering it in the text box. But when I try to refresh the website, I get an error 'Undefined variable:$pays'.

How's can I get rid of this error and display the latest transaction Id in the view? If you have knowledge of passing a variable from an API controller, kindly help me



via Chebli Mohamed

Not getting condiotions if statement and else statement

$tickets  = Ticket::select("tickets.cust_id","tickets.ticket_id","tickets.category_id","tickets.subject","tickets.priority","tickets.message","tickets.status","tickets.createdticket","tickets.last_reply","tickets.closing_ticket","tickets.auto_close_ticket","tickets.created_at","tickets.updated_at","groups_categories.group_id","groups_users.users_id")
   ->leftJoin('groups_categories','groups_categories.category_id','tickets.category_id')
   ->leftJoin('groups_users','groups_users.groups_id','groups_categories.group_id')
   ->get();

Above code is my query. I want the show the ticket according the login users



via Chebli Mohamed

Laravel Query: How to groupBy DB:raw queries

I'm currently working on user_score table where I need to display all the users score data like number of attempts, avg score, etc. I need to display the data by quiz id and I'm having problems on getting the number of attempts. as you can see below I have two data or two attempts now i want to group them and count as 2 attempts. Is there a way to group them since I used DB:raw and when I used groupby it's not working. Can anyone help me, thank you!

Sample image of the query response

Here is my code:

$remarks = DB::table('user_scores')->where('quiz_id',$id)
->Join('quiz_information','quiz_information.id', '=', 'quiz_id')
->rightJoin('users','users.id', '=', 'user_id')
->select(DB::raw('COUNT(user_scores.user_id) as Attempts'),'quiz_information.quiz_title AS Quiz Title','total_points AS Points','number_of_correct_answers',
    'users.name AS Name',DB::raw('if(remarks=1,"passed","failed") as STATUS'), DB::raw("AVG(number_of_correct_answers) AS Average"),
    'user_scores.created_at AS Date and Time') 
// ->select('quiz_information.quiz_title AS Quiz Title','total_points AS Points','number_of_correct_answers',
// 'users.name AS Name','remarks as STATUS', 'user_scores.created_at AS Date and Time')
->groupBy('quiz_title','total_points','number_of_correct_answers','name','remarks','user_scores.created_at')
->get()
->toArray();


return response(['message'=>"Remarks successfuly shown", 
'error'=>false,
'error code'=>200,
'line'=>"line".__LINE__."".basename(__LINE__),
'quizRemarks'=>$remarks],200,[],JSON_NUMERIC_CHECK);
}


via Chebli Mohamed

dimanche 10 octobre 2021

How to get result from database based on the user with laravel

I started coding laravel and everything was fine till I wanted to get the result based on the user, how to do it, what do I need to do?.



via Chebli Mohamed

Displaying Transaction Id to the customers view

I've been making an eCommerce laravel system and I've been struggling with showing the customers their transactions Id after they've completed all their payment. I'm using an API to carry out the transaction. After the user has successfully carried out the payment, the transaction Id is then saved to the database. Now, I want to take the transaction id, and display it on the customers view so that they can print an invoice. Here's the controller that's supposed to be handling all the transaction Id:

public function confirmPayment(Request $request){
    $request->validate(['transactionId'=>'required']);
    $transId = $request->transactionId;
    $exists = Payment::where('mpesa_trans_id',$transId)->latest()->first();
    if(!$exists){
        $error= ["success"=>false, "error"=>"Unable to confirm your transaction code. Please contact admin.. :)"];
        session($error);
        return back();
    }
    $message = ["success"=>true, "message"=>"Payment successful!"];
    session($message);
    return back();
}

Here's how I've tried to display the transaction id on the customers view

                        <div class="frm-grp">
                            <label>@lang('Transaction Id')</label>
                            <input type="text" name="transactionId" placeholder="@lang('Example: OIB9FQP9H7')">
                            <span class="text-box">Your Transaction Id Is</span>
                            <span></span>
                        </div>

Which also gives me an error 'Undefined variable: transId'. I didn't put the @foreach yet.

Can someone please assist me on figuring out the solution to this problem? This is where the transaction id is supposed to be displayed after the customer makes a payment



via Chebli Mohamed