eddieace

eddieace

Falkenberg

Member Since 2 Years Ago

Experience Points 31,840
Experience
Level
Lessons Completed 289
Lessons
Completed
Best Reply Awards 0
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.

30 Oct
1 month ago

eddieace left a reply on VerifyCsrfToken Exclude Not Working

Now I tried this and it did not work

    protected $except = [
        'https://sub.mydomain.com/example/*',
    ];

eddieace started a new conversation VerifyCsrfToken Exclude Not Working

I'm having an issue with excluding a route from verifying CSRF token.

I'm trying to exclude all requests on an endpoint which I call mydomain.com/example so I do like this in the VerifyCsrfToken.php file.

class VerifyCsrfToken extends Middleware
{
    /**
     * Indicates whether the XSRF-TOKEN cookie should be set on the response.
     *
     * @var bool
     */
    protected $addHttpCookie = true;

    /**
     * The URIs that should be excluded from CSRF verification.
     *
     * @var array
     */
    protected $except = [
        'example/*',
    ];
}

But it does not solve the issue. If I do this in the app/Http/Kernel.php file everything works as it should.

Anyone know why I can't exclude specific routes?

    protected $middlewareGroups = [
        'web' => [
            \App\Http\Middleware\EncryptCookies::class,
            \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
            \Illuminate\Session\Middleware\StartSession::class,
            // \Illuminate\Session\Middleware\AuthenticateSession::class,
            \Illuminate\View\Middleware\ShareErrorsFromSession::class,
            //\App\Http\Middleware\VerifyCsrfToken::class,
            \Illuminate\Routing\Middleware\SubstituteBindings::class,
            \Barryvdh\Cors\HandleCors::class,
        ],

        'api' => [
            'throttle:60,1',
            'bindings',
        ],
    ];
´´´
18 Jun
5 months ago

eddieace left a reply on Can $collection->increment('field') Fail?

Actually, I don't know if it misses it or not. I just look at all the other statistics I have, which display the same results but redirects lately dropped a lot.

@Snapey I'm redirecting to a view because that view displays a message before it redirects to its final destination. But it needs to hit this method before being redirected.

eddieace started a new conversation Can $collection->increment('field') Fail?

I have a redirect function that looks like this. For some reason, it looks like it's sometimes missing to increment the item. I'm wondering if it sometimes can be so that it misses this because some caching or something?

public function redirect($key)
{
    $item = $this->item->findOrFail($key);

    $item->increment('redirects');

    $encode = urlencode($item->_url);

    return view('item.redirect', ['url' => ($encode)]);
}
28 May
6 months ago

eddieace started a new conversation Blacklist Emails

I have an application where people fill in a form including their email. Lately, some Chinese bot has been able to break through the CSRF protection and is abusing this service. I need to come up with a soluting to blacklist emails, or agents. What solution would you guys suggest?

09 Apr
8 months ago

eddieace started a new conversation Computed Property With Multiple Checkbox Filters

I am trying to make a solution for filtering results using checkboxes as simple as possible and as readable as possible.

I have a computed property called filteredPositions that looks like this. But it won't work with multiple filters on one array. Does anyone have a good solution for this problem?

Here is the computed property.

filteredPositions() {
    if (this.checkedFilters.includes("SE")) {
        return this.positions.filter(position => position.country_id == 1);
    }
    if (this.checkedFilters.includes("US")) {
        return this.positions.filter(position => position.country_id == 2);
    }
}

Testdata

data() {
    return {
        positions: [],
        filters: [
            {
                name: 'SE',
            },
            {
                name: 'US',
            }
        ],
        checkedFilters: ['SE', 'US'],
    }
},
´´´

19 Feb
9 months ago

eddieace started a new conversation "laravel/cashier":"~7.0" Not Compatible With "stripe/stripe-php": "^6.1"

I get an error when I'm trying to run

composer require "laravel/cashier":"~7.0"

The error

  Problem 1
    - laravel/cashier v7.0.9 requires stripe/stripe-php ~4.0 -> satisfiable by stripe/stripe-php[v4.0.0, v4.0.1, v4.1.0, v4.1.1, v4.10.0, v4.11.0, v4.12.0, v4.13.0, v4.2.0, v4.3.0, v4.4.0, v4.4.1, v4.4.2, v4.5.0, v4.5.1, v4.6.0, v4.7.0, v4.8.0, v4.8.1, v4.9.0, v4.9.1] but these conflict with your requirements or minimum-stability.

Maybe it should be updated so it can use the latest version of stripe-php sdk?

Anyone solved it or have a fix for it?

07 Feb
10 months ago

eddieace left a reply on Failed To Mount Component: Template Or Render Function Not Defined

I solved this by adding .default when declaring my components.

Vue.component('example-component', require('./components/ExampleComponent.vue').default);
06 Feb
10 months ago

eddieace started a new conversation Failed To Mount Component: Template Or Render Function Not Defined

All of a sudden I got this error. I have tried to delete node modules and package-lock.json and reinstalled everything using npm install.

Any clues?

[Vue warn]: Failed to mount component: template or render function not defined.

found in
05 Feb
10 months ago

eddieace left a reply on Vue.js File Upload

Here is my solution.


            imgUpload(e) {
                if (!e.target.files.length)
                    return;
                var data = new FormData();
                data.append('image', e.target.files[0]);
                axios.post('/image', data)
                .then(response => { this.ad.image = response.data.path })
                .catch(error => { console.log(error) });
            },
<input type="file" @change="imgUpload">
12 Dec
1 year ago

eddieace started a new conversation Refactoring Objects Using Laravel Collections Fails

What I try to do is that I need to return an array with key-value pairs from an array of objects.

From an api I get objects that looks something like this.

    array:8 [▼
      0 => TargetingSearch {#229 ▼
        #data: array:6 [▼
          "id" => "6005609368513"
          "name" => "Software"
          "audience_size" => 565991450
          "path" => array:4 [▶]
          "description" => ""
          "topic" => "Technology"
        ]
        #_type_checker: TypeChecker {#228 ▶}
      }

The simple way to do it is to loop through the objects and push the values into an array.

      $codes = [];
      foreach($objects as $object) {
          $codes[] = [
            'id' => $object->id,
            'name' => $object->name,
          ];
      }

Which will return this that is exactly what I need.

    ['id' => 321, 'name' => "item1"],
    ['id' => 321, 'name' => "item1"],
    ['id' => 321, 'name' => "item1"],

I think that this is a little hard to manage and what I try to do is something a little more readable.

For example, by using the Laravel collection classes I could do something like this.

$codes = collect($objects)->pluck('id', 'name')->toArray();

The problem here is that this does not return the keys.

    ["item1" => "123"],
    ["item2" => "321"],
    ["item3" => "213"],

If I use

$codes = collect($objects)->only('id', 'name')->toArray(); 

It returns an empty array because the object itself is messing it all up.

anyone knows how to solve this?

08 Dec
1 year ago

eddieace started a new conversation Valet And Laravel 5.5 Access Denied For User 'root'@'localhost'

Hello. I just started a new project and I use Valet for all my new projects. I also use a mysql DB that is installed on my local machine. It works on all my old projects using Laravel 5.4, 5.3 and 5.2. For some reason, I get this error.

SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: NO) (SQL: select * from `users` where `email` = [email protected] limit 1)

My .env file looks like this.

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

And as I said before, this works on all my old projects.

If I run tinker and for example run a simple call to the database, the connection works. So this error is only in the browser.

$users = App\User::all();
=> Illuminate\Database\Eloquent\Collection {#752
     all: [],
   }
>>>

Any clues?

04 Dec
1 year ago

eddieace started a new conversation Eloquent Using Multiple WhereNotIn

I'm trying to make a query where I use multiple whereNotIn arrays. For some reason, they block each other and ignores the other query parameters.

Any clues on how to solve this?

$products = Products::orderBy('id','DESC')
    ->where('status', '=', 4)
    ->whereNotIn('category', $excluded)
    ->whereNotIn('location', ['New York', 'Boston', 'Washington, DC', 'Charlotte'])
    ->take(400)
    ->get();
31 Oct
1 year ago

eddieace started a new conversation Running A Laravel Application Worldwide

Hey!

I'm in that stage where I need to scale my Laravel application worldwide. This means that I need to reduce latency on my site in the US and Asia. There are several ways to do this. What I think is that I should use a CDN of some kind. There are also services like Amazon lambda, but that does not run with PHP code. Another option would be to run a VPS in the US, one in Asia and one in Europe, and deploy it to three VPS at the same time.

what do you think is the best strategy for this?

26 Sep
1 year ago

eddieace started a new conversation Curl Not Working In Homestead

For some reason, I can't use CURL to send post requests in homestead. It just returns null and here is my code.

Additional, headers are not being set, even if it's application/json it returns HTML/charset.

any clues?


            $ch = curl_init(env('app_url') . 'applications/' . $position->ats_reference . '/import');
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
            curl_setopt($ch, CURLOPT_HTTPHEADER, ["Content-Type: application/json"]);
            curl_setopt($ch, CURLOPT_POST, true);
            curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([
                'token' => $user->token,
                'data' => [$data]
            ]));
            curl_exec($ch);
            $info = curl_getinfo($ch);
            dd($info);
            curl_close($ch);
15 Sep
1 year ago

eddieace started a new conversation Multiple Domains Per Langauge

Hello, I have a project where I want to have one domain per language. So my sites are pointing to the same domain, but for some reason, one of my domains are being redirected to the other.

To clarify. example.com example.org

example.org is pointed to the same directory as example.com.

When I visit example.org, I get redirected to example.com

I don't know if the problem is that I use LetsEncrypt SSL on both domains.

I use Forge to configure my servers. And I have setup two sites with 2 nginx conf files.

Any clues?

Here is my nginx files

example.com

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

server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;
    server_name example.com;
    root /home/forge/example.com;

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

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

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

    index index.html index.htm index.php;

    charset utf-8;

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

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }
    location ~ /(public/mail-signature/.*)$ {

    }

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

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

    error_page 404 /index.php;

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

    location ~ /\.ht {
        deny all;
    }
}

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

example.org

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

server {
    listen 80;
    listen [::]:80;
    server_name example.org;
    root /home/forge/example.com;

    # FORGE SSL (DO NOT REMOVE!)
    # ssl_certificate;
    # ssl_certificate_key;

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

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

    index index.html index.htm index.php;

    charset utf-8;

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

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

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

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

    error_page 404 /index.php;

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

    location ~ /\.(?!well-known).* {
        deny all;
    }
}

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

07 Sep
1 year ago

eddieace left a reply on API Route For Laravel 5.2 Access-Control-Allow-Origin

But for some reason, I can fetch the data using file_get_contents() in PHP. But not from a $http.get() request.

eddieace started a new conversation API Route For Laravel 5.2 Access-Control-Allow-Origin

Hey, I'm trying to build an API from a Laravel 5.2 app.

What i do is return data as this.

return response()->json($data);

Live on the server it works to call this API from an url.

But when I try to access it from another application running laravel 5.4. and using Vuejs it returns this error.

XMLHttpRequest cannot load https://mysite.com/api/v1/user?token=xxxxx. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://mysecondsite.com' is therefore not allowed access.

The request from vue looks like this.

        created() {
            this.$http.get('https://mysite.com/api/v1/user?token=xxxxx')
                .then(response => {
                    console.log(response);
                })
                .catch(error => {
                    console.log(error);
                });
        },

any clues?

04 Sep
1 year ago

eddieace started a new conversation Chunk.sortModules();

I get this problem when I try to run NPM. Anyone have any clues?

test ⚑ → npm run dev                                                                                                                                                                                                                                                        master ✗ 2d

> @ dev /Users/myuser/Code/testing/test
> node node_modules/cross-env/dist/bin/cross-env.js NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js

 78% advanced chunk optimization/Users/myuser/Code/testing/test/node_modules/extract-text-webpack-plugin/dist/index.js:188
            chunk.sortModules();
                  ^

TypeError: chunk.sortModules is not a function
    at /Users/myuser/Code/testing/test/node_modules/extract-text-webpack-plugin/dist/index.js:188:19
    at /Users/myuser/Code/testing/test/node_modules/async/dist/async.js:3083:16
    at eachOfArrayLike (/Users/myuser/Code/testing/test/node_modules/async/dist/async.js:1003:9)
    at eachOf (/Users/myuser/Code/testing/test/node_modules/async/dist/async.js:1051:5)
    at Object.eachLimit (/Users/myuser/Code/testing/test/node_modules/async/dist/async.js:3145:5)
    at Compilation.<anonymous> (/Users/myuser/Code/testing/test/node_modules/extract-text-webpack-plugin/dist/index.js:184:27)
    at Compilation.applyPluginsAsyncSeries (/Users/myuser/Code/testing/test/node_modules/tapable/lib/Tapable.js:206:13)
    at Compilation.seal (/Users/myuser/Code/testing/test/node_modules/webpack/lib/Compilation.js:579:8)
    at /Users/myuser/Code/testing/test/node_modules/webpack/lib/Compiler.js:493:16
    at /Users/myuser/Code/testing/test/node_modules/tapable/lib/Tapable.js:289:11
    at _addModuleChain (/Users/myuser/Code/testing/test/node_modules/webpack/lib/Compilation.js:481:11)
    at processModuleDependencies.err (/Users/myuser/Code/testing/test/node_modules/webpack/lib/Compilation.js:452:13)
    at _combinedTickCallback (internal/process/next_tick.js:131:7)
    at process._tickCallback (internal/process/next_tick.js:180:9)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ dev: `node node_modules/cross-env/dist/bin/cross-env.js 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 @ dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/myuser/.npm/_logs/2017-09-04T13_55_30_770Z-debug.log
11 Jul
1 year ago

eddieace started a new conversation In 5.4 Mailables In Browser While Editing Css

In 5.4 is there any way to view Mailables in the browser while editing CSS?

01 Jun
1 year ago

eddieace started a new conversation Envoyer, Deploying With Npm Install And Gulp --production

Hi Envoyer fans!

On every deploy I have to run npm install and gulp. This results in longer deploy times.

Is it anyone who have a good solution for this? Cashing the node-modules folder or something like that?

19 Apr
1 year ago

eddieace started a new conversation Failed To Open Stream: HTTP Request Failed! HTTP/1.1 503 First Byte Timeout

When doing a get request to an API I get this error

failed to open stream: HTTP request failed! HTTP/1.1 503 first byte timeout

Anyone has any clues on how to solve it?

eddieace started a new conversation SSL Auto Renew With LetsEncrypt

In this series @JeffreyWay explain how to make LetsEncrypt automatically renew itself. As far as I can see, this is no longer supported in forge?

Or am I wrong?

https://laracasts.com/series/server-management-with-forge/episodes/12

30 Mar
1 year ago

eddieace left a reply on Helper To Retrive A Users Posts Checking Between Multple Dates.

By the way here is the sql query

select * from `posts` where `posts`.`user_id` = ? and `posts`.`user_id` is not null and `ends_at` between ? and ? or `published_at` between ? and ?
29 Mar
1 year ago

eddieace started a new conversation Helper To Retrive A Users Posts Checking Between Multple Dates.

Hello!

I have written a helper class to get active posts from a specific time span. The problem here is that the condition after orWhereBetween it does not include the user_id.

This would work if i only would like to check one date, but in this case I would like to check both ends_at and published at to get all active posts that touches a specific time span.

Here is my helper method in my User class.

My question is, how do I solve this?

public function activePosts($from, $to) {
    return $this->hasMany(Post::class)->whereBetween('ends_at', [$from, $to])
        ->orWhereBetween('published_at', [$from, $to])
        ->get();
}
28 Mar
1 year ago

eddieace started a new conversation Move Images From Old Server To S3 From Url

Hi!

I'm trying to write a script where I'm trying to move images from an old server to s3. Is it possible to do by downloading the image from an url?

For example.

$companies = Company::all();

$companies->each( function ($company) {

    //some method to download file
    $file = download($company->logo);

    //Store on s3
    $filename = $file->storeAs('images', uniqid('img_') . "." . $file->guessClientExtension(), 's3');

    //Get the new path
    $new_path = Storage::disk('s3')->url($filename);

    //save the new path to logo
    $company->logo = $new_path;
    
    //save the new path
    $company->save();
}

eddieace started a new conversation Validator Max:255 On Url Not Working

Hello!

I have a validator that looks like this. For some reason it does not validate max:255 on url. Why? Otherwise the validator works fine.

$this->validate($request, [
    'title' => 'required',
    'url' => 'url|max:255'
]);
27 Mar
1 year ago

eddieace left a reply on Vagrant Up | VBoxManage: Error: Could Not Open The Medium '/Users/myuser/VirtualBox VMs/homestead-7/box-disk1.vmdk'.

I don't really know what the answer is. But must have something to do with permissions for the users on my mac. What I did was that i did some updates on my mac, using an old user which I had forgotten the login details for. After that, I was able to destroy the current VM and create a new one using vagrant up.

eddieace started a new conversation Vagrant Up | VBoxManage: Error: Could Not Open The Medium '/Users/myuser/VirtualBox VMs/homestead-7/box-disk1.vmdk'.

For some reason I got this error.

Any clues on how to solve this?

´´´ There was an error while executing g `VBoxMan, a CLI used by Vagrant for controlling VirtualBox. The command and stderr is shown below.

Command: ["startvm", "be05f1d7-efdc-4367-a47f-3373aae0ac78", "--type", "headless"]

Stderr: VBoxManage: error: Could not open the medium '/Users/myuser/VirtualBox VMs/homestead-7/box-disk1.vmdk'. VBoxManage: error: VD: error VERR_FILE_NOT_FOUND opening image file '/Users/myuser/VirtualBox VMs/homestead-7/box-disk1.vmdk' (VERR_FILE_NOT_FOUND) VBoxManage: error: Details: code NS_ERROR_FAILURE (0x80004005), component MediumWrap, interface IMedium

22 Mar
1 year ago

eddieace left a reply on Eloquent Take 25 Random Out Of 400 First Rows Laravel 5.2

My solution.

´´´php $result = Model::where('status', '=', 0) ->orderBy('id', 'desc') ->take(400) ->get() ->random(25); ´´´

eddieace started a new conversation Eloquent Take 25 Random Out Of 400 First Rows Laravel 5.2

Hi I need to make an eloquent request with top 400 rows, and select 25 random.

Right now the query looks like this. I get the latest 400 rows

$result = Model::where('status', '=', 0)
    ->orderBy('id', 'desc')
    ->limit(400)
    ->get();
```php



I know that I can do something like this, but then it will take all rows with status 0 but I want 25 out of the top 400.

```php
$result = Model::where('status', '=', 0)
    -inRandomOrder()
    ->limit(25)
    ->get();
20 Mar
1 year ago

eddieace started a new conversation Notifications Bulk Email Laravel 5.3

Hi!

I have a problem sending bulk emails with notifications in Laravel 5.3

The problem is that it's a loop, but it does only send out one email, the first one. Any clues?

Here is the handle method

public function handle()
{
    $users = User::all();

    $users->each(function ($user) {

        $users->notify(new SendSomething($user));

    });
}

And here is the notification itself

namespace App\Notifications;

use App;
use Log;
use App\User;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;

class SendSomething extends Notification
{
    use Queueable;

    private $position;
    /**
     * Create a new notification instance.
     *
     * @return void
     */
    public function __construct(User $user)
    {
        //
        $this->user = $user;

    }

    /**
     * Get the notification's delivery channels.
     *
     * @param  mixed  $notifiable
     * @return array
     */
    public function via($notifiable)
    {
        return ['mail'];
    }

    /**
     * Get the mail representation of the notification.
     *
     * @param  mixed  $notifiable
     * @return \Illuminate\Notifications\Messages\MailMessage
     */
    public function toMail($notifiable)
    {

        $user = $this->user;

        return (new MailMessage)
            ->to($user->email)
            ->from('[email protected]', 'example')
            ->subject('Some subject')
            ->greeting('Hello ' . $user->name . '!')
            ->line('How are you?')
            ->action('Do something', url('/somewhere/'))
            ->line('Kind regards, <br> u bro');
    }

    /**
     * Get the array representation of the notification.
     *
     * @param  mixed  $notifiable
     * @return array
     */
    public function toArray($notifiable)
    {
        return [
            //
        ];
    }
}
13 Mar
1 year ago

eddieace started a new conversation Echo And Blade Escapes Strings

I have a codeblock that looks like this.

The ptoblem is that everything after the var _globalObj row becomes green (the whole file)

    <script>
        var _globalObj = '<?php echo json_encode(array('_token'=> csrf_token())) ?>';
        var enableUrl = '{{url("admin/positions/enable-editor/" . $position->id)}}';
    </script>

I would like to have it something like this

    <script>
        var _globalObj = '{{ json_encode(array('_token'=> csrf_token())) }}';
        var enableUrl = '{{url("admin/positions/enable-editor/" . $position->id)}}';
    </script>

But for some reason blade escapes alot some json stuff like back slashes etc.

Any clues on how to solve this?

10 Mar
1 year ago

eddieace left a reply on Wordpress On Forge Upstream Sent Too Big Header While Reading Response Header From Upstream

Here is the solution.

You enter the settings

fastcgi_buffers 16 16k; 
fastcgi_buffer_size 32k;

into etc/ngin/sites-available/example.com

and add it into the location ~ .php$ block

like this.

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

        fastcgi_buffers 16 16k;
        fastcgi_buffer_size 32k;

    }

eddieace started a new conversation BelongsToMany With UpdateOrCreate

Hi I have this function. It runs every once in a while and I just added every location that a postition have. In a pivot table. The problem now is that every time it runs it adds a new record in the database. So the position gets new locations every time it runs.

Here is the function:

$position = Position::updateOrCreate(['title' => $position->title, company_id => $company_id], $position);

foreach($position->locations() as $location) {

    $location = Location::firstOrCreate(['name' => $location->name]);
    
    $position->locations()->attach($location->id);
}

Is there some way I could

if (if position_location not already exists) {
    $position->locations()->attach($location->id);
}
07 Mar
1 year ago

eddieace started a new conversation Wordpress On Forge Upstream Sent Too Big Header While Reading Response Header From Upstream

Hi I have a wordpress site running on forge. I get this error.

502 Bad Gateway

From log:

017/03/07 09:40:30 [error] 12586#12586: *13909 upstream sent too big header while reading response header from upstream, client: 46.59.124.52, server: example.com, request: "GET /wp-admin/post.php?post=123&action=edit HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php7.1-fpm.sock:", host: "example.com", referrer: "http://ecample.com/wp-admin/edit.php?post_type=page&orderby=title&order=asc"

Online I have found a few solutions.

The first one is this but the problem is that I don't know where to add it. I have tried both in etc/nginx/nginx.conf and in the location block in sites-available.

fastcgi_buffers 16 16k; 
fastcgi_buffer_size 32k;

Any clues on how to fix this?

27 Feb
1 year ago

eddieace left a reply on Import Packages With Yarn Or Npm And Install Them Correctly

So @vipin93 you mean like this?

So this is my bootstrap.js

window._ = require('lodash');

/**
 * We'll load jQuery and the Bootstrap jQuery plugin which provides support
 * for JavaScript based Bootstrap features such as modals and tabs. This
 * code may be modified to fit the specific needs of your application.
 */

window.$ = window.jQuery = require('jquery');
require('bootstrap-sass');

/**
 * Vue is a modern JavaScript library for building interactive web interfaces
 * using reactive data binding and reusable components. Vue's API is clean
 * and simple, leaving you to focus on building your next great project.
 */

window.Vue = require('vue');
require('vue-resource');

/**
 * We'll register a HTTP interceptor to attach the "CSRF" header to each of
 * the outgoing requests issued by this application. The CSRF middleware
 * included with Laravel will automatically verify the header's value.
 */


require('bootstrap-tagsinput');
require('typeahead.js');


Vue.http.interceptors.push((request, next) => {
    request.headers.set('X-CSRF-TOKEN', Laravel.csrfToken);

    next();
});

eddieace started a new conversation Import Packages With Yarn Or Npm And Install Them Correctly

Hi, I wonder if there is a complete guide on to instal packages with yarn or NPM. I have done this successfully a few times but it's always a struggle to get it to work together with gulp and elixir.

That are a few packages that you need in alot of projects, for example

bootstrap-datepicker bootstrap-tagsinput datatables font-awesome

What I do when i add these packages is to run;

1. Int the terminal i run yarn add bootstrap-tagsinput

It is then loaded into my package.json

2. Secondly I runyarn to install all my dependencies`

3. Then i need to import it both in my resources/assets/js and resources/assets/sass

Here comes the tricky part. I then want to import all the code into app.js and app.css so i need to import the files from assests

I do something like this. in the app.js

/**
 * First we will load all of this project's JavaScript dependencies which
 * include Vue and Vue Resource. This gives a great starting point for
 * building robust, powerful web applications using Vue and Laravel.
 */

require('./bootstrap');
require('./bootstrap-tagsinput');

In the css i do this.

// Fonts
@import url(https://fonts.googleapis.com/css?family=Raleway:300,400,600);

// Variables
@import "variables";

// Bootstrap
@import "node_modules/bootstrap-sass/assets/stylesheets/bootstrap";

@import "node_modules/bootstrap-tagsinput/dist/bootstrap-tags-input";

@import "style";

I then guess that gulp should import all these files into app.css and app.js in my public folder.

Is this correct?

13 Feb
1 year ago

eddieace started a new conversation Migrate From Outside Homestead

Hi!

I wonder if someone have a soloution on how to use migrate commands outside of homestead?

SQLSTATE[HY000] [2002] Connection refused (SQL: select * from information_schema.tables where table_schema = epoch and table_name = migrations)

I get this error and I have to vagrant ssh onto the virtual machine.

03 Feb
1 year ago

eddieace left a reply on Notification Select Who To Send To

I have now realized that the key is to look into the MailMessage class

<?php

namespace Illuminate\Notifications\Messages;

class MailMessage extends SimpleMessage
{
    /**
     * The view for the message.
     *
     * @var string
     */
    public $view = [
        'notifications::email',
        'notifications::email-plain',
    ];

    /**
     * The view data for the message.
     *
     * @var array
     */
    public $viewData = [];

    /**
     * The "from" information for the message.
     *
     * @var array
     */
    public $from = [];

    /**
     * The recipient information for the message.
     *
     * @var array
     */
    public $to = [];

    /**
     * The "cc" recipients of the message.
     *
     * @var array
     */
    public $cc = [];

    /**
     * The "reply to" information for the message.
     *
     * @var array
     */
    public $replyTo = [];

    /**
     * The attachments for the message.
     *
     * @var array
     */
    public $attachments = [];

    /**
     * The raw attachments for the message.
     *
     * @var array
     */
    public $rawAttachments = [];

    /**
     * Priority level of the message.
     *
     * @var int
     */
    public $priority;

    /**
     * Set the view for the mail message.
     *
     * @param  string  $view
     * @param  array  $data
     * @return $this
     */
    public function view($view, array $data = [])
    {
        $this->view = $view;
        $this->viewData = $data;

        return $this;
    }

    /**
     * Set the from address for the mail message.
     *
     * @param  string  $address
     * @param  string|null  $name
     * @return $this
     */
    public function from($address, $name = null)
    {
        $this->from = [$address, $name];

        return $this;
    }

    /**
     * Set the recipient address for the mail message.
     *
     * @param  string|array  $address
     * @return $this
     */
    public function to($address)
    {
        $this->to = $address;

        return $this;
    }

    /**
     * Set the recipients of the message.
     *
     * @param  string|array  $address
     * @return $this
     */
    public function cc($address)
    {
        $this->cc = $address;

        return $this;
    }

    /**
     * Set the "reply to" address of the message.
     *
     * @param  array|string $address
     * @param null $name
     * @return $this
     */
    public function replyTo($address, $name = null)
    {
        $this->replyTo = [$address, $name];

        return $this;
    }

    /**
     * Attach a file to the message.
     *
     * @param  string  $file
     * @param  array  $options
     * @return $this
     */
    public function attach($file, array $options = [])
    {
        $this->attachments[] = compact('file', 'options');

        return $this;
    }

    /**
     * Attach in-memory data as an attachment.
     *
     * @param  string  $data
     * @param  string  $name
     * @param  array  $options
     * @return $this
     */
    public function attachData($data, $name, array $options = [])
    {
        $this->rawAttachments[] = compact('data', 'name', 'options');

        return $this;
    }

    /**
     * Set the priority of this message.
     *
     * The value is an integer where 1 is the highest priority and 5 is the lowest.
     *
     * @param  int  $level
     * @return $this
     */
    public function priority($level)
    {
        $this->priority = $level;

        return $this;
    }

    /**
     * Get the data array for the mail message.
     *
     * @return array
     */
    public function data()
    {
        return array_merge($this->toArray(), $this->viewData);
    }
}

eddieace started a new conversation Notification Select Who To Send To

Hi, I have a question regarding notification email receiver.

I have an object that have multiple email-adresses and I only want to notify one of them.

How do I choose what email to notify?

17 Jan
1 year ago

eddieace started a new conversation Vue Rangeslider Mousedrag Not Working

I'm trying to get my rangeslider in vue.js to work. For some reason draggin by using mobile or mousebutton is not working. Clicking is working perfectly. Any clues?

Here is my RangeSlider.vue file

<script>
  export default {
    props: {
      min: {
        required: true,
      },
      max: {
        required: true,
      },
      suffix: {
        required: false,
        default: '',
      },
      name: {
        required: true,
      }
    },

    data() {
      return {
        dragging: false,
        value: 0,
        id: '',
      };
    },

    mounted() {
      $(window).mouseup(e => {
        if (this.dragging) {
          this.dragging = false;
        }
      });

      $(window).mousemove(e => {
        if (this.dragging) {
          this.move(e);
        }
      });

      this.id = this.makeid();
    },

    methods: {
      drag() {
        this.dragging = true;
      },

      drop() {
        this.dragging = false;
      },

      move(e) {
        const sliderPos = $('#' + this.id + ' .range-slider-slider').offset().left;
        const sliderWidth = $('#' + this.id + ' .range-slider-slider').width();
        const min = 0;
        const max = sliderWidth - $('#' + this.id + ' .range-slider-handle').width();

        const position = Math.min(max, Math.max((e.pageX - 25) - sliderPos, min));

        $('#' + this.id + ' .range-slider-handle').css({
          left: position + 'px',
        });

        const n = this.max - this.min;
        const k = position / sliderWidth;
        const v = Number(Math.ceil(n * k)) + Number(this.min);

        if (v == this.max) {
          this.value = v + '+';
        } else {
          this.value = v;
        }
      },

      makeid() {
          var text = "";
          var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";

          for( var i=0; i < 8; i++ )
              text += possible.charAt(Math.floor(Math.random() * possible.length));

          return text;
      }
    }
  };
</script>

<template>
  <div class="range-slider" :id="id">
    <input v-model="value" type="hidden" :name="name">
    <div class="range-slider-slider" @click="move"></div>
    <div :class="['range-slider-handle', dragging ? 'active' : '']" @mousedown="drag" @mouseup="drop"><span class="ranger-slider-label">{{ value }} {{ suffix }}</span></div>
  </div>
</template>

And here is my form-group

<div class="form-group">
    <label for="experience">{{ trans('position.experience') }}</label>
    <range-slider name="experience" min="0" max="10"></range-slider>
</div>
16 Jan
1 year ago

eddieace left a reply on Vue 2 And Initial Input Form Values

@phoenixcorp do you have an example of how you solved this issue?

eddieace started a new conversation Validation Error Using Form Request.

I have a problem.

I'm using a Form Request but also Vue on my form. My problem is that old('') variables does not work together with Vue v-model.

Here is an example of the input field.

<div class="form-group">
    <label for="name">{{ trans('messages.name') }}</label>
    <input type="text" name="name" v-model="name" id="name" value="{{ old('name') }}" class="form-control">
    @if($errors->has('name'))
      <span class="help">
        {{trans('Validations.name')}}
      </span>
    @endif
</div>

If I remove the v-model="name" the {{ old('name') }} variable works.

This is the error i get from Vue in the browser.

<input v-model="name" value="asdasdasd">:
inline value attributes will be ignored when using v-model. Declare initial values in the component's data option instead. 

and here is my .vue file

<script>
  import RangeSlider from './RangeSlider.vue';

  export default {
    components: {
      RangeSlider,
    },

    props: ['fields'],

    data() {
      return {
        name: '',
        email: '',
        phone: '',
        loading: false,
        errors: {},
      };
    },

    methods: {
      onSubmit() {
        this.loading = true;
      }
    }
  };
</script>
05 Jan
1 year ago

eddieace started a new conversation Customizing Emails Notifications Laravel 5.3

Hello! I'm trying to send an email using notifications in 5.3. My problem is that i have one email where i need to loop through an array of multiple items and display them in the email. Is it possible to get the array inside of the email template?

03 Jan
1 year ago

eddieace left a reply on UpdateOrCreate Matching Multiple Attributes Like Company And Record

Well, something else was wrong. This code works perfectly.

eddieace started a new conversation UpdateOrCreate Matching Multiple Attributes Like Company And Post

What I'm tring to do is adding records with the same title and company so that company one and two can have a record with the same title. I'v been trying to use the updateOrCreate method but with no success.

Here is my code, any clues?


$company_id = 12345;
$xml = simplexml_load_file($url);
$records = array();

foreach ($xml->channel as $x) {
    foreach ($x->item as $item) {
        $record[] = [
            'company_id' => $company_id,
            'title' => (string)$item->title,
            'location' => (string)$item->location,
            'description' => (string)$item->description,
    }
}

foreach($records as $record) {
    Model::updateOrCreate(['title' => $record['title'], 'company_id' => $company_id], $record);
}
01 Dec
2 years ago

eddieace started a new conversation Nginx Error If I Activate LetsEncrypt Certificate And All Sites Becomes Disabled

Hello fellow Forge Enthusiasts!

I have a problem that if I obtain a LetsEncrypt certificate and activate it something in my nginx configuration returns an error. It also makes all my sites on that server deactivated.

This happens when I try to restart nginx.

Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xe" for details.
nginx.service is not active, cannot reload.

I wish I could show you how my nginx config in sites-enabled would look like but I have obtained to many already.

I wonder if anyone knows what could be wrong? Could anyone link a working nginx config?

I host all my sites on a AWS EC2 Instance.

22 Nov
2 years ago

eddieace started a new conversation Upstream Timed Out (110: Connection Timed Out) While Reading Response Header From Upstream

I get this error when I run GET requests in my commands. This is the error I get in the log

upstream timed out (110: Connection timed out) while reading response header from upstream, 
client: xx.xxx.xxxx.xxx, server: stage.myapp.cpm, request: "GET /script/run HTTP/1.0", 
upstream: "fastcgi://unix:/var/run/php/php7.0-fpm.sock", host: "stage.myapp.cpm,"

As I have understood I should change som settings but i don' know how and where?

Should I change something in sites-enabled? Here is an example

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

server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;
    server_name test.test.com;
    root /home/forge/test.test.com/current/public;

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

    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE$
    ssl_prefer_server_ciphers on;
    ssl_dhparam /etc/nginx/dhparams.pem;

    index index.html index.htm index.php;

    charset utf-8;

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

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

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

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

    error_page 404 /index.php;

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

    location ~ /\.ht {
        deny all;
    }
}

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