Laraveldeep

Laraveldeep

Member Since 2 Years Ago

Experience Points 29,840
Experience Level 6

160 experience to go until the next level!

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

  • Complete a lesson — 100pts
  • Create a forum thread — 50pts
  • Reply to a thread — 10pts
  • Leave a reply that is liked — 50pts
  • Receive a "Best Reply" award — 500pts
Lessons Completed 206
Lessons
Completed
Best Reply Awards 2
Best Reply
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.

23 Dec
1 month ago

Laraveldeep left a reply on Why Laravel 5.7 Email Verification Link Requires Logged In User?

It gives me

Call to a member function getKey() on null

on vendor/laravel/framework/src/Illuminate/Foundation/Auth/VerifiesEmails.php

    /**
     * Mark the authenticated user's email address as verified.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     * @throws \Illuminate\Auth\Access\AuthorizationException
     */
    public function verify(Request $request)
    {
        if ($request->route('id') != $request->user()->getKey()) {  <------ HERE
            throw new AuthorizationException;
        }
 
        if ($request->user()->markEmailAsVerified()) {
            event(new Verified($request->user()));
        }
 
        return redirect($this->redirectPath())->with('verified', true);
    }

Laraveldeep started a new conversation Why Laravel 5.7 Email Verification Link Requires Logged In User?

Hi,

I just noticed today that email verification link redirects to login page if user is not logged in.

Verification link only verifies if the registered user is logged in.

How can I modify this behavior?

In my app only thing I modified is not to automatically login user during registration process

My RegisterController.php method override:

    public function register(Request $request)
    {
        $this->validator($request->all())->validate();

        event(new Registered($user = $this->create($request->all())));

        // $this->guard()->login($user);

        // return $this->registered($request, $user)
                        // ?: redirect($this->redirectPath());

        return view('auth.registration_thanks');

    }

Thanks!

20 Dec
1 month ago

Laraveldeep left a reply on [L5.7] InvalidArgumentException : No Connector For []

Seems like its a bug.

I have similar code using L5.4 and L5.6. Didn't find any issue with sending mails.

Not sure though

Laraveldeep started a new conversation [L5.7] Middleware Interfering With Queue:work

This is a follow up question relating to my previous issue

https://laracasts.com/discuss/channels/laravel/l57-invalidargumentexception-no-connector-for

Question: Why queue:work is affected by middleware?

Thanks!

Laraveldeep left a reply on [L5.7] InvalidArgumentException : No Connector For []

So at last I figured out that the culprit is my middleware. My newsletter controller have middleware called 'admin' (that only admins are allowed to send newsletter). Disabling that worked fine as usual.

Subscribing part (controller) doesn't have any because its public, so any site visitor can subscribe. It was working from before.

How can middleware interfere with the queue job? probably I should start another thread on this topic.

Laraveldeep started a new conversation Something Off With The Time

Hi,

I have noted that the time displayed for posts seems incorrect. I have started a thread only few hours ago but it is showing that its started 15 hours before. Same for the notification too.

Thanks!

Laraveldeep left a reply on [L5.7] InvalidArgumentException : No Connector For []

Nope. I tried using 'medium' queue for confirmation mail and it works but newsletter mail doesn't go through even if I put on 'high' priority queue.

Not sure what's wrong. Let me look at the Newsletter Mail class itself. I am sure its something blunder.

Thanks for your time.

Laraveldeep left a reply on [L5.7] InvalidArgumentException : No Connector For []

newsletter subscription confirmation part (its inside try catch block, which is sent after making a subscriber entry in database)

$confirm_mail = (new SubscribeConfirmMail($confirm_link))->onQueue('high');

Mail::to($request->subscribe_email)->queue($confirm_mail);

Actual newsletter sending part

foreach (Subscriber::WhereNotNull('verified_at')->where('active', true)->where('hard_bounced', false)->where('complained', false)->cursor() as $subscriber) {

    $composed_newsletter = (new DailyNewsletter($request->newsletter_subject))->onQueue('medium');

    // send mail
    Mail::to($subscriber->email)->queue($composed_newsletter);
    
}

This ones gets into jobs database but won't send.

Can you see any thing? I have no clue what's wrong. I am sure it is very small.

Laraveldeep left a reply on [L5.7] InvalidArgumentException : No Connector For []

.env

QUEUE_CONNECTION=database

As I said other mail jobs get sent but not this one.

Any clue what else could that be?

Laraveldeep started a new conversation [L5.7] InvalidArgumentException : No Connector For []

When I tried to send mails using queue:work it just says processing. So after some search I found a way to log the event why it failed as suggested on documentation

https://laravel.com/docs/5.7/queues#failed-job-events and https://stackoverflow.com/questions/48199475/laravel-5-5-queue-no-connector-for

My laravel.log shows:

   InvalidArgumentException  : No connector for []

  at /var/www/html/taazacoupons57/vendor/laravel/framework/src/Illuminate/Queue/QueueManager.php:172
    168|      */
    169|     protected function getConnector($driver)
    170|     {
    171|         if (! isset($this->connectors[$driver])) {
  > 172|             throw new InvalidArgumentException("No connector for [$driver]");
    173|         }
    174| 
    175|         return call_user_func($this->connectors[$driver]);
    176|     }

  Exception trace:

  1   Illuminate\Queue\QueueManager::getConnector()
      /var/www/html/taazacoupons57/vendor/laravel/framework/src/Illuminate/Queue/QueueManager.php:156

  2   Illuminate\Queue\QueueManager::resolve("daemon")
      /var/www/html/taazacoupons57/vendor/laravel/framework/src/Illuminate/Queue/QueueManager.php:138

  Please use the argument -v to see more details.

What does this mean and whats wrong?

P.S. My mail subscription verification mail goes fine. I am using mail trap to check that. However this newsletter mail fails.

I have no clue.

Thanks!

Laraveldeep started a new conversation Mixing HTML Tags Inside Mail Markdown Question

Hi,

I am trying to use some styled HTML tags inside mail::table component in my mail markdown for newsletter.

Actually it is like this:

@component('mail::message')

@component('mail::table')
| Today's Popular Items |
| ---------------------- |
@foreach ($items as $item)
| <a href="some url", style="text-decoration: none; etc. etc." {{ $item->name}} </a> |
@endforeach

@endcomponent

@endcomponent

While testing, it renders fine but when queuing it seems to have problem. Among list of subscribers, I can see only one entry on jobs table (using database for queue). Also while trying to send that mail using queue:work it keeps on trying without sending

Q1. Are HTML tags with inline styling allowed inside markdown? I suspect problem with the slot parser. Where is this log saved?

Q2. What is the alternative to what I am trying to do? Another option I see is grab the html source from rendered page and modify and use that as view instead of markdown but I will have to worry about modifying several mails if template changes.

Thanks!

Laraveldeep left a reply on Laravel 5.7 Pagination Error - Only First Link Works

Try this

{{ $admins->appends(Request::except('page'))->links() }}

If you have query string on URL, you need to include those without page parameter. I suspect the reason it stays on page 1 is page=1 is included on your query string (since you have appended all) .

28 Sep
4 months 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
8 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
8 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
8 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
8 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.