Laraveldeep

Laraveldeep

Member Since 2 Years Ago

Experience Points 29,070
Experience
Level
Lessons Completed 202
Lessons
Completed
Best Reply Awards 2
Best Answer
Awards
  • Start Your Engines Achievement

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • First Thousand Achievement

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • One Year Member Achievement

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • Two Year Member Achievement

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • Three Year Member Achievement

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • Four Year Member Achievement

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • Five Year Member Achievement

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • School In Session Achievement

    School In Session

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

  • Welcome To The Community Achievement

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • Full Time Learner Achievement

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • Pay It Forward Achievement

    Pay It Forward

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

  • Subscriber Achievement

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • Lifer Achievement

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • Laracasts Evangelist Achievement

    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 Achievement

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • Laracasts Veteran Achievement

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • Ten Thousand Strong Achievement

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • Laracasts Master Achievement

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • Laracasts Tutor Achievement

    Laracasts Tutor

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

  • Laracasts Sensei Achievement

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • Top 50 Achievement

    Top 50

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

28 Sep
1 month ago

Laraveldeep left a reply on How To Execute 'LIKE' Raw Query With Binding?

@Yorki

It doesn't work. However thanks for giving the variation idea. After some experiment, figured out that apostrophe is not needed (its kind of redundant).

This works

DB::select("SELECT * FROM `users` WHERE `name` LIKE :name", ['name' => '%' . $request->name . '%']);

or

DB::select("SELECT * FROM `users` WHERE `name` LIKE ':name'", ['name' => "%$request->name%"]);

Thanks

Laraveldeep left a reply on How To Execute 'LIKE' Raw Query With Binding

@rin4ik

That doesn't work. It lacks apostrophe. Should be

DB::select("SELECT * FROM `users` WHERE `name` LIKE '%$request->name'%'");

This works but prone to attack because we are directly using whats provided on request.

The reason I am trying to run with named binding is to leverage the data sanitation provided by Laravel out of the box.

https://laravel.com/docs/5.6/database#running-queries

Laraveldeep started a new conversation How To Execute 'LIKE' Raw Query With Binding

Hi,

This works

DB::select("SELECT * FROM `users` WHERE `name` = :name", ['name' => $request->name]);

But this returns empty result

DB::select("SELECT * FROM `users` WHERE `name` LIKE '%:name%'", ['name' => $request->name]);

What is wrong with second query?

Thanks!

24 May
5 months ago

Laraveldeep left a reply on [L5.5] 302 Redirect With MethodNotAllowed Exception

Ok my bad... Nothing weird. My input field name is email and my error render field is nouser... that's why. :)

23 May
5 months ago

Laraveldeep started a new conversation [L5.5] 302 Redirect With MethodNotAllowed Exception

I am trying to do basic stuff here on backend. Show email search form and find user and present on same page.

My we.php

Route::get('/siteadmin/manage-users', 'Backend\[email protected]');
Route::post('/siteadmin/find-user', 'Backend\[email protected]');

My Controller Actions

    public function showFindUserForm()
    {
        return view('backend.finduser');
    }

    public function findUser(FindUser $request)
    {

    // for testing if error renders on view
        return redirect()->back()->withErrors(['nouser', 'no such user']);

    }

My view blade

@extends('layouts.app')

@section('content')

    <div class="section">

        <div class="container">
    
            @include('backend.partials.usersearchform')

            @if(!empty($user))

                <div class="box">
                    <p class="has-text-weight-semibold">{{ $user->name }}</p>
                    <p><span class="has-text-weight-semibold">Group:</span> {{ $user_group }}</p>
                    <div class="field">

                    </div>
                </div>

            @endif

        </div>
    
    </div>

@endsection

My view partials that contains the form

<div class="section">

    <div class="container">

        <div class="level">

            <div class="level-item has-text-centered">

                <form action="/siteadmin/find-user" method="POST">

                    {{ csrf_field() }}

                    <div class="field has-addons">

                        <div class="control">
                            <input class="input" type="text" name="email" placeholder="Enter email" required>
                        </div>


                        <div class="control">
                            <button class="button is-primary">
                                <span class="icon">
                                    <i class="fas fa-search"></i>
                                </span>
                            </button>
                        </div>


                        @if ($errors->has('nouser'))
                            <p class="help is-danger">
                                {{ $errors->first('nouser') }}
                            </p>
                        @endif

                    </div>

                </form>

            </div>

        </div>

    </div>

</div>

Seems pretty standard but somehow I am getting 302 with MethodNotAllowed when I check the network section and error never renders.

Any Suggetion?

20 May
5 months ago

Laraveldeep left a reply on Strange "Cannot Find Module 'shebang-command'" Error On Npm Run Dev

Finally I figured this out.

Its because I don't have libpng-dev installed on my fresh installation of Ubuntu.

This is required by pngquant-bin, which is required by laravel-mix. This somehow disturbed the installation of shebang-command and 'laravel-mix`.

Solution:

$sudo apt install ligpng-dev



And on laravel project

$ rm -rf node_modules
$ npm cache clear
$ npm install
$ npm run dev

Solved!

Laraveldeep left a reply on Strange "Cannot Find Module 'shebang-command'" Error On Npm Run Dev

I even tried npm cache clean followed by npm install after removing node_modules. Only error I get is that fsevents is not insatalled. That should be fine becasue fsevents are for Mac OSX only.

npm WARN optional Skipping failed optional dependency /chokidar/fsevents:
npm WARN notsup Not compatible with your operating system or architecture: [email protected]
npm WARN optional Skipping failed optional dependency /watchpack/chokidar/fsevents:
npm WARN notsup Not compatible with your operating system or architecture: [email protected]
npm WARN optional Skipping failed optional dependency /webpack-dev-server/chokidar/fsevents:
npm WARN notsup Not compatible with your operating system or architecture: [email protected]
npm WARN [email protected] requires a peer of [email protected]^6.0.0 but none was installed.
npm ERR! Linux 4.15.0-20-generic
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "install"
npm ERR! node v8.10.0
npm ERR! npm  v3.5.2
npm ERR! code ELIFECYCLE

npm ERR! [email protected] postinstall: `node lib/install.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] postinstall script 'node lib/install.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the pngquant-bin package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node lib/install.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs pngquant-bin
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls pngquant-bin
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /var/www/html/myblog/npm-debug.log

But npm run dev still gives me same error.

19 May
5 months ago

Laraveldeep started a new conversation Strange "Cannot Find Module 'shebang-command'" Error On Npm Run Dev

Hi,

I just set up new Ubuntu 18.04 and cloned my previously working project from repo.

composer install, npm install all went fine

But during npm run dev I am getting this error:

> @ dev /var/www/html/myblog
> npm run development


> @ development /var/www/html/myblog
> cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js

module.js:549
    throw err;
    ^

Error: Cannot find module 'shebang-command'
    at Function.Module._resolveFilename (module.js:547:15)
    at Function.Module._load (module.js:474:25)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/var/www/html/myblog/node_modules/cross-spawn/lib/util/readShebang.js:5:22)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)

npm ERR! Linux 4.15.0-20-generic
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "run" "development"
npm ERR! node v8.10.0
npm ERR! npm  v3.5.2
npm ERR! code ELIFECYCLE
npm ERR! @ development: `cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules--config=node_modules/laravel-mix/setup/webpack.config.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ development script 'cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js'.
npm ERR! Make sure you have the lamyblog version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the  package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /var/www/html/myblog/npm-debug.log

npm ERR! Linux 4.15.0-20-generic
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "run" "dev"
npm ERR! node v8.10.0
npm ERR! npm  v3.5.2
npm ERR! code ELIFECYCLE
npm ERR! @ dev: `npm run development`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ dev script 'npm run development'.
npm ERR! Make sure you have the lamyblog version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the  package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     npm run development
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /var/www/html/myblog/npm-debug.log

In my other machine it is working perfectly fine.

Any suggestion on this?

Thanks!

12 Nov
1 year ago

Laraveldeep left a reply on Using Blade Inside Of A Vue Templates Properly

@jekinney is right

Let say our example vue component is <emailaddr></emailaddr>

Example Vue component:

<template>
    // few other things
    <p>{{ errorMessage }}</p>

</template>

<script>
export default {
    props: ['errorMessage'],
    // other stuffs

}
</script>

Example Blade:

@if ($errors->has('email'))
    <emailaddr></emailaddr>
@elseif 
    <emailaddr error-message="{{ $errors->first('email') }}"></emailaddr>
@endif

Laraveldeep left a reply on `input.files` Not Recognized In Single Page Vue Component

My bad, I used computed instead of method.

Laraveldeep started a new conversation `input.files` Not Recognized In Single Page Vue Component

Hi,

I am trying to move already tested file upload input field as single file Vue component. I have tested this script already and working fine while used on global scope but when the code is moved to component, I am getting the error.

computed: {
    myMethog: function(event) {
        var input = event.target;
        if(input.files && input.files[0]) {
            // do something here
        }
    }
}

Renderer is throwing this error

[Vue warn]: Error in render: "TypeError: Cannot read property 'files' of undefined"

why?

Same code works when it is not inside component.

10 Nov
1 year ago

Laraveldeep left a reply on Missing Required Client Configuration Options: Region While Trying To Implement S3

Well after upgrade and restarting tinker I am getting the correct setting and region issue is resolved.

Laraveldeep left a reply on Missing Required Client Configuration Options: Region While Trying To Implement S3

That's what I did initially (set those on .env). After that I hard coded that on filesystems.php.

On both case I am getting same error that region parameter is not set or missing.

cache is cleared too... Now I am getting null for everything like mentioned before.

Any other clue?

Laraveldeep left a reply on Missing Required Client Configuration Options: Region While Trying To Implement S3

@gregrobson

After update I got null for everything... really weird

>>> config('filesystems.disks.s3')
=> [
     "driver" => "s3",
     "key" => null,
     "secret" => null,
     "region" => null,
     "bucket" => null,
   ]
>>>

Laraveldeep left a reply on Missing Required Client Configuration Options: Region While Trying To Implement S3

I just upgraded Laravel from 5.5.14 to 5.5.20 with composer update just in case. Now I am getting null for everything from config.

Getting same error while tinkering

Storage::disk('s3')->files()

Weird

Laraveldeep left a reply on Missing Required Client Configuration Options: Region While Trying To Implement S3

@robrogers3

It gives me

[
            'driver' => 's3',
            'key' => env('AWS_KEY'),
            'secret' => env('AWS_SECRET'),
            'region' => env('AWS_REGION'),
            'bucket' => env('AWS_BUCKET'),
]

region is there. Not sure where is the fault. These are set from my environment file. I have tried also adding the settings on config/filesystems.php but still getting same message.

09 Nov
1 year ago

Laraveldeep left a reply on Missing Required Client Configuration Options: Region While Trying To Implement S3

Can somebody point me to right direction? I am not sure what's wrong with my current config.

07 Nov
1 year ago

Laraveldeep left a reply on Missing Required Client Configuration Options: Region While Trying To Implement S3

Thanks @Robstar

Just to test, I have tried playing with various region. However it have no effect. The error remains the same.

Seems like whatever I set on filesystem.php or .env the region variable is not propagated properly back to the driver. Well... not sure

Also the changes you have mentioned must be just recent ones.

I have a fresh installation of 5.5 from past release with these

        's3' => [
            'driver' => 's3',
            'key' => env('AWS_KEY'),
            'secret' => env('AWS_SECRET'),
            'region' => env('AWS_REGION'),
            'bucket' => env('AWS_BUCKET'),
        ],

Have tested it using the new keys but error still remains same.

I guess variable name changes in this regard doesn't matter. Whatever is in filesystem.php, if we have it on .env it won't be a problem.

Any other clue?

Laraveldeep started a new conversation Missing Required Client Configuration Options: Region While Trying To Implement S3

Hi,

I am trying to test my file upload sent to s3. I have already installed the package league/flysystem-aws-s3-v3 ~1.0

In my .env file I have set the credentials needed by config/filesystems.php like this:

AWS_KEY=my_key
AWS_SECRET=my_secret
AWS_REGION=us-east-1
AWS_BUCKET=my_bucket

However when I try to store the uploaded file, it is giving me this Error

File: 

vendor\aws\aws-sdk-php\src\ClientResolver.php


Message:

Missing required client configuration options: region: (string) A "region" configuration value is required for the "s3" service (e.g., "us-west-2"). A list of available public regions and endpoints can be found at http://docs.aws.amazon.com/general/latest/gr/rande.html.

I have no idea why it is throwing error and what to look for.

06 Nov
1 year ago

Laraveldeep left a reply on How To Show Error On Particular Field On Blade For Field Array?

I found the solution quicker than I thought from my last posts answer

@if ($errors->has('photo.'.$number'))
    {{ $errors->first('photo.'.$number) }}
@endif

Key point it was not obvious to me was, we don't need to put braces inside blade directives.

Laraveldeep left a reply on How To Show Error On Particular Field On Blade For Field Array?

I found the solution quicker than I thought from my last posts answer

@if ($errors->has('photo.'.$number'))
    {{ $errors->first('photo.'.$number) }}
@endif

Key point it was not obvious to me was, we don't need to put braces.

Laraveldeep left a reply on Error Message Not Showing For Dynamically Generated Form Elements

Oh my bad.

What was I thinking :)

Thanks for pointing that out.

Laraveldeep started a new conversation How To Show Error On Particular Field On Blade For Field Array?

My form field

<input class="file-input" type="file" name="photo[]" accept="image/*">

As per documentation (), my validation rule

'photo.*' => 'file|image|mimes:jpeg, bmp, png'

Lets say I have 6 of these fields.

When validation fails, i know it will flash the error message with particular field like:

photo.0
photo.1
and so on..

Question: How to catch that on blade so that I can show the error message only on particular filed where error occurred?

This doesn't work, when error occurs all fields shows error message

@if ($errors->has('photo.*'))

This doesn't get triggered either. Seems like value passed is not parsed at all.

@if ($errors->has('photo.{{ $number }}'))

Any idea or work around?

Laraveldeep started a new conversation Error Message Not Showing For Dynamically Generated Form Elements

Hi,

I have form element which I generate using for loop depending upon how many I like and each element have error message associated with it.

Let's say:

<input name="myinput{{ $number }}" value="some_value">


@if ($errors->has('myinput{{ $number }}')) <---- This doesn't trigger when validation fails.
    <p class="help is-danger">
        {{ $errors->first('myinput{{ $number }}') }} <--- I know this is not allowed but this is my intention.
    </p>
@endif
  1. Why its not triggered?
  2. Is there a way around for what I am trying to do for showing message?

Thanks!

16 Oct
1 year ago

Laraveldeep left a reply on Laravel[5.5] Presets (Give It A Try)

@codenex didn't know about that. Thanks for the info.

Anyway I have moved my project to organization https://github.com/laravel-frontend-presets

Some of the presets we maintain at this time are Bulma, Zurb Foundation and uikit3. https://packagist.org/packages/laravel-frontend-presets/

If you can contribute, kindly join.

Thanks!

05 Oct
1 year ago

Laraveldeep left a reply on Dynamic Content In Master Page Sidebar

Not sure what is exactly required but I am guessing a kind of view composer type solution..

Have a look at this: https://laravel.com/docs/5.5/views#view-composers

19 Aug
1 year ago

Laraveldeep left a reply on Add/Update Cache Control Metadata On S3 Objects

@Robstar yep I solved this using aws-cli... much quicker

02 Aug
1 year ago

Laraveldeep left a reply on Response Code To SNS Subscription Confirmation Not Working

@awhite yes I was able to solve this. My case was I forgot to set the subscription message as RAW. You can find that in AWS SNS console under other subscription actions -> edit subscription attributes. Because of this I was not able to get the JSON data I was expecting.

My code is similar to the one suggested by @martinbean

Just in case if you want to check this out here is my full code

AmazonSNSController.php

<?php

namespace App\Http\Controllers\AWS;

use Illuminate\Http\Request;

use App\User;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Storage;


class AmazonSNSController extends Controller
{


    // handle bounced emails
    public function handleBounces(Request $request)
    {

        // $bounce_simulator_email = '[email protected]';

        // get bounce message
        $payload = json_decode($request->getContent());


      if(property_exists($payload, 'Type'))
      {
        if($payload->Type === "SubscriptionConfirmation")
        {
            // if we are verifying notification subscription in this Endpoint for the
            // first time then go the said URL to confirm
            $confirmation_url = curl_init($payload->SubscribeURL);
            curl_exec($confirmation_url);
        }
      }
        else // process bounces
        {
        // You have to set "subscription attribute to RAW" on endpoints from SNS console to get JSON message
        $notificationType = $payload->notificationType;
        $bounceType = $payload->bounce->bounceType;
        $bounced_email = $payload->bounce->bouncedRecipients[0]->emailAddress; //get first email


        // take action
        if($notificationType === 'Bounce')
        {

            if($bounceType === "Transient")
            {
                // increment soft bounce count
                User::where(['email' => $bounced_email])->increment('softbounced');
            }
            else
            {
                // mark email as bounced permanently
                User::where(['email'=> $bounced_email])->update(['bounced' => 1]);
            }


            //mark as hard bounced for emails which has soft bounced count of 3 or more
            User::where(['email' => $bounced_email, 'softbounced' => 3])->update(['bounced' => 1]);

        }

        }

    }




    // handle email complaints
    public function handleComplains(Request $request)
    {

        // $complaint_simulator_email = '[email protected]';

      $payload = json_decode($request->getContent());


      if(property_exists($payload, 'Type'))
      {
        if($payload->Type == "SubscriptionConfirmation")
        {
          // if we are verifying notification subscription in this Endpoint for the
          // first time then go the said URL to confirm
          $confirmation_url = curl_init($payload->SubscribeURL);
          curl_exec($confirmation_url);
        }
      }
      else
      {
        // You have to set "subscription attribute to RAW" on endpoints from SNS console to get JSON message
        $notificationType = $payload->notificationType;
        $complaint_email = $payload->complaint->complainedRecipients[0]->emailAddress; // get the first one


        if($notificationType === 'Complaint')
        {
            // Mark complained for this email
            User::where(['email'=> $complaint_email])->update(['complained' => 1]);
        }
      }


  }

}


I have these columns on my users table.

Hope this helps.

22 Jul
1 year ago

Laraveldeep started a new conversation Zurb Foundation 6 Preset For Laravel 5.5

As title says, try out this preset.

Pretty easy to use.

php artisan preset foundation // for basic preset

or

php artisan preset foundation-auth // for preset, Auth route entry and Foundation Auth views on single go

Details at: https://github.com/laravel-frontent-presets/zurb-foundation

https://packagist.org/packages/laravel-frontend-presets/zurb-foundation

Give it a try.

Feedback welcome

Thanks!

20 Jul
1 year ago

Laraveldeep left a reply on Getting 'r Is Not Defined' Error

Orphaned r can be found here on app.js:

/**
 * Echo exposes an expressive API for subscribing to channels and listening
 * for events that are broadcast by Laravel. Echo and event broadcasting
 * allows your team to easily build robust real-time web applications.
 */

// import Echo from 'laravel-echo'

// window.Pusher = require('pusher-js');

// window.Echo = new Echo({
//     broadcaster: 'pusher',
//     key: 'your-pusher-key'
// });
r; <-----------------

Any clue?

All I did was changed the Jquery version down to 2.2.4.

Laraveldeep started a new conversation Getting 'r Is Not Defined' Error

Hi,

I am testing the laravel dev version 5.5. After npm run dev I am seeing this error on console

Uncaught ReferenceError: r is not defined
    at Object.VERSION (app.js:15236)
    at __webpack_require__ (app.js:20)
    at Object.<anonymous> (app.js:15163)
    at __webpack_require__ (app.js:20)
    at Object.<anonymous> (app.js:15148)
    at __webpack_require__ (app.js:20)
    at app.js:63
    at app.js:66

Not sure what is causing this. Any idea?

Thanks!

18 Jul
1 year ago

Laraveldeep left a reply on Laravel[5.5] Zurb Foundation Preset

Added Bulma.

Please give it a try and send feedback.

All you have to do is to laravel new myapp --dev then copy the folders as instructed here https://github.com/Laraveldeep/Laravel-Scaffolding-Presets

Thanks!

17 Jul
1 year ago

Laraveldeep left a reply on Laravel Executing GET Instead Of POST Request

I suspect your form tag has missing action="URL" section

Laraveldeep started a new conversation Laravel[5.5] Zurb Foundation Preset

Hi,

When I heard of Laravel preset on 5.5, I was wondering about the great feature plus what will be included and how to include my favorite framework if not present in bundle.

With this in mind, I started tinkering and came up with the working Zurb Foundation preset. During the pull request, it was denied that no more presets will be entertained. So thought of integrating and using presets in unofficial way.

This is the easiest method (unofficial) I came up with. Have tried and working perfectly fine. Kindly give it a try and tell what do you think.

Actually its not hard to do things manually either but if presets are available, it can save few more minutes.

Download the preset here: https://github.com/Laraveldeep/Laravel-Scaffolding-Presets

Thanks and peace!

14 Jul
1 year ago

Laraveldeep left a reply on Using Foundation Zurb 6.3.0 With Laravel 5.4

Exactly, this have in discussed on 5.3 thread. I found this tutorial with explanation.

http://somethingnewtutorial.blogspot.com/2017/07/using-foundation-6-with-laravel-5.html

Laraveldeep left a reply on Zurb Foundation For Sites V6 Tabs Not Working

how did you install the foundation? via npm?

what about the correct version of Jquery used by foundation?

Take a look at this:

http://somethingnewtutorial.blogspot.com/2017/07/using-foundation-6-with-laravel-5.html

same process for L5.3 as well. You will be using gulp instead of laravel-mix.

Hope this helps.

Hope in L5.5 we already have preset for Foundation as well.

21 Jun
1 year ago

Laraveldeep left a reply on How To Keep Ordering Intact For Find By Array Collection?

Long method solved the problem like this:

$mykeys = array(1,5,6,3,2,4);

$users = collect(); // https://laravel.com/docs/5.4/collections
foreach($mykeys as $key)
{
  $users->push(Users::find($key));
}

dd($users);

Still want to know if there is sweet short method.

Laraveldeep started a new conversation How To Find Records By Array But Keep Order Intact?

Hi,

I need to fetch some records by passing array of primary key but I need the fetched records ordered according the passed key. How can I do that?

I noticed that it fetched the records but also sorts by primary key in ascending order. I need to prevent this.

No such thing mentioned on documentation: https://laravel.com/docs/5.4/eloquent#retrieving-single-models.

Basically what I am doing is:

$mykeys = array(1,5,6,3,2,4);

$users = Users::find($mykeys);

I am getting the collection but sorted. I want it sorted as per my key passed.

Thanks!

15 Jun
1 year ago

Laraveldeep left a reply on AWS SNS Topic Subscription Not Working

Ok after few tests I am able to confirm the subscription.

The fault is in my 'VerifyCsrfToke` middleware entry.

Used this and it worked:

protected $except = [
    '/sns*',
];

Laraveldeep started a new conversation AWS SNS Topic Subscription Not Working

Hi,

I am sending email from L5.3 application through AWS SES. I need to handle bounces and complains from sent email through SNS topic. So I have this for testing purpose:

web.php

Route::post('/sns/handle-bounces', 'AWS\[email protected]');
Route::post('/sns/handle-complains', 'AWS\[email protected]');

AmazonSNSController

public function handleBounces(Request $request)
{
  $payload = $request->getContent();
  Storage::put('public/payload.txt', $payload); //just write to text file what AWS SNS had sent
  die();
}

So I have added exception to these two methods at VerifyCsrfToken.php

<?php

namespace App\Http\Middleware;

use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as BaseVerifier;

class VerifyCsrfToken extends BaseVerifier
{
    /**
     * The URIs that should be excluded from CSRF verification.
     *
     * @var array
     */
    protected $except = [
        '/sns/handle-bounces',
        '/sns/handle-complains',
    ];
}

My site is HTTPS so I have correctly added the Endpoint URL in AWS console for SNS topic subscription and sent the Request Confirmation via SNS console. But I am not getting any text file I was expecting. Seems like method never executed.

Need some input on this.

Thanks in advance!

18 May
1 year ago

Laraveldeep left a reply on How Can I Implement My Own Custom Code Blocks?

Thanks @Cronix

After googling around I think it will be simple solution for me to do what I said I won't do :)

By the way I forgot to mention that this is controlled environment so no worries. Basically I am trying to avoid HTML tags when entering text in CMS for general users. Instead use another intuitive pair of characters to denote certain things, which will be replaced later for formatting purposes. Like:

Hello {John} will be later displayed to Hello <b>John</b>
Hello [John] becomes Hello <i>John</i>

I only need very few of them, so PHP str_replace with blade {! !} seems to fit my needs instead of using full package.

So basically solved like this:

$search_chars = array('{', '}', '[', ']');
$replace_chars = array('<b>', '</b>', '<i>', '</i>');

{! str_replace($search_chars, $replace_chars, $whatever_text_in_DB) !}

All I have to do is to add items on array if I need more tags.

Laraveldeep started a new conversation How Can I Implement My Own Custom Code Blocks?

Basically I need to implement custom code block to display formatting purpose, something like this on laracast (https://help.github.com/articles/basic-writing-and-formatting-syntax/)

How can I do that for text coming out from my DB?

Don't like to type HTML tags on the text and tell blade to ignore it.

Thanks!

12 Dec
1 year ago

Laraveldeep left a reply on Response Code To SNS Subscription Confirmation Not Working

After some search, found something about CORS.

As suggested here http://en.vedovelli.com.br/2015/web-development/Laravel-5-1-enable-CORS/

I have created my middleware and implemented on my controller already (not sure if this is required).

Still I my controller is not receiving any message.

It seems there is no way to test this on localhost. Testing in live server makes debugging a bit tedious.

I have tried to write the whole request to a text file too for testing purpose but nothing gets written either... makes me think that controller is not receiving anything in the first place.

Really appreciate some suggestion.

Laraveldeep left a reply on Response Code To SNS Subscription Confirmation Not Working

After some tests, seems like my controller is not getting any post request from SNS. Its somehow blocked.

I already have disabled CSRF token verification for this controller.

Am I missing something?

Laraveldeep left a reply on Response Code To SNS Subscription Confirmation Not Working

Thanks @martinbean

I am already using aws-sdk for SES.

I have "aws/aws-sdk-php": "~3.0", in my composer.json

By the way can you please explain a bit about the code?

My old implementation is something like this:

if subscription confirmation
then go to the requested url to confirm
else
its a notification message so do something about it like mark on DB as hard bounded, soft bounced or complaint.

Really appreciate if you can share a working sample.

Thanks!

Laraveldeep started a new conversation Response Code To SNS Subscription Confirmation Not Working

Hi,

I have translated my old PHP code to laravel for this. Old code is working fine.

Old code:

        $postBody = file_get_contents('php://input');
        
        $message_data = json_decode($postBody);
        
        if($message_data->Type == "SubscriptionConfirmation") {
            $confirmation_url = curl_init($message_data->SubscribeURL);
            curl_exec($confirmation_url);
        }

New Code:

        $message_data = json_decode($request->all());


        if($message_data->Type == "SubscriptionConfirmation")
        {
            $confirmation_url = curl_init($message_data->SubscribeURL);
            curl_exec($confirmation_url);
        }

I believe my code is correct and working but some other things probably I am not aware of.

I have already exempted this route from csrf token verification.

Are there any other cross domain stuffs I should be aware of?

From SNS console I am not getting any response from my site's endpoint when I send the subscription cofirmation request.

Thanks!

Laraveldeep left a reply on Add/Update Cache Control Metadata On S3 Objects

Will try this later and update.

For the mean time I have solved the issue using aws-cli to update the cache control for thousands of files already uploaded.

Planning to integrate this feature on CMS I am currently working.

Thanks!

11 Dec
1 year ago

Laraveldeep started a new conversation Add/Update File Cache Control Metadata On S3 Objects

Hi,

How to add/update "cache-contorl"meta data on S3 using filesystem? Documentation only mentions the metadata about size etc. https://laravel.com/docs/5.3/filesystem

Thanks!

Laraveldeep started a new conversation Nginx Gzip Question

I saw a comment on nginx site configuration that gzip should be disabled of SSL to avoid BREACH attacks.

Discussion thread seems bit old as of now. Is this issue fixed?

My site is https. Can I enable gzip on SSL now?

As per google page speed test, I am getting 47/100. What else can I do to make response faster?

I already have images served from AWS Cloudfront with compression enabled.

Also I have set up the expires header like this based on the tutorial by Digital Ocean https://www.digitalocean.com/community/questions/leverage-browser-caching-for-nginx

#Expires map
map $sent_http_content_type $expires {
        default                    off;
        text/html                  epoch;
        text/css                   max;
        application/javascript     max;
        ~image/                    max;
        image/svg+xml                   max;
        application/x-font-ttf          max;
        application/x-font-truetype     max;
        application/x-font-opentype     max;
        application/font-woff           max;
        application/font-woff2          max;
        application/vnd.ms-fontobject   max;
        application/font-sfnt           max;
}

But google page speed test still suggest to leverage browser cache (no expiry defined for images).

not sure why.

This is my first nginx setup.

Really appreciate some help.