thoresuenert

thoresuenert

Member Since 4 Years Ago

Freelancer at Home Office

Experience Points 33,935
Experience Level 7

1,065 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 377
Lessons
Completed
Best Reply Awards 5
Best Reply
Awards
  • Start Your Engines Achievement

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • First Thousand Achievement

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • One Year Member Achievement

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • Two Year Member Achievement

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • Three Year Member Achievement

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • Four Year Member Achievement

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • Five Year Member Achievement

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • School In Session Achievement

    School In Session

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

  • Welcome To The Community Achievement

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • Full Time Learner Achievement

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • Pay It Forward Achievement

    Pay It Forward

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

  • Subscriber Achievement

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • Lifer Achievement

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • Laracasts Evangelist Achievement

    Laracasts Evangelist

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

  • Chatty Cathy Achievement

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • Laracasts Veteran Achievement

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • Ten Thousand Strong Achievement

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • Laracasts Master Achievement

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • Laracasts Tutor Achievement

    Laracasts Tutor

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

  • Laracasts Sensei Achievement

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • Top 50 Achievement

    Top 50

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

03 Dec
3 months ago

thoresuenert started a new conversation Unable To Calculate Golang Binary Hmac Hash

Hello, i try to verify a request from messagebird service. https://developers.messagebird.com/docs/verify-http-requests

there pseudo code:

signature = HMAC_SHA_256(
        TIMESTAMP + \n + QUERY_PARAMS + \n + SHA_256_SUM(BODY),
        signing_key
)

if HMAC_EQUALS(signature, BASE_64_DECODE(request_signature)) {
    // Yay!
}

Go example

func sign(timestamp, queryParams string, body []byte, key string) []byte {
    var buf bytes.Buffer

    buf.WriteString(timestamp)
    buf.WriteRune('\n')
    buf.WriteString(queryParams)
    buf.WriteString('\n')

    hash := sha256.Sum256(body)
    buf.Write(hash[:])

    mac := hmac.New(sha256.New, []byte(key))
    mac.Write(buf.Bytes())

    return mac.Sum(nil)
}

actualSignature, err := base64.StdEncoding.DecodeString(reqSignature)
if err != nil {
    // handle error
}

signature := sign(timestamp, queryParams, body, signingKey)
if hmac.Equal(signature, expectedSignature) {
    // OK
}

the actualSignature includes a bytestring b"..."

i am not able to solve that.

my code so far, getting 404 all the time.

class MessageBirdController extends Controller
{
    public function update(Request $request)
    {
        $signature = base64_decode($request->header('MessageBird-Signature'));
        $time = $request->header('MessageBird-Request-Timestamp');
        $query = $request->getQueryString();
        $body_hash = hash('sha256', $request->getContent()); // is empty body

        $content = $time. '\n'. $query . '\n' . $body_hash;

        $expected = hash_hmac('sha256', $content , config('services.messagebird.secret'),true);
   
        if (! hash_equals($expected, $signature) ) {
            return response('',404);
        }

        return response();
    }
}
14 Aug
1 year ago

thoresuenert left a reply on Laravel Mailable Firing Twice

Do you guys defined the "to" in config/mail ?

I have the same issue when i remove the "to" entry i see 1 mail.

25 Sep
3 years ago

thoresuenert left a reply on Confusion About Queue Timeouts

@aarondfrancis to prevent invisible infinite loops for example.

09 Aug
3 years ago

thoresuenert started a new conversation PHPSpec "Mock/Stub" Facebook SDK

hey girls and boys, i want to write a wrapperClass for the facebook sdk. i come up with following spec and code:


use Facebook\Facebook;
use PhpSpec\ObjectBehavior;
use Prophecy\Argument;

class FacebookClientSpec extends ObjectBehavior
{
    function let(Facebook $facebook)
    {
        $this->beConstructedWith($facebook);
    }

    function it_can_get_page_listing_for_a_user(Facebook $fb, UserStub $user)
    {
        $listingStub = new PageListingResponseStub;
        $fb->get('/me/accounts',$user->provider_token)->shouldBeCalled();
        $fb->get('/me/accounts', $user->provider_token)->willReturn($listingStub);

        $this->forUser($user)->getPageListing()->shouldReturn($listingStub);
    }
}


class UserStub {
    public $provider_token = 'test';
}
class PageListingResponseStub
{
    public static $decodedBody = [
        "data" => [
            0 => [
                "access_token" => "asdfasdf",
                "category" => "Restaurant/Cafe",
                "name" => "Test",
                "id" => "asdfasdf",
                "perms" => [
                    0 => "ADMINISTER",
                    1 => "EDIT_PROFILE",
                    2 => "CREATE_CONTENT",
                    3 => "MODERATE_CONTENT",
                    4 => "CREATE_ADS",
                    5 => "BASIC_ADMIN",
                ]
            ],
            1 => [
                "access_token" => "asdfasdf",
                "category" => "Food/Beverages",
                "name" => "BLubb",
                "id" => "asdfasdf",
                "perms" => [
                    0 => "ADMINISTER",
                    1 => "EDIT_PROFILE",
                    2 => "CREATE_CONTENT",
                    3 => "MODERATE_CONTENT",
                    4 => "CREATE_ADS",
                    5 => "BASIC_ADMIN",
                ]
            ]
        ],
        "paging" => [
            "cursors" => [
                "before" => "asdfasdfsadf",
                "after" => "asdfasdfasdf",
            ]
        ]
    ];

    public function decodedBody()
    {
        return self::$decodedBody;
    }
}
class FacebookRestaurantResponseStub
{
    public static $decodedBody = [
        "location" => [
            "city" => "asdfasdf",
            "street" => "asdfasdf",
            "zip" => "13123",
        ],
        "hours" => [
            "mon_1_open" => "10:00",
            "mon_1_close" => "22:00",
        ],
        "id" => "asdfasdf",
    ];

    public function decodedBody()
    {
        return self::$decodedBody;
    }
}```

namespace SocialConnecter;

use Facebook\Exceptions\FacebookResponseException; use Facebook\Exceptions\FacebookSDKException; use Facebook\Facebook;

class FacebookClient {

private $fb;
private $access_token;

public function __construct(Facebook $fb)
{
    $this->fb = $fb;
}

public function forUser($user)
{
    $this->access_token = $user->provider_token;
    return $this;
}

public function getPageListing()
{
    try {
        // Returns a `Facebook\FacebookResponse` object
        // '/625891200870224?fields=about,location,impressum,website,hours'
        $response = $this->fb->get('/me/accounts', $this->access_token);

// dd($response); } catch(FacebookResponseException $e) { echo 'Graph returned an error: ' . $e->getMessage(); exit; } catch(FacebookSDKException $e) { echo 'Facebook SDK returned an error: ' . $e->getMessage(); exit; }

    return $response;
}

}


but it come up with:
/SocialConnecter/FacebookClient
  14  - it can get page listing for a user
      expected [obj:spec\DailyMeal\SocialConnecter\PageListingResponseStub], but got null.

when the result is right like return 'test' and shouldreturn('test') it will throw not called exception.

Any idea?
20 Jul
3 years ago

thoresuenert started a new conversation Events, Eventlisteners And Queues: Sending Mails

Hey girls and boys, a key feature of my business logic is the mail sending parts. when the user send an mail it fires MailWasSent Event. The Eventlistener picks up and send the mail via Mailer.

I need infos about failing mails.

Should i queue the Eventlistener? Should i queue the Mailer? Should i queue both?

14 Nov
4 years ago

thoresuenert left a reply on How To Contributing To Existing Laravel Package?

yeah next time, FULL INFO.

But why it is removed?

thoresuenert left a reply on How To Contributing To Existing Laravel Package?

The Solution: When you are using Laravel 5

the workbench autoloading part is missing:

/*
|--------------------------------------------------------------------------
| Register The Workbench Loaders
|--------------------------------------------------------------------------
|
| The Laravel workbench provides a convenient place to develop packages
| when working locally. However we will need to load in the Composer
| auto-load files for the packages so that these can be used here.
|
*/

if (is_dir($workbench = __DIR__.'/../workbench'))
{
    Illuminate\Workbench\Starter::start($workbench);
}

put i at the end of bootstrap/autoload.php

13 Nov
4 years ago

thoresuenert left a reply on How To Contributing To Existing Laravel Package?

the package has not the workbench structure from the docs, maybe that is the problem ... i changed the vendor to mitchellvanw with no effect.

it doesn't work. i will give up.

thoresuenert left a reply on How To Contributing To Existing Laravel Package?

I did the autoload and added the provider afterwards. The App cannot find the files... This is frustrating, again again and again

thoresuenert left a reply on How To Contributing To Existing Laravel Package?

php artisan dump-autoload
workbench/thoresuenert/laravel-doctrine/src/LaravelDoctrineServiceProvider.php

result:

PHP Fatal error: Class 'Mitch\LaravelDoctrine\LaravelDoctrineServiceProvider' not found in /vagrant/vendor/laravel/framework/src/Illuminate/Foundation/ProviderRepository.php on line 158

thoresuenert left a reply on How To Contributing To Existing Laravel Package?

  1. but the composer dependencies are removed from vendor. they are missing now?

  2. no way to get the service provider working. maybe i have to manipulate the path or something in my fork. don't know what to do...

thoresuenert left a reply on How To Contributing To Existing Laravel Package?

  1. I have to move dependencies to root/composer.json, right?

  2. removing and run dump-autoload works, like expected. Readding and running dump-autoload fails. I have to add the service provider, right? Or is there some magic involved?

thoresuenert left a reply on How To Contributing To Existing Laravel Package?

  1. that removes all dependencies from vendor.
  2. the service provider of the package cannot be found

thoresuenert started a new conversation How To Contributing To Existing Laravel Package?

I am in the situation where i had to fork an existing package for the moment, because the package takes more time to make the changes.

I want to move that package into a workbench, so i can test and develop somethings for later contribution.

I am using the package via composer and added a repository entry for the fork at github:

"repositories": [{
        "type": "vcs",
        "url": "https://github.com/thoresuenert/laravel-doctrine"
    }],

How to move that repo under development into a workbench? I tried the way mentioned in this reddit post: http://www.reddit.com/r/laravel/comments/2el65h/a_question_about_editing_packages/ck0syex

13 Oct
4 years ago

thoresuenert left a reply on Multi-user Types

@mikebronner yeah but you can fall into the IF everywhere trap. You a different views for both types. With STI you can control the flow by type and not by ifs or permission or role checks, which will lead to better code. think about the situation where an intern and freelancer have same access permission but have a different view of the resource. With DDD it is a completely different task/command which type is doing sth. So using STI makes it easier to create commands by take. (what i have in mind)

I am modelling my logic right now. Reading much, too much?, about DDD and business logic and avoiding IFs etc. I should sign a bigger picture of my problem to evaluate the STI thing better.

thoresuenert left a reply on Multi-user Types

From my point of understanding could be single table inheritance a solution too. I don't know if the different user types should be solved by adding roles and permissions. Because a UserType isn't a Role for me. What if you have two different UserTypes which have different attributes/relations but have the same Role Permissions? Maybe i have an expert intern and freelancer. The freelancer has prize lists for different things and the expert have a contract for payments. In the end i have two totally different things for contract/payment.

I am going to solve the same problem with single table inheritence and save the class/type in the users table which hold the authentication credentials.

10 Oct
4 years ago

thoresuenert left a reply on Laravel ORM Value Object

@thepsion5 "When models are popualted from the database, it still uses any mutators you define on the class, so you don't even NEED a getter for simple value objects." How to define that mutators? Can't find it in docs.

09 Oct
4 years ago

thoresuenert left a reply on Laravel ORM Value Object

I would think about using a composer Package for value objects and handling the transformation within getFooAttribute and setFooAttribute which are automatically called by $model->foo = $bar

09 Sep
4 years ago

thoresuenert left a reply on Laracasts Validation Package Unique Rule On Update

@JeffreyWay gave the answer already at https://github.com/laracasts/Validation/issues/6#issuecomment-51113831

public function excludeUserId($id)
{
    $this->rules['username'] = "required|unique:users,username,$id"

    return $this;
}

Then, you can do $this->updateAccountForm->excludeUserId(Auth::id())->validate();

thoresuenert started a new conversation Laracasts Validation Package Unique Rule On Update

Hey guys, i am falling in a trap on the unique rule when i try to update a retrieve object.

protected $rules = [
        'name'    => 'unique:downloads|required'
    ];

then the validation:

$this->downloadForm->validate(Input::only('name','file'));

will fire the unique rule is hurt.

How to solve that problem? I read about adding the ID manually, but the form Object dont know the model.

03 Sep
4 years ago

thoresuenert left a reply on Artisan Migrations Refresh

it was an confusing console error that base view exists. Ending up with wrong definition of column for foreign key.

->unsigned()->index();

was missing

thoresuenert started a new conversation Artisan Migrations Refresh

Hey girls and boys, After running the refresh command i am stuck after rollback because of wrong order of migrations.

2014_07_31_211115_create_password_reminders_table.php
2014_07_31_220307_create_session_table.php
2014_08_01_113002_create_user_table.php
2014_09_03_130445_create_fields_table.php
2014_09_03_131752_create_specials_table.php
2014_09_03_132227_create_special_user_table.php

I guess the only relevant thing is the ID after the timestamp otherwise i have not this problem.

How to solve this one?

29 Aug
4 years ago

thoresuenert started a new conversation Nested Controller With Partial For Each Controller

Hey guys, i am using a single app written with backbone right now. But that isnt ideal because of async file uploads is kind of pita.

for example i have an email client like Mail.app: on the left side i have a scroll down list of my mails/conversations. on the right side i have the full mail shown up.

I am stuck how to handle the state of the partials with nested routes. Anyone an idea?

28 Aug
4 years ago

thoresuenert left a reply on Envoy And Local Composer Installation On Remote Server

@henrique thanks for the information update vs install. Without "php" it will end up with the same error.

thoresuenert started a new conversation Envoy And Local Composer Installation On Remote Server

I have the following deploy script:

@task('stage', ['on' => 'staging'])
    cd portal
    git pull origin {{ $branch }}
    php ~/composer.phar update
    php artisan migrate
    php artisan db:seed
@endtask

i tried to add an .bashrc alias for the composer.phar i tried

~/composer.phar
../composer.phar

But i setting an alias has no effect on envoy.

the remote connection quits with this error:

fatal: Invalid refspec '/var/www/vhosts/staging/composer.phar'

but the path is the right one. I cannot find any information about this problem. Anyone has an idea?

thoresuenert left a reply on Gitlab And Deployment

solved by myself. it works the way i thought.

thoresuenert started a new conversation Gitlab And Deployment

I am implementing a staging server for my project right now. I have a staging server and a gitlab server. From my point of understanding i can use the deploy key to grant readonly access.

On the staging server i want to pull/clone the gitlab repo with the deploy key.

Is that the right way to do it? If yes, how to do it the right way?

thoresuenert left a reply on Finding An Item In A Paginated View

Out of the box the natural order in a mysql table is the ID. get the ID of the image you are looking for.

SELECT COUNT(*) FROM image WHERE id <= IDofImage

thoresuenert left a reply on Finding An Item In A Paginated View

The codesnippet shows, that you don't have any order by statement? If you can use a order by $name the solution can be:

SELECT COUNT(*) FROM image WHERE $name <= 'imageGetPageOf'

that will return the row number of the image of interest.

pageOfImage = row number / page length
27 Aug
4 years ago

thoresuenert left a reply on Component API For Blade

Should a normal include do the trick?

@include('partials.ads',['label' => 'hello']) 

I cant see any difference between ur approach and using include.

also see http://laravel-recipes.com/recipes/90

thoresuenert left a reply on IP Filter For Auth

I am using the Homestead Vm out of the box. It is using nginx, but i dont know if there is a proxy involved. Does VirtualBox handle the Request by proxy?

Request::header('host') gives the Application URL Request::getClientIp() gives the IP of the Homstead VM.

All tests are running in local env. Tomorrow i am able to test it in production env.

thoresuenert started a new conversation IP Filter For Auth

Hello guys, i have to devide my user in two groups, internal and external. the internal user have a fixed IP range.

After auth::attempt i have to check the IP address, but the Request::getClientIp() is the same as the Homestead IP.

From my point of view, the IPs should be different. Am i wrong?