Pixelairport

Pixelairport

Member Since 3 Years Ago

Berlin

Experience Points
18,480
Total
Experience

1,520 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
166
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 4
18,480 XP
Feb
15
1 week ago
Activity icon

Replied to Laravel Queue Should Wait Till The Next Job

I used

php artisan queue:work --queue="high"

first, which seems to do all things at once. When I use

php artisan queue:listen --queue="high"

it seems it first do one thing and then another. Is that correct?

Feb
14
1 week ago
Activity icon

Started a new Conversation Laravel Queue Should Wait Till The Next Job

Hi. I test my application with terminal and tinker. My job creates a db entry in a table called "track" if it is finished. It also checks at the beginning if there is a entry to avoid doing the same thing more than once in a set period. The problem i have is, that when I start the worker and push the dispatch event multiple times in a very short time, the job is done more than one time and I have 3 or 4 entries in track table, because it is done often. So it seems the jobs running parallel. Is there a workaround for this?

In my example i send an notification email to user with the number how many private messages he has. So the email should only be send every 14 days.

Feb
13
1 week ago
Activity icon

Awarded Best Reply on Problem With Bind And Get The Classes With App()

Ok it works... when i do it with a closure.

public function handle(TrackereventRepository $tracker) { // ... }

thx

Activity icon

Replied to Problem With Bind And Get The Classes With App()

Ok it works... when i do it with a closure.

public function handle(TrackereventRepository $tracker) { // ... }

thx

Activity icon

Replied to Problem With Bind And Get The Classes With App()

I tried it another was and now i got an output with "Serialization of 'Closure' is not allowed". Dont know how to get the binded repository. Have someone an idea? I wonder why $this->mailerHelper = app('mailer.helper'); is working and $this->trackerevent = app('tracker.trackerevent'); not.

Activity icon

Started a new Conversation Problem With Bind And Get The Classes With App()

Hi. I binded two different classes (a helper and a repository) with providers. Now i create a job for queueing the send of emails. In the handle() method I try to get these binded classes. The strange thing is the first one works the second not:

    $this->mailerHelper = app('mailer.helper');

    $this->trackerevent = app('tracker.trackerevent');

When i do dd($this->trackerevent) I get the same as when i do dd(app()). The other thing works as expected ($this->mailerHelper). It is really strange and I hope someone has an idea.

Feb
07
2 weeks ago
Activity icon

Replied to Textarea Validation Problem With Max, Because Of \r\n

Thank you... that helped me a lot. I have to check some other things... because you said PHP_EOL i had a new thing to search for, so I just found a method i did not knew. strtr(). I everytime used str_replace(). With strtr I can also replace \r\n... I check this and also a PHP_EOL version... thx

Activity icon

Replied to Textarea Validation Problem With Max, Because Of \r\n

I output the text with dd($mytext) and see the \r\n, but i could nocht replace it. Tried it with str_replace. The \r\n is also orange, and the normal text is green. I just dont get it replaced.

Activity icon

Started a new Conversation Textarea Validation Problem With Max, Because Of \r\n

After a lot of time, I found out that max validation makes problems, when I have an textarea. For example I write this:

Hello
World

This should be 10 chars. But Laravel says its 11. The Problem is that i have set maxlength to the textarea field to 10. And also the validation for max is 10. I type in the whole text with 10 chars and get an error. Because laravel seems to add for each break an \r\n (with an empty space at the end. I mean "\r\n "). I think this could be the problem. But what could I do? I found a lot for replace stuff at google but this all does not help. The \r\n is still there.

Activity icon

Replied to DB Query Which Has Exactly Two Relations

Participant is just a relation table which has thread_id and user_id. The users are attached with this tabel to the treads. But i think that is ok for now, because it works. Maybe i will refactor it, when i have time. thx

Activity icon

Replied to DB Query Which Has Exactly Two Relations

It returns a result. But i get every conversion where user 1 or 57 is involved. I need exactly the one conversion between these two. But i had a idea. Maybe not perfect, but works for my first version. Sometimes I just have to talk (or write) about my problem to think again in another way about it... so thx ;) ... Here is what works for me now (I first get the results of all conversions with the ids and then check the count of participants with the array):

$q = $this->whereHas('participants');        
foreach($aUserIds as $k => $v) {
            $q->whereHas('participants', function ($query) use($v) {
                $query->where('user_id', $v);
            });
        }

        foreach($q->get() as $conversion){
            if($conversion->participants->count()==count($aUserIds)){
                return $conversion;
            }
        }

        return null;
Activity icon

Started a new Conversation DB Query Which Has Exactly Two Relations

I build a message system. When a user creates a new message to a user i will check if there is already a conversation for theses users to attach the message. Otherwise a new thread will be opened. I have problems to create the query in laravel.

return $this->whereHas('participants', function ($query) { $query->where('user_id','=',1)->where('user_id','=',57); })->get();

This is my first idea. I also tried whereIn, but this is checking for just one id (1 or 57). I need the conversation, where only 1 and 57 are participants. Also if there is another thread where there are 1, 57 and 173 (for example) participants. Hope you understand what i mean. And also hope you can help me with this problem. thx.

Jan
08
1 month ago
Activity icon

Awarded Best Reply on Error With Mix.js In Production Mode

Ok. I found a solution. I use platform cartalyst, which compiles the files again and minify it. I load the app.js the normal way with: instead using the class to load assets from cartalyst.

Activity icon

Replied to Error With Mix.js In Production Mode

Ok. I found a solution. I use platform cartalyst, which compiles the files again and minify it. I load the app.js the normal way with: instead using the class to load assets from cartalyst.

Activity icon

Started a new Conversation Error With Mix.js In Production Mode

In my laravel project I use vue and it works as long as I do "npm run dev". But when I do "npm run production" I get an error: Uncaught SyntaxError: Invalid regular expression: missing /

What I found out is, that in prodcution mode the app.js file is minified. That seems to be the problem, because when i open the minified version in PhpStorm and select all and press alt+cmd+L the file is unminified (is this is the right word :)) ... after this everythings works again.

So I need to know how to avoid this minify version. I cant just do copy, because this is the main vue file, which need to be compilied.

thx

PS: Already have this in my webpack.mix.js:

mix.options({uglify: false});

but this doesnt work.

Dec
16
2 months ago
Activity icon

Awarded Best Reply on Medialibrary With Existing S3 Files

Ok. I use transloadit which copies the files to s3 and then i do another upload with spatie medialibrary, which use the path of the uploaded file and upload it a second time to right directory. For the start that works. If my project work, i will find another solution.

Activity icon

Replied to Medialibrary With Existing S3 Files

Ok. I use transloadit which copies the files to s3 and then i do another upload with spatie medialibrary, which use the path of the uploaded file and upload it a second time to right directory. For the start that works. If my project work, i will find another solution.

Dec
06
2 months ago
Activity icon

Replied to Medialibrary With Existing S3 Files

Im a step closer...

$song->addMediaFromUrl($file)->toMediaCollection('song','songs');

This is what i do in my code, after upload the file with transloadit. The problem is, that the file is taken from s3 again and is duplicated into a second folder on s3. But the file is already there. Is there a way just to attach a file without uploading it?

Dec
05
2 months ago
Activity icon

Started a new Conversation Medialibrary With Existing S3 Files

I use Spatie Medialibrary for avatar images in my project. Now I want to add uploads. These are uploaded with transloadit. That means not with the normal laravel Storage or Spatie Medialibrary. But I want to connect the file after the upload with model item. Is that possible and makes this sense? I always get errors like "File not exist". Or should i use another workaround for this without medialibrary?

Nov
18
3 months ago
Activity icon

Replied to Validate Fields Like: Custom[link][homepage]

top :) thx... that was what im looking for :)

Nov
17
3 months ago
Activity icon

Started a new Conversation Validate Fields Like: Custom[link][homepage]

Most of the times I have fields with name="username", which I can validate with:

$this->rules['username'] = 'required|string|min:2|max:32';

But now I have a vield with name="custom[link][homepage]". How should the syntax look like for this?

thx Norman

Nov
02
3 months ago
Activity icon

Started a new Conversation How To Save Images Path To Different Image Sizes?

I create a extension which have creates differents sizes for image uploads. For example I have an avatar. The full/path/to/image.jpg is stored to my users database. Now i want to upload mulitple files to public folder. This could look like this:

public/user/3nfHGe/avatar/msne484ng.jpg public/user/3nfHGe/avatar/small/msne484ng.jpg public/user/3nfHGe/avatar/large/msne484ng.jpg

I can change the macros for building these different sizes in a config file. So in one project i maybe have 2 macros in another one i have 10.

Now I try to find the best way to save the path to images in database. Would you save each to database in a single row, or would you do another field in users and save it as array or json in database, or would you split the filename and path and do everything in code. I mean recreating the full path in a controller or repository for example?

Nov
01
3 months ago
Activity icon

Started a new Conversation Save Whole Path To Image For Uploads?

Hi,

just wanted to ask if it is ok or best practise to save the whole path to database for uploads like avatars. I use Storage at laravel and get for example something like: user/4vR54Bnm/avatar/LJOGQJLe48GFceQxV5g4X5n8DZ1nguuZ7HQMzJj.png

The first part (user/4vR54Bnm/avatar/) is the path i want to use for the file and LJOGQJLe48GFceQxV5g4X5n8DZ1nguuZ7HQMzJj.png is the file.

Would you explode the full path and only store the file in database and create the full path again in your code? It is easier to store the whole path in db. But can i get problems with that later? What is best practise for that. I just ask before use it in my life project.

thx Norman

Oct
25
3 months ago
Activity icon

Awarded Best Reply on Phpunit.xml Does Not Use My Sqlite Settings

Ok. After a lot of hours i found the problem. It was my fault... I ever was thinking that

php artisan config:cache

does the same as

php artisan config:clear & php artisan cache:clear

But that isn't so... not sure why... but when i do the second version (first config:clear then cache:clear) it works.

Activity icon

Replied to Phpunit.xml Does Not Use My Sqlite Settings

Ok. After a lot of hours i found the problem. It was my fault... I ever was thinking that

php artisan config:cache

does the same as

php artisan config:clear & php artisan cache:clear

But that isn't so... not sure why... but when i do the second version (first config:clear then cache:clear) it works.

Oct
24
3 months ago
Activity icon

Replied to Phpunit.xml Does Not Use My Sqlite Settings

Yes. This is done by laravel as default. I changed nothing. I just set the two lines in phpunit.xml which is in root folder. Laravel comes with phpunit out of the box.

Activity icon

Replied to Phpunit.xml Does Not Use My Sqlite Settings

No. I dont set this be my own. I have the default user model and then another one:

class Trailer extends Model
{
    protected $fillable = [
        'title', 'tmdb_movie_id', 'site', 'key', 'size'
    ];
}
Activity icon

Replied to Phpunit.xml Does Not Use My Sqlite Settings

output is: alias phpunit='vendor/bin/phpunit'

Activity icon

Replied to Phpunit.xml Does Not Use My Sqlite Settings

With terminal while inside homestead/vagrant.

  1. vagrant ssh
  2. phpunit --filter=myTestFile
Activity icon

Started a new Conversation Phpunit.xml Does Not Use My Sqlite Settings

I start to learn testing. After a lot of tests I realized, that even if i setup my phpunit.xml to use sqlite, it uses my main database, which is mysql.

I have this in my phpunit.xml:

    <server name="APP_ENV" value="testing"/>
    <server name="BCRYPT_ROUNDS" value="4"/>
    <server name="CACHE_DRIVER" value="array"/>
    <server name="MAIL_DRIVER" value="array"/>
    <server name="QUEUE_CONNECTION" value="sync"/>
    <server name="SESSION_DRIVER" value="array"/>
    <server name="DB_CONNECTION" value="sqlite" />
    <server name="DB_DATABASE" value=":memory:" />

I don't want to use my production database for all my tests. I think it is better to use another one. But what have I forgot?

Oct
23
3 months ago
Activity icon

Replied to Best Way To Use Database At Testing

Thx @tykus ... sometimes i just need something to search for. Your really helped me to find a solution. The solution with php-vcr works. I also found a video here on laracasts: https://laracasts.com/lessons/testing-http-requests

Activity icon

Started a new Conversation Best Way To Use Database At Testing

I try to start with testing and wrote my first tests. Now i want to test things with database. Normally it creates every entry in the database which is my main database. So i switch to sqlite (:memory:). That means i have to do migrations everytime. The problem is, that i use other apis to get data into the database which i need. Its an app for movies and i need to get 100 movies for each test ... What is the best way now? Normally the application caches the movies for a few hours, but testing loads it everytime again and says "too many requests".

  1. Should i only work with fake data? I mean: Should i test the api in an extra test and the rest of my application with fake data (factories)?
  2. Should i use my live database and reset everything after tests. I think this is possible but not clever.
  3. Is there a way to use cache from my original application? And is that good ... i think this can get confusing when i have to test caching stuff. And also my repositories would throw errors.

What do you think? Or what is the best way. Im new to testing and the conept is a bit confusing for me.

Oct
14
4 months ago
Activity icon

Replied to Testing Json Status (with GuzzleHttp)

ok. i call the wrong parameters in console and did

phpunit --filter=unit/MovieDbApiTest.php

when only call

phpunit

it works.

this is the new test which works, if someone is interested.

public function it_has_api_access()
{
    $key = config('services.movieDb.key');
    $url = config('services.movieDb.url');
    $query = 'dumbo';

    $client = new Client();
    $response = $client->get("$url/search/movie?api_key=$key&query=$query");
    
    $this->assertEquals($response->getStatusCode(),200);
}
Activity icon

Started a new Conversation Testing Json Status (with GuzzleHttp)

I want to start with testing and wrote my first test. But the test always says that everything is ok. When using the code in a normal route and output the status i got 200... here i check for 500... but i also get an ok. Can anyone help?

public function it_has_api_access()
{
    $key = config('services.movieDb.key');
    $url = config('services.movieDb.url');
    $query = 'dumbo';

    $client = new Client();
    $response = $client->get("$url/search/movie?api_key=$key&query=$query");
    $response->assertStatus(500);
}