eriktobben

eriktobben

Member Since 4 Years Ago

Experience Points
36,775
Total
Experience

3,225 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
349
Lessons
Completed
Best Reply Awards
0
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.

Level 8
36,775 XP
31 Jul
1 month ago

eriktobben started a new conversation Valet: CURL Error 6: Could Not Resolve

Hi,

I am trying to access another project (API) via one of my projects locally. This has worked before, but now I get the following error:

cURL error 6: Could not resolve: scheduler.test (Domain name not found) (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)

In .env the url is http://scheduler.test/api

I am able to access the site in Safari, but I get the Guzzle error when trying to access it via the other project.

I have tried restarting Valet, but that did not work.

Any suggestions? :)

18 Jun
3 months ago

eriktobben started a new conversation Simple Asset Cache Busting

Hi,

Is there an easy way to version static assets without using Mix? All I want is to bust file cache when I do updates to css og js files. I have found some packages where I can run an Artisan command to generate a new hash. The problem with these packages is that I have to alter the nginx rewrite rules, and I was hoping not to do that.

09 Jun
3 months ago

eriktobben started a new conversation Best Way Of Keeping Cart Active After Logout

Hi,

I am developing an eCommerce site and I have a question related to the cart. Currently I have a Cart model and a CartItem model where the cart and its content is stored. When a user adds a product to cart, I create the cart and store the cart ID in session.

My problem is when the user logs out the session is cleared and the user gets an empty cart because the cart ID in session is no longer there.

What is the best way to solve this issue?

21 May
4 months ago

eriktobben left a reply on Laravel Premium Package

Not sure, but I would assume you need a subscription to Private Packagist: https://packagist.com/

03 May
4 months ago

eriktobben started a new conversation Guzzle CURL Error 56: OpenSSL

Hi,

I am trying to consume an API in Laravel with Guzzle. When testing the API with Postman everything works, but when using Guzzle in Laravel I get the following error:

cURL error 56: OpenSSL SSL_read: SSL_ERROR_SYSCALL, errno 54 (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)

I am consuming other APIs which uses https and there are no problems there. I have tried searching for that error, but I can not find a solution.

I have checked and I do have OpenSSL on my Mac. (I am using Valet on macOS Mojave).

Any tips would be appreciated :)

26 Mar
5 months ago

eriktobben left a reply on Simple Search

Thank you :)

25 Mar
5 months ago

eriktobben left a reply on Simple Search

Okey, so by having where('company_id', auth()->user()->company_id) the query the query will only return results where the company_id is a match?

22 Mar
6 months ago

eriktobben left a reply on Simple Search

Thank you for your response.

Will there be a difference using orWhere instead of where?

 $addresses = Address::where('company_id', auth()->user()->company_id)
        ->where(function($query) use ($search){
            $query->orWhere('name', 'LIKE', '%'.$search.'%') // orWhere in this line instead of using where
            $query->orWhere('address', 'LIKE', '%'.$search.'%')
            $query->orWhere('address2', 'LIKE', '%'.$search.'%')
            $query->orWhere('zip', 'LIKE', '%'.$search.'%')
            $query->orWhere('city', 'LIKE', '%'.$search.'%')
        })
        ->paginate(30);
19 Mar
6 months ago

eriktobben started a new conversation Simple Search

Hi,

I am wondering if this query will scope the search result on company_id and not show addresses for a different company?

if ($search) {
    $addresses = Address::where('company_id', auth()->user()->company_id)
    ->where('name', 'LIKE', '%'.$search.'%')
    ->orWhere('address', 'LIKE', '%'.$search.'%')
    ->orWhere('address2', 'LIKE', '%'.$search.'%')
    ->orWhere('zip', 'LIKE', '%'.$search.'%')
    ->orWhere('city', 'LIKE', '%'.$search.'%')
    ->paginate(30);
}

Based on testing it is working, but I am not sure if this query could return addresses which do not belong to the company.

Or is there a better way of doing this?

06 Feb
7 months ago

eriktobben left a reply on Can't Deploy Forge Site

I figured it out.

I removed everything from the Deploy Script except "git pull origin master" and it seems that the "php artisan backup:run" is the one causing trouble.

eriktobben started a new conversation Can't Deploy Forge Site

Hi,

I was deploying my site via Forge and introduced a syntax error in the console kernel.

I fixed the error, pushed the code and tried to deploy again, but then I get this error:

PHP Parse error:  syntax error, unexpected '->' (T_OBJECT_OPERATOR) in /home/forge/domain.com/app/Console/Kernel.php on line 33

Parse error: syntax error, unexpected '->' (T_OBJECT_OPERATOR) in /home/forge/domain.com/app/Console/Kernel.php on line 33

I am not able to deploy the code because of this error.

What would cause the deploy script to fail because of a syntax error in the PHP code?

06 Nov
10 months ago

eriktobben left a reply on How To Generate A Unique But Simple Id For Ticket?

I am using this:

public function reference()
    {
        
        $unique = str_random(6);

        $check = Model::where('reference', $unique)->first();

        if ($check) {
            return $this->reference();
        }

        return $unique;
    }
05 Nov
10 months ago

eriktobben left a reply on Incorrect String Value

That worked great. No data loss when editing the tables. Thanks!

eriktobben left a reply on Incorrect String Value

@Cronix Thanks, I see. Will my current data that is stored in UTF-8 be intact after changing to utf8mb4 and utf8mb4_unicode_ci?

eriktobben started a new conversation Incorrect String Value

Hi,

I have upgraded a Laravel 5.1 project to 5.7 and moved it to a server with PHP 7.2 and MariaDB 10.2.18.

In the old version I was using MySQL 5.5.62 and was having problems if the message that should be stored contained an emoji. The text after the emoji was not stored in the database, but no error was thrown.

After upgrading I exported the database and imported it on the new server and I though the problem was fixed.

Today, I got the following error: SQLSTATE[22007]: Invalid datetime format: 1366 Incorrect string value: '\xF0\x9F\x91\x8D\xF0\x9F...' for column 'message' at row 1.

Here are info about the new database: Type: InnoDB Encoding: UTF-8 Unicode (utf8) Collation: utf8_unicode_ci

Is there something I can change here in the database so it can store emojis? And can I change this on a live database? (After taking backup of course).

28 Oct
10 months ago

eriktobben left a reply on Problem After Renewing SSL Certificate

That worked! Thank you @click :)

eriktobben left a reply on Problem After Renewing SSL Certificate

This is what my nginx config looks like from Forge, and is the same as the path under SSL in the control panel:

server {
    listen 443 ssl;
    server_name site.domain.com;
    root /home/forge/site.domain.com/public;

    # FORGE SSL (DO NOT REMOVE!)
    ssl_certificate /etc/nginx/ssl/site.domain.com/123456/server.crt;
    ssl_certificate /etc/nginx/ssl/site.domain.com/123456/server.crt;

    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;

    index index.html index.htm index.php;

    charset utf-8;

    # FORGE CONFIG (DOT NOT REMOVE!)
    include forge-conf/site.domain.com/server/*;
26 Oct
10 months ago

eriktobben started a new conversation Problem After Renewing SSL Certificate

Hi,

My SSL certificate expired yesterday, and today I updated it. It is a PositiveSSL from Conmodo.

I am using Forge and I updated the certificate as I normally do. After the certificate was installed, when I try to access site.domain.com, I get redirected to test.domain.com or stage.domain.com. I then tried to install the certificate again, same problem. I also tried a Lets Encrypt certificate and the same problem appears.

If I access the site with http:// it works, but I get a TokenMismatchException on POST requests. There have been no changes to the code, and it all worked yesterday.

I have tried restarting nginx and the server with no luck. The nginx-config file have the correct domains and config/app.php have the correct site url.

This is a Laravel 5.1 app.

Does anyone have any idea on what could cause this?

12 Jul
1 year ago

eriktobben left a reply on Store HTML Content In A Pdf

Did you forget to add ->first() at the end?

$certificateContent = RegistrationType::with('certificate')->where('id', $request->send_to)->first();
27 Mar
1 year ago

eriktobben left a reply on General Data Protection Regulation (GDPR)

@gietema You don't believe you need a Data Processing Agreement with Forge, but you should get one from your server provider.

If you are using Digital Ocean, just create a support ticket with a DPA request and include your contact / company information. They will send you a personalized copy.

28 Feb
1 year ago

eriktobben left a reply on Redirect After Login.

@phpMick Yes. But I believe the data in auth() is called on every request anyways so there is no additional database call.

eriktobben left a reply on Redirect After Login.

Use Middleware.

if (auth()->user()->is_active == 0) {
    return redirect()->route('notActive');
}
19 Feb
1 year ago

eriktobben started a new conversation Combine Multiple Forms And Send Everything In One Request

Hi,

I have multiple forms on my page, and when the user submits I want to combine all forms into one "master form" / request that gets submitted to the server. Is that possible?

I have found that I can get all input with this code:

$('form').serialize();

But how do I send the serialized data as a POST request to the server?

Is there a better way of doing this?

12 Feb
1 year ago

eriktobben left a reply on Problem Storing File In Folder DO/S3

The following code work as expected:

$storage = \Storage::disk('spaces');
$filePath = "img/category/{$fileName}.{$fileContents->extension()}";
$storage->put($filePath, file_get_contents($fileContents), 'public');
11 Feb
1 year ago

eriktobben started a new conversation Problem Storing File In Folder DO/S3

Hi,

I am using the following code to store a public file in Digital Ocean Spaces:

Storage::disk('spaces')->put("img/category/{$fileName}.{$fileContents->extension()}", $fileContents, 'public');

But this is how it is being stored in DO: BUCKET/img/category/8a18ad92-5646-4676-83a1-989a8ec222da-test.jpeg/3RmP6iFEbNx5uF2Jr27ONqL5Apl8gVLKUXLzpVbh.jpeg

So my file name becomes a folder. How can I specify what folder to store the file in and set a custom file name?

30 Jan
1 year ago

eriktobben left a reply on Install Rocket.chat On A Forge Server

Hi,

Yes, I am aware of this documentation and how to install it on a blank server. My question is how I can install it on a Forge provisioned server? I assume nginx will overrule the url set in the Rocket settings?

Is it possible to use a Forge provisioned server and install this application like I install Laravel projects? So that I can create a new site in Forge and attach a SSL certificate or should I not use Forge for this application?

eriktobben started a new conversation Install Rocket.chat On A Forge Server

Hi!

Does anyone know if its possible and how I can install Rocket.chat on a server created via Forge? https://rocket.chat

I would like to use Forge to manage the server, create a site and serve Rocket.chat from that site and then add a SSL cerificate.

31 Dec
1 year ago

eriktobben started a new conversation Horizon Runs Job Multiple Times

Hi!

I have just installed Horizon, and set my QUEUE_DRIVER to redis in .env-file. When I run php artisan horizon the job gets executed four times.

I have no info in Horizon dashboard, and the status is a cross.

.env

QUEUE_DRIVER=redis
HORIZON_PREFIX=projectone:

config/horizon.php

'use' => 'default',

'prefix' => env('HORIZON_PREFIX', 'horizon:'),

'waits' => [
        'redis:default' => 60,
    ],


'environments' => [
        'production' => [
            'supervisor-1' => [
                'connection' => 'redis',
                'queue' => ['default'],
                'balance' => 'auto',
                'processes' => 10,
                'tries' => 3,
            ],
        ],

        'local' => [
            'supervisor-1' => [
                'connection' => 'redis',
                'queue' => ['default'],
                'balance' => 'auto',
                'processes' => 3,
                'tries' => 3,
            ],
        ],
    ],

Terminal

[2017-12-31 21:17:27] Processing: App\Jobs\GenerateInvoice
[2017-12-31 21:17:32] Processing: App\Jobs\GenerateInvoice
[2017-12-31 21:17:32] Processing: App\Jobs\GenerateInvoice
[2017-12-31 21:17:32] Failed:     App\Jobs\GenerateInvoice

The error message for the failed job is just because the file name already exists.

19 Dec
1 year ago

eriktobben left a reply on Using Redis As Queue Driver And Cache

@burlresearch Thank you for clarifying. I assume as long as I just bust regular cache items it will not interfere with the queue.

17 Dec
1 year ago

eriktobben left a reply on Using Redis As Queue Driver And Cache

Thanks for the replies.

Okey, so I can safely deploy Horizon and queues on the same server. If I do a cache:clear will that affect the jobs in the queue?

I have not tried it yet. I'm trying to make a decision wether to use Redis for both services.

eriktobben started a new conversation Using Redis As Queue Driver And Cache

Hi,

Will there be a problem using Redis as a queue driver and for storing cache? Do I need to do anything special or will it just work?

11 Jun
2 years ago

eriktobben left a reply on Check For Duplicates In The Same Table

Thanks @mushood, that worked!

I used the following query:

$data = DB::select(DB::raw('SELECT email, COUNT(*) c FROM users GROUP BY email HAVING c > 1'));

10 Jun
2 years ago

eriktobben started a new conversation Check For Duplicates In The Same Table

Hi!

I have a table containing 7 000 accounts with an email address and I want to check if any of these records are duplicates (email). What is the easiest way of doing that? Is it to fetch all records and run a foreach to the DB?

30 Apr
2 years ago

eriktobben left a reply on Cache::remember - Forever?

@martinbean That worked perfectly! Thanks :)

eriktobben left a reply on Cache::remember - Forever?

But how can I use this with a closure so that Laravel performs a query if the key don't exists in the cache?

eriktobben started a new conversation Cache::remember - Forever?

Hi,

I have some settings stored in the database and I want to cache them forever as they don't change often. When the user updates his settings, I delete the cache and add the new version to the cache.

How can I set this method to store the data forever?

´´´ $value = Cache::remember('users', $minutes, function () { return DB::table('users')->get(); }); ´´´

25 Apr
2 years ago
17 Apr
2 years ago

eriktobben started a new conversation Calculate Total Sum With Dynamic Form Fields

Hi!

I have a form for an order create page, where 1 line contains description, quantity and price. The user can click a button to generate a new line.

At the bottom of the page, I want to display the total order amount.

I am not able to bind to the generated lines and therefore can not calculate the order total.

Here is the code:

HTML

<div class="col-sm-7">
    <div class="form-group">
        <div class="col-md-12">
            <input name="line_description[]" type="text" class="form-control" placeholder="Description">
        </div>
    </div>
</div>

<div class="col-sm-2">
    <div class="form-group">
        <div class="col-md-12">
            <input name="line_qty[]" type="text" class="form-control" placeholder="Quantity" v-model="qty">
        </div>
    </div>
</div>

<div class="col-sm-3">
    <div class="form-group">
        <div class="col-md-12">
            <input name="line_price[]" type="text" class="form-control" placeholder="Price" v-model="price">
        </div>
    </div>
</div>

JS

<script type="text/javascript">
$(function() {
  $("#addMore").click(function(e) {
    e.preventDefault();
    $("#lines").append('<div class="col-sm-7"><div class="form-group"><div class="col-md-12"><input name="line_description[]" type="text" class="form-control" placeholder="Description"></div></div></div>');

    $("#lines").append('<div class="col-sm-2"><div class="form-group"><div class="col-md-12"><input name="line_qty[]" type="text" class="form-control" placeholder="Quantity" v-model="qty"></div></div></div>');

    $("#lines").append('<div class="col-sm-3"><div class="form-group"><div class="col-md-12"><input name="line_price[]" type="text" class="form-control" placeholder="Price" v-model="price"></div></div></div>');
  });
});
</script>

Vue

<script>
    new Vue({
      el: '#app',
      data: {
        qty: 0,
        price: 0
      }
    })
</script>

Does anyone have any idea on how to get this to work?

21 Feb
2 years ago

eriktobben left a reply on Queue Workers Restart Automatically Upon Deploy?

I think you can run php artisan queue:restart during your deployment process.

05 Jan
2 years ago

eriktobben left a reply on Using Sequel Pro With Valet

Not sure what happened, but I wrote the username as Root with a capital R. After changing to 'root' it works.

Thanks!

eriktobben left a reply on Using Sequel Pro With Valet

Hi Khare,

That is what I tried, but I get the following errors:

When trying to see users: Unable to get list of users An error occurred while trying to get the list of users. Please make sure you have the necessary privileges to perform user management, including access to the mysql.user table.

When trying to add database: Error Couldn't create database. MySQL said: Access denied for user ''@'localhost' to database 'test2'

eriktobben started a new conversation Using Sequel Pro With Valet

Hi!

I am setting up a new Mac and trying out Valet for the first time in an attempt to not install Homestead. But I love how easy it was to connect to MySql in homestead and add a new database from Sequel Pro.

Is it possible to do this when using Valet? How do I connect to the MySql server on my local machine to create databases and users from Sequel Pro?

Thanks!

03 Sep
3 years ago

eriktobben left a reply on Confused On Where To Store Files

Storing assets in /public is usually fine as they are part of the repository and will get placed back again when you run your deployment. Problem is files that are user generated, say an PDF uploaded by a user. When you run your deployment that file along with everything else is deleted. Since the PDF is not part of the repository it won't be added again.

I store all user generated files in /storage as it is not accessible like in the public folder and it is also safe from being deleted at deployment.

01 Sep
3 years ago

eriktobben left a reply on Guzzle 6 And Oauth 2

Oh, okey. I am following the Stipe Docs at https://stripe.com/docs/connect/standalone-accounts for creating a connection to a stand-alone account. Do you think Cashier can do this kind of behavior?

eriktobben left a reply on Guzzle 6 And Oauth 2

Thanks for your answer. I don't think I can use Cashier to connect to another users Stripe Account?

eriktobben started a new conversation Guzzle 6 And Oauth 2

Hi!

I am trying to consume the Stripe API for adding and attaching a stand-alone account using Guzzle. Stripe uses Oauth 2 and I can't find a plugin like guzzlehttp/oauth-subscriber for Oauth 2.

How would you go about making an Oauth 2 request using Guzzle?

19 Aug
3 years ago

eriktobben left a reply on Https Problems With Routes

@JarekTkaczyk Makes sense! Thanks for the answer :)

18 Aug
3 years ago

eriktobben started a new conversation Https Problems With Routes

Hi!

So I've been working on a very simple API and I have been testing it for a while with no SSL-certificate. After I installed a Let's Encrypt certificate through Forge I get a strange error.

My routes look look like this:

Route::get('email', '[email protected]')->name('email.index');
Route::post('email/send', '[email protected]')->name('email.send');
Route::get('email/{id}', '[email protected]')->name('email.show');

On all routes I have a Token validation that gets passed as a header on the GET-routes and as part of the request body on the POST-route.

Problem: If I send a POST request to api.domain.com/email/send I expect to get a response back with the email ID but instead I get a token validation error. After some testing I find that this particular message gets generated by [email protected] That was not the case before I added SSL. If I test the same route in Homestead everything works great.

If I do the same request to https://api.domain.com/email/send everything works as expected.

I find it strange that adding a SSL-certificate will change how the server handles the POST request and sends is to a route that is only defined as GET. There have been no changes to the code and the same code is working fine in Homestead (without SSL)