bambamboole

Experience

24,840

0 Best Reply Awards

  • Member Since 1 Year Ago
  • 243 Lessons Completed
  • 2 Favorites

22nd February, 2018

bambamboole left a reply on Gitlab CI Weird Redis Host • 4 months ago

Nope, I wasn't not working on this project since I created the thread.

3rd January, 2018

bambamboole left a reply on Uploading Finished Project To Your Server - Confusing. • 5 months ago

Hi @JJK ,

a full explanation of how to install a secure webserver is a bit to much for a discussion here. But I have a link for you:

This is for Ubuntu but its almost the same because its Debian based. https://www.digitalocean.com/community/tutorials/how-to-install-laravel-with-an-nginx-web-server-on-ubuntu-14-04

Another very great resource is https://serversforhackers.com/

Hope that helps you.

cheers

bambamboole left a reply on Maybe Add A Default Markup For A New Discussion • 5 months ago

This would be very nice!

26th December, 2017

bambamboole left a reply on How To Test A View Composer In Laravel? • 5 months ago

I found a solution:

class SidebarComposerTest extends TestCase
{

    /**
     * @test
     */
    public function it_passes_the_latest_posts_to_the_view(): void
    {
        $latestPosts = [1,2,3,4,5];
        $post = \Mockery::mock(Post::class);
        $post->shouldReceive('getLatestPosts')->andReturn($latestPosts);
        $composer = new SidebarComposer($post);
        $view = \Mockery::spy(View::class);

        $composer->compose($view);

        $view->shouldHaveReceived('with')->with('latestPosts', $latestPosts);
    }
}

If someone has a better idea, im open for input :-)

24th December, 2017

bambamboole left a reply on How To Test A View Composer In Laravel? • 5 months ago

@craigpaul no, the error is still the same.

23rd December, 2017

bambamboole started a new conversation How To Test A View Composer In Laravel? • 5 months ago

I want to test a view composer and I don't get how to...

I have a simple View Composer like this:

class SidebarComposer
{
    /**
     * @var Post
     */
    protected $post;

    public function __construct(Post $post)
    {
        $this->post = $post;
    }

    public function compose(View $view)
    {
        $view->with('latestPosts', $this->post->orderBy('created_at', 'desc')->take(5)->get());
    }
}

And my test looks like that

class SidebarComposerTest extends TestCase
{
    use DatabaseMigrations;
    /** @test */
    public function it_passes_the_latest_posts_to_the_view()
    {
        $posts = factory(Post::class,5)->create();
        $composer = app(SidebarComposer::class);
        $view = \Mockery::mock(View::class);

        $view->shouldReceive('with')->with(['latestPosts', $posts])->once();

        $composer->compose($view);
    }
}

The phpunit error I get is this :

Mockery\Exception\NoMatchingExpectationException : No matching handler found for Mockery_0_Illuminate_View_View::with('latestPosts', object(Illuminate\Database\Eloquent\Collection)). Either the method was unexpected or its arguments matched no expected argument list for this method

Does anyone have any suggestions on how to test the ViewComposer correctly?

15th December, 2017

bambamboole started a new conversation Gitlab CI Weird Redis Host • 6 months ago

Hi,

I use gitlab ci for testing a laravel 5.5 project which uses redis.

I have a REDIS_HOST with the value redis.

But in my phpunit pipeline I get the following error:

Predis\Connection\ConnectionException: Connection refused [tcp://redis:tcp://172.17.0.3:6379]

I don't know from where the IP comes and why it writes two times tcp:// .

Local tests works like a charm.

thanks in advance bambamboole

13th November, 2017

bambamboole started a new conversation How To Handle Multi Model Relationships In Laravel • 7 months ago

Hi,

I want to build a blog based on Laravel. But the content of a blog post won't be a normal wysiwyg field but can contain many blocks of different types.

Lets say we have an article which has a title and a one to many relation to blocks. But the blocks can be from different types (like a photo block, text block etc.)

How can I handle the relation from an article to the different blocks with one relation method (blocks()) ?

Or does anyone has a better solution?

thanks in advance cheers bambamboole

21st October, 2017

bambamboole left a reply on [Help Needed] SVG Sprites With Laravel.Mix • 8 months ago

I get an error with this config: ENOENT: no such file or directory, open '/Users/mchristlieb/Sites/treenio/website/public/spritemap.js'

Does anyone has any suggestions?

6th October, 2017

bambamboole left a reply on ExampleTest Fails In Gitlab CI • 8 months ago

After checking the logs on the CI server I realized I added the mix-manifest.json to my gitignore... That's why it worked locally but not on the CI server. My bad :)

bambamboole left a reply on ExampleTest Fails In Gitlab CI • 8 months ago

Thanks @ftrillo, much appreciated. Unfortunately that didn't help.

bambamboole started a new conversation ExampleTest Fails In Gitlab CI • 8 months ago

Hi folks,

I built a simple gitlab ci with the following docker container:

# Set the base image for subsequent instructions
FROM php:7.1

# Update packages
RUN apt-get update

# Install PHP and composer dependencies
RUN apt-get install git curl libmcrypt-dev libjpeg-dev libpng-dev libfreetype6-dev libbz2-dev -yqq

# Clear out the local repository of retrieved package files
RUN apt-get clean

# Install needed extensions
# Here you can install any other extension that you need during the test and deployment process
RUN docker-php-ext-install exif mcrypt pdo_mysql zip

# Install Composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

# Install Laravel Envoy
RUN composer global require "laravel/envoy"

with this gitlab-ci.yml:

image: registry.gitlab.com/treenio/treenio:latest

stages:
  - test
  - deploy

cache:
  paths:
  - vendor/

before_script:
    - cp .env.example .env
    - composer install

phpcs:
  stage: test
  script:
    - vendor/bin/phpcs

unit_test:
  stage: test
  script:
    - php artisan key:generate
    - vendor/bin/phpunit

When running the test locally everything works fine. As well with the docker container locally.

But in the Gitlab CI the ExampleTest fails with a 500 instead of a 200 status code. All other tests are green.

There was 1 failure:

1) Tests\Feature\ExampleTest::testBasicTest
Expected status code 200 but received 500.
Failed asserting that false is true.

/builds/treenio/treenio/vendor/laravel/framework/src/Illuminate/Foundation/Testing/TestResponse.php:77
/builds/treenio/treenio/tests/Feature/ExampleTest.php:25

FAILURES!
Tests: 5, Assertions: 7, Failures: 1.
ERROR: Job failed: exit code 1

Anyone any suggestions why the test fails in the CI ?

Thanks in advance bambamboole

6th May, 2017

bambamboole started a new conversation Vue Axios Post Register Route • 1 year ago

Hi,

i've got a problem with my register components axios post request:

This is my code:

<script>
    import axios from 'axios';
    export default {
        props: [],
        data() {
            return {
                formInputs: {},
                formErrors: []
            }
        },
        created() {
            console.log('Signup component');
        },
        methods: {
            submitForm(){
                console.log(this.formInputs);
                axios.post('/register', this.formInputs)
                    .then(function (response) {
                        console.log(response);
                    })
                    .catch((error) => {
                        console.log(error);
                        this.formErrors = error;
                    });
            }
        }
    }
</script>

When the there are validation errors, the response has status code 422 and enters the catch promise(I believe its called a promise :-) ) and I doesn't have access to the payload of the response with the validation error messages for setting them on the form.

Does anyone have a hint for a solution of this problem?

thanks in advance

bambamboole

5th May, 2017

bambamboole left a reply on Image Resize/crop In Blade Templates • 1 year ago

I thought the same...

Is there maybe another solution for this issue where I can handle this inline?

4th May, 2017

bambamboole started a new conversation Image Resize/crop In Blade Templates • 1 year ago

Hi,

I'm searching for a way to resize/crop images on the fly in Blade Templates. Preferably with Caching of the images.

I need it for building responsive images with srcset.

Thanks in advance bambamboole

Edit Your Profile
Update

Want to change your profile photo? We pull from gravatar.com.