skauk

skauk

Member Since 1 Year Ago

Experience Points
35,420
Total
Experience

4,580 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
150
Lessons
Completed
Best Reply Awards
34
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
35,420 XP
Feb
24
1 day ago
Activity icon

Replied to How To Update A Laravel Vue Project?

@uhbc this project doesn't use Mix. Can you show the contents of package.json?

Feb
23
2 days ago
Activity icon

Replied to Send Mail With SMTP And Storing "message-id"

@23andreas This is not working with every driver, so you'll be probably better off using a listener like described above.

Feb
20
5 days ago
Activity icon

Replied to Send Mail With SMTP And Storing "message-id"

@23andreas Mail facade's send() method accepts a callback as the 3rd parameter, so you can get a message ID from there. For example:

$message_id = "";
Mail::to($replyToMessage->sender_email)->send(
    new SupportCaseReply($replyToMessage, $user, $message)),
    [], 
    function ($message) use (&$message_id) {
        $message_id = $message->getId();
    });
Feb
18
1 week ago
Activity icon

Awarded Best Reply on Unresolvable Dependency IsdownForMaintenance

@donneh Maybe this comment will be useful for you.

Feb
07
2 weeks ago
Activity icon

Awarded Best Reply on Custom Laravel Nova Avatars

@daugaard47 You could put that logic into an accessor on the model and get it from everywhere, including Nova. In the model class:

public function getAvatarAttribute($value)
{
    if ($value == 'DefaultAvatar.png'){
        return 'https://mysite.com/images/DefaultAvatar.png';
    } elseif (strpos($value, 'gravatar') == true) {
        return  $value;
    }

    return "https://mysite.com/images/users/${this->id}/${value}";
}

Because you already have the avatar field on the model your $value parameter, in this case, will be the value of this field from the database.

Feb
06
2 weeks ago
Activity icon

Replied to SOLID-principle - Single Responsibility

@dutchroyals It seems fine. Logout is a part of the login lifecycle so it appears placed appropriately. Perhaps you could make a single method for logout which works for the mobile app too. However, this is totally up to you. Whatever is most convenient for your case.

Activity icon

Replied to Custom Laravel Nova Avatars

@daugaard47 You could put that logic into an accessor on the model and get it from everywhere, including Nova. In the model class:

public function getAvatarAttribute($value)
{
    if ($value == 'DefaultAvatar.png'){
        return 'https://mysite.com/images/DefaultAvatar.png';
    } elseif (strpos($value, 'gravatar') == true) {
        return  $value;
    }

    return "https://mysite.com/images/users/${this->id}/${value}";
}

Because you already have the avatar field on the model your $value parameter, in this case, will be the value of this field from the database.

Feb
05
2 weeks ago
Activity icon

Awarded Best Reply on Undefined Variable $model, When Passing Route To Component

@splendidkeen You can essentially pass anything else as a parameter to the route so later you can use it as a template to make a URL:

<model-list model-route="{{ route('model.show', '%id%') }}"></model-list>
// ...
<div v-for="model in models">    
    <model :model="model"  :modelRoute="modelRoute.replace('%id%', model.id)"></model>
</div>
Activity icon

Awarded Best Reply on Create A Group Function For Relationships In Model

@gzai Essentially this is alright already. You can further refine it depending on how many this type of relationship you have. Another idea would be to create a generic model Log and have a field type on it, so you can get all related entries and then group them by type: $model->log->groupBy('type').

Activity icon

Replied to Create A Group Function For Relationships In Model

@gzai Sure it can exhaust the memory depending on the amount of data you have there. I think you can be better off exploring the direction of putting all logs into a single model. If you find this useful, please go ahead and mark as the best reply. Thanks!

Activity icon

Replied to Undefined Variable $model, When Passing Route To Component

@splendidkeen You can essentially pass anything else as a parameter to the route so later you can use it as a template to make a URL:

<model-list model-route="{{ route('model.show', '%id%') }}"></model-list>
// ...
<div v-for="model in models">    
    <model :model="model"  :modelRoute="modelRoute.replace('%id%', model.id)"></model>
</div>
Activity icon

Replied to Custom Laravel Nova Avatars

@daugaard47 When you create a User be it with Nova or any other way there are a number of events you can listen to and populate your avatar field accordingly. You can use event listeners or observers but for simple stuff, you can use this simple pattern: In your model class override the boot method:

protected static function boot()
{
    static::creating(function ($model) {
        $hash = md5(strtolower(trim($model->email)));
        $gravatar = 'http://www.gravatar.com/avatar/'.$hash.'??s=200&d=identicon';
        $model->avatar = $gravatar;
    });

    parent::boot();
}
Activity icon

Replied to Create A Group Function For Relationships In Model

@gzai Essentially this is alright already. You can further refine it depending on how many this type of relationship you have. Another idea would be to create a generic model Log and have a field type on it, so you can get all related entries and then group them by type: $model->log->groupBy('type').

Activity icon

Replied to Return Laravel Exception To Vue

@dawgonking You can do try/catch and return a response inside the catch block:

try {
    // some code here
}
catch (Exception $e) {
    return response()->json(['status' => $e->getMessage()]);
}
Activity icon

Replied to SES On Vapor

@theunforgiven Make sure that you have the following configuration in your config/services.php:

'ses' => [
        'key' => env('AWS_ACCESS_KEY_ID'),
        'secret' => env('AWS_SECRET_ACCESS_KEY'),
        'region' => env('AWS_DEFAULT_REGION'),
    ],

Vapor will inject these environment variables automatically. Make sure you also have MAIL_DRIVER set to ses (this is the default) using command vapor env:pull production. Also check if your SES account is not in the sandbox mode (open SES in AWS console and it should have a note on top if it is.) so you can send e-mails not only to your verified ones and of course you have to add your domain and e-mail address in SES.

Feb
03
3 weeks ago
Activity icon

Replied to Unable To Install Spark

@utchin You have to review what exactly happens during the CI build. Sometimes composer dependencies are installed without the project code and then get copied over. For Spark you have to have the spark folder in place in order to install it successfully.

Jan
31
3 weeks ago
Activity icon

Awarded Best Reply on Laravel Excel Uninitialized String Offset

@annbooney It seems like the array you are getting from ReportTrabajosExport ->array() only has 4 elements, so you don't really need map() method and WithMapping interface.

Activity icon

Awarded Best Reply on Merge Collection - Why They Remove Item

@sevensoft You are effectively replacing screen key in your collection with the new one. If this is what you wanna do you should do it like this:

$res = $a1->replaceRecursive($a2);

This way you end up with the following structure:

Illuminate\Support\Collection {#983
     all: [
       "screen" => [
         "diagonal" => "12.0",
         "pixel" => "1920x1080",
       ],
     ],
   }
Activity icon

Replied to Laravel Excel Uninitialized String Offset

@annbooney It seems like the array you are getting from ReportTrabajosExport ->array() only has 4 elements, so you don't really need map() method and WithMapping interface.

Activity icon

Replied to Custom Rule Not Working

@bigweld86 What syntax error are you getting?

Activity icon

Replied to Merge Collection - Why They Remove Item

@sevensoft You are effectively replacing screen key in your collection with the new one. If this is what you wanna do you should do it like this:

$res = $a1->replaceRecursive($a2);

This way you end up with the following structure:

Illuminate\Support\Collection {#983
     all: [
       "screen" => [
         "diagonal" => "12.0",
         "pixel" => "1920x1080",
       ],
     ],
   }
Jan
30
3 weeks ago
Activity icon

Replied to Not Able To Add Foreign Key

@hjortur17 The columns have to be the same type, so if you're referencing the id column that is BIGINT then the foreign key column has to be BIGINT as well.

Activity icon

Replied to Undefined Offset: 1 In Dynamic Input Field

@noblemfd In the last code snippet why do you increment $i by 2 each time and why do you do $segments[$i + 1] inside the loop? What happens is that you try to access $segments[1] on the first iteration when $i = 0 and because of this element is not set you're getting that error. The easiest way to fix it would be to add a fallback:

$extra[$segments[$i]] = $segments[$i + 1] ?? null;
Activity icon

Awarded Best Reply on Error Laravel Excel 3.1

@annbooney I believe it should be:

(new ReportProduccionExport($codigo, $fromDate, $toDate))->download('invoices.xlsx');
Jan
29
3 weeks ago
Activity icon

Replied to Error Laravel Excel 3.1

@annbooney I believe it should be:

(new ReportProduccionExport($codigo, $fromDate, $toDate))->download('invoices.xlsx');
Activity icon

Replied to Using Laravel Blade File

@lukegalea16 You could just dump the whole $processedData array into your template and pick the values from it using select value in Javascript:

$data = @json($processedData)
Activity icon

Replied to Change Date Timezone In Laravel Project While Fetching Date.

@singhwithlaravel This has nothing to do with what you have originally asked.

Activity icon

Replied to Change Date Timezone In Laravel Project While Fetching Date.

@singhwithlaravel Sorry, I don't quite understand your point. Say you want to display the update timestamp of a model, so you would do $model->updated_at. With the technique described in the article you would do $model->localize('updated_at') instead, so there's nothing extra to do just a different way of accessing the date. Maybe I miss something? Please clarify.

Activity icon

Replied to Change Date Timezone In Laravel Project While Fetching Date.

@singhwithlaravel The article describes a HasLocalDates Trait that enables you to call $model->localize('date_attribute') and convert any date attribute to user's timezone without having an accessor for each one.

Activity icon

Replied to Share Model And REST URL Resources With 2 Different Users

@seanworks Usually you would use roles and/or permissions to address a situation like this. So when you users have roles/permissions you can check if they have a particular one that enables a feature and therefore something extra gets included in the response.

Activity icon

Replied to Change Date Timezone In Laravel Project While Fetching Date.

@singhwithlaravel This is required to add the extra fields with the localized date instead of making accessors for each one like you did.

Jan
28
4 weeks ago
Activity icon

Awarded Best Reply on Route Question Hierarchy

@seanworks You could do either of two. Just decide what works for you best. In both cases, you can benefit from route model binding:

Route::get('test/{test}/question/{question}', function (App\Test $test, App\Question $question) {
    return view('test', compact('test', 'question'));
});

The respective Test and Question entries will be retrieved for you behind the scenes based on their primary ids and you can customize this to use something different like a slug. Eg, /test/1/question/1.

In the first case you would probably want to limit access just to questions that belong to a particular test, so that's a little bit more elaborate, however, your URL structure will reflect your data structure which could be a benefit. With the second option it's a bit easier:

Route::get('test/{test}', function (App\Test $test) {
    $questions = $test->questions;
});

Route::get('question/{question}', function (App\Question $question) {
    $test = $question->test;
});
Activity icon

Replied to Change Date Timezone In Laravel Project While Fetching Date.

@singhwithlaravel Please check the article that I have linked in my previous reply. It addresses the very same problem that you are trying to solve. Towards the end, there is a Trait that creates a copy of each date attribute of a model adjusted for the local timezone of the user.

Activity icon

Replied to Authentication Undefined On Broadcast Channel

@splendidkeen Sorry, don't quite understand what you mean. Can you elaborate?

Activity icon

Replied to Authentication Undefined On Broadcast Channel

@splendidkeen In this code block:

Broadcast::channel('Posts.{postId}', function (User $user, int $postId) {
    $post = Post::findOrFail($postId);
    return $user->friends->where('friend_id', $post->user_id)->count() === Post::findOrFail($postId)->user_id;
});

You are retrieving the Post twice, retrieving all Friends of the User and comparing the count of Friends with the user_id of the Post. What you should be doing is checking if the user_id of the Post is among Friends of the User:

Broadcast::channel('Posts.{postId}', function (User $user, int $postId) {
    $post = Post::findOrFail($postId);
    return $user->friends()->where('friend_id', $post->user_id)->exists();
});
Activity icon

Replied to How To Add Multiple Child Row Data Together With Parent Row In Laravel Blade

@bosspogs You should group your form controls under the same key. For instance:

<input type="number" name="requisition[0][qty]" class="form-control quantity" required>  
<input type="text" name="requisition[0][unit]" class="form-control" required>  
<input type="text" name="requisition[0][description]" class="form-control" required>  

You should increase the index for each fieldset you add, e.g. requisition[1][qty]. Then you'll get all your data under a single key (request->get('requisition')) which will allow you to easily validate and process the data.

Activity icon

Awarded Best Reply on Column Not Found In 'group Statement' When Using Pagination

@martinzeltin Pagination won't work like this out of the box because of your query returning groups instead of single records that then can be hydrated into your model. There are ways that you can get around that. Take a look at this gist, it might help you with what you are trying to do.

Activity icon

Replied to $ Is Not Defined Vs #app Is Not Found

@tommy001 For jQuery you have to install it first (npm i jquery --save-dev) and include it in resources/js/bootstrap.js:

window.$ = window.jQuery = require('jquery');

Then compile your assets with Mix: npm run dev and you should be good.

Activity icon

Replied to How To Use Custom Domain Name Instead Of Ip Address.

@noblemfd You have to register a domain name and put your IP address in its A record. Then you need to configure your web server, so it knows to serve this specific website for this domain name. There are plenty of articles on how to do that for your specific web server software out there.

Activity icon

Replied to Change Date Timezone In Laravel Project While Fetching Date.

@singhwithlaravel Checkout this article. It seems to have everything you need to do what you want to do.

Jan
27
4 weeks ago
Activity icon

Replied to NGINX Multiple Level Auth_basic Authentication

@cruorzy Well, there's a reason it is called basic authentication. If your use case is more elaborate, you have to look into more complex authorization mechanisms.

Activity icon

Replied to How To Generate Unique Serial Number In Factory

@uksarkar Reservation has a primary key stored in the id column. So that would be a unique representation of a Reservation. What you do with uid is getting the id of the last record persisted in the database and adding 1000 to it. Can you please explain the logic behind this?

Activity icon

Replied to How To Generate Unique Serial Number In Factory

@uksarkar Okay, but the question still stands of what kind of relationship do you want to create with uid column.

Activity icon

Replied to How To Generate Unique Serial Number In Factory

@uksarkar What's your goal here? You are making your factory dependent on the existing database records. However, factories can generate models without saving them in the database and in this case you end up with the same numbers under uid field. Also, uuid is something different and when you use this term here it makes it harder to understand your case and help you.

Activity icon

Replied to Corcel Not Working On Server

@ajithlal Did you install the package with composer on the server?

Activity icon

Replied to Change Date Timezone In Laravel Project While Fetching Date.

@singhwithlaravel I belive app.php configuration file has a key timezone which defines the timezone for the application.

Activity icon

Replied to Same Query Different Result

@mozafar In the second query, the semicolon is unnecessary. Also in the first query, you're using IN operator while in the second it is =, so they are technically not the same.