Laraveldeep

Laraveldeep

Member Since 3 Years Ago

Experience Points 30,850
Experience Level 7

4,150 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 215
Lessons
Completed
Best Reply Awards 2
Best Reply
Awards
  • start-engines Created with Sketch.

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • first-thousand Created with Sketch.

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • 1-year Created with Sketch.

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • 2-years Created with Sketch.

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • 3-years Created with Sketch.

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • 4-years Created with Sketch.

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • 5-years Created with Sketch.

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • school-session Created with Sketch.

    School In Session

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

  • welcome-newcomer Created with Sketch.

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • full-time-student Created with Sketch.

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • pay-it-forward Created with Sketch.

    Pay It Forward

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

  • subscriber-token Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer-token Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • lara-evanghelist Created with Sketch.

    Laracasts Evangelist

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

  • chatty-cathy Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

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

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

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

27 Feb
5 months ago

Laraveldeep left a reply on Ping To Homestead Is Fine But Connection Refused

Looks its fine

[email protected]:~$ systemctl status nginx
? nginx.service - A high performance web server and a reverse proxy server
   Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
   Active: active (running) since Wed 2019-02-27 05:55:12 UTC; 59min ago
     Docs: man:nginx(8)
  Process: 861 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
  Process: 613 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
 Main PID: 866 (nginx)
    Tasks: 2 (limit: 2319)
   CGroup: /system.slice/nginx.service
           +-866 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
           +-867 nginx: worker process

Feb 27 05:55:11 homestead systemd[1]: Starting A high performance web server and a reverse proxy server...
Feb 27 05:55:12 homestead systemd[1]: nginx.service: Failed to parse PID from file /run/nginx.pid: Invalid argument
Feb 27 05:55:12 homestead systemd[1]: Started A high performance web server and a reverse proxy server.

Not sure though why nginx.pid parse failed

[email protected]:~$ sudo nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

26 Feb
5 months ago

Laraveldeep started a new conversation Ping To Homestead Is Fine But Connection Refused

Hi,

I have setup the L5.7 Homestead on my Windows 10 machine and did the vagrant up but I can't open the site.

I am getting www.myapp.local refused to connect. on browser. I do have entry on hosts file

192.168.10.10 www.myapp.local

Pinging on 192.168.10.10 however is fine.

Details (gitbash):

$ vagrant up
Bringing machine 'homestead-7' up with 'virtualbox' provider...
==> homestead-7: Checking if box 'laravel/homestead' version '7.1.0' is up to date...
==> homestead-7: Clearing any previously set forwarded ports...
==> homestead-7: Clearing any previously set network interfaces...
==> homestead-7: Preparing network interfaces based on configuration...
    homestead-7: Adapter 1: nat
    homestead-7: Adapter 2: hostonly
==> homestead-7: Forwarding ports...
    homestead-7: 80 (guest) => 8000 (host) (adapter 1)
    homestead-7: 443 (guest) => 44300 (host) (adapter 1)
    homestead-7: 3306 (guest) => 33060 (host) (adapter 1)
    homestead-7: 4040 (guest) => 4040 (host) (adapter 1)
    homestead-7: 5432 (guest) => 54320 (host) (adapter 1)
    homestead-7: 8025 (guest) => 8025 (host) (adapter 1)
    homestead-7: 27017 (guest) => 27017 (host) (adapter 1)
    homestead-7: 22 (guest) => 2222 (host) (adapter 1)
==> homestead-7: Running 'pre-boot' VM customizations...
==> homestead-7: Booting VM...
==> homestead-7: Waiting for machine to boot. This may take a few minutes...
    homestead-7: SSH address: 127.0.0.1:2222
    homestead-7: SSH username: vagrant
    homestead-7: SSH auth method: private key
==> homestead-7: Machine booted and ready!
==> homestead-7: Checking for guest additions in VM...
==> homestead-7: Setting hostname...
==> homestead-7: Configuring and enabling network interfaces...
==> homestead-7: Mounting shared folders...
    homestead-7: /vagrant => D:/DATA/SourceCodes/Homestead
    homestead-7: /home/vagrant/code => D:/DATA/SourceCodes/laravel
==> homestead-7: Machine already provisioned. Run `vagrant provision` or use the `--provision`
==> homestead-7: flag to force provisioning. Provisioners marked to run always will still run.

Ping details from windows command prompt:

Pinging 192.168.10.10 with 32 bytes of data:
Reply from 192.168.10.10: bytes=32 time<1ms TTL=64
Reply from 192.168.10.10: bytes=32 time<1ms TTL=64
Reply from 192.168.10.10: bytes=32 time<1ms TTL=64
Reply from 192.168.10.10: bytes=32 time<1ms TTL=64

Ping statistics for 192.168.10.10:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 0ms, Maximum = 0ms, Average = 0ms

I am sure it is a minor issue but can't figure out.

23 Dec
7 months 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');

    }

I mean it might be bit confusing for user if is not logged in.

It is desirable if verification link auto verifies and auto logs in the user.

Thanks!

20 Dec
7 months 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 'admin' middleware. Disabling that worked fine as expected.

    public function __construct()
    {
        // $this->middleware('admin');
    }

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');

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

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

I am testing with this command

php artisan queue:work --queue=high,medium,low --stop-when-empty

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/myapp/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/myapp/vendor/laravel/framework/src/Illuminate/Queue/QueueManager.php:156

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

  Please use the argument -v to see more details.

What does this mean and what's wrong?

P.S. My mail subscription verification mail goes fine. I am using mailtrap to check that. However this newsletter mail job 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
10 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

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

Also I don't know the parameter beforehand. Have to check based on what user had provided on search form.

Any other suggestion?

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
1 year 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
1 year 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 web.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(Request $request)
    {

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

    }

My finduser 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 usersearchform 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
1 year 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 is 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
1 year 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 methods.

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 cases 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,
   ]
>>>

But this is what I have in my filesystems.php

        's3' => [
            'driver' => 's3',
            'key' => env('my_key'),
            'secret' => env('mysecret'),
            'region' => env('us-east-1'),
            'bucket' => env('my_buket_name'),
        ],

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 has 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?

By the way I am using request method to store the file if it is relevant to the issue

$path = $request->file('uploadedfile')->store('s3_path', 's3');

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 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 ( https://laravel.com/docs/5.5/validation#validating-arrays ), 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 it is not triggered?
  2. Is there a way around for nested braces to show 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
2 years 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
2 years 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
2 years 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
2 years ago

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

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
2 years ago

Laraveldeep started a new conversation Laravel[5.5] Presets (Give It A Try)

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
2 years ago

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

Exactly, this had been discussed on 5.3 thread. I found this tutorial with explanation.

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

Hope Laravel 5.5 will have presets for Foundation as well.

Update: By the way I have created the preset already but will not be included in core package. However there is an unofficial way to use it. Check this out here https://github.com/Laraveldeep/Laravel-Scaffolding-Presets

Preset thread: https://laracasts.com/discuss/channels/laravel/laravel55-zurb-foundation-preset

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
2 years 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.