Jantlap

Jantlap

Member Since 2 Years Ago

Experience Points
3,800
Total
Experience

1,200 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
31
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 1
3,800 XP
24 Apr
1 year ago

Jantlap left a reply on Signed URL's With Utm Tags

Yes, that is the point. Seems we would need to do our own URL signing.

Jantlap started a new conversation Signed URL's With Utm Tags

Hi,

Im using signed urls generated for e-mail, so the link is secure and cannot be tampered. But when we add some more tracking parameters to URL, like utm_tags, the validation will fail.

Is there any possibility to exclude get params from validation and validate only the part without GET parameters?

05 Feb
1 year ago

Jantlap left a reply on DI Services Using Auth Into Controller Constructor

This is indeed a solution, but sometimes you would like to make it available for all methods.

Jantlap started a new conversation DI Services Using Auth Into Controller Constructor

Hi,

is there a way to get this working? When DI is resolving services in Controller constructor, user is not present at the moment.

Controller

public function __construct(SomeService $someService)
 {
    parent::__construct();
    $this->middleware('auth');
    $this->someService = $someService;
 }

SomeService

public function __construct(AuthManager $authManager)
{
    // $authManager->user() is empty
}

Thanks for help.

03 Feb
1 year ago

Jantlap started a new conversation Phpstan Having Issue With Delete()

Hi,

Im having problem with my phpstan check, when checking $this->model->whereIn('some', $things)->delete(); phpstan is saying:

Method App\Repositories\Model::deleteBulk() should return int but returns bool|null.

But it returns int. Someone know how to fix that besides adding this into ignore list?

18 Jan
1 year ago

Jantlap left a reply on Cant Wrap My Head Around Markdown Mailables

This is actually mailable view.

I need to customize footer for every message, therefore I cant go with regular @component('mail::message') but with @component('mail::layout')

Jantlap left a reply on Cant Wrap My Head Around Markdown Mailables

Now I see problem is with indentation, this works now:

@component('mail::layout')
    {{-- Header --}}
    @slot('header')
        @component('mail::header', ['url' => config('app.url')])
            <!-- header here -->
        @endcomponent
    @endslot

    {{-- Body --}}
# {{__('emails.digest.header')}}

{{__('emails.digest.first_paragraph', ['list_name' => 'List name'])}}

@component('mail::panel')
{{__('emails.digest.subscribed')}} 1
@endcomponent

@component('mail::panel')
{{__('emails.digest.unsubscribed')}} 1
@endcomponent

{!! __('emails.digest.unsub', ['account' => 'acc', 'list_id' => 1]) !!}

{{__('emails.ps')}}

    {{-- Subcopy --}}
    @slot('subcopy')
        @component('mail::subcopy')
            <!-- subcopy here -->
        @endcomponent
    @endslot


    {{-- Footer --}}
    @slot('footer')
        @component('mail::footer')
            <!-- footer here -->
        @endcomponent
    @endslot
@endcomponent

Strange indeed.

Jantlap left a reply on Cant Wrap My Head Around Markdown Mailables

Hi @mdecooman , this is jist a regular title with translation

Jantlap started a new conversation Cant Wrap My Head Around Markdown Mailables

Hi,

Im struggling with markdown mailables, I want to have different footer for every e-mail. So Im trying:

@component('mail::layout')
    {{-- Header --}}
    @slot('header')
        @component('mail::header', ['url' => config('app.url')])
            <!-- header here -->
        @endcomponent
    @endslot

    {{-- Body --}}
    # {{__('emails.digest.header')}}

    {{__('emails.digest.first_paragraph', ['list_name' => 'List name'])}}

    @component('mail::panel')
    {{__('emails.digest.subscribed')}} 1
    @endcomponent

    @component('mail::panel')
    {{__('emails.digest.unsubscribed')}} 1
    @endcomponent

    {!! __('emails.digest.unsub', ['account' => 'acc', 'list_id' => 1]) !!}

    {{__('emails.ps')}}

    {{-- Subcopy --}}
    @slot('subcopy')
        @component('mail::subcopy')
            <!-- subcopy here -->
        @endcomponent
    @endslot


    {{-- Footer --}}
    @slot('footer')
        @component('mail::footer')
            <!-- footer here -->
        @endcomponent
    @endslot
@endcomponent

But that way the body is broken. Am I missing something?

Thanks for claryfying.

12 Jan
1 year ago

Jantlap left a reply on Extra Informations For Logged User

Thank you. It is a bit more complicated and we really can't use relations. But this answer would work indeed. What an easy solution!

What about boot method, is it suitable for this type of situation when we want this attribute in every model?

Jantlap started a new conversation Extra Informations For Logged User

Hi,

I would like to get more informations on logged user from different table / source. But this is not regular SQL relation.

I have an accessor on User model right now, but that means that Im calling it every single time. And I would like to call it only once.

How would i do that?

Thank you.

03 Jan
1 year ago

Jantlap left a reply on Best Practice (pattern) For A Method On Model

And what about going for something like:

$pages = $pagesRepo->all()->each(function ($item) use($pagesRepo) {
    $item->pageviews = $pagesRepo->getPageviews();
});

Jantlap left a reply on Best Practice (pattern) For A Method On Model

I feel somehow that the model class itself should not contain such things like Auth::user() and any other logic outside of the model, and that it maybe would be better to move this to some method in repository like getAllWithPageviews and work with a collection there.

But i dont know.

The query is something like select count(*) AS count from pagelog where page_id = ? and there is a cache just for performance reasons. But the question is more about the pattern.

Jantlap started a new conversation Best Practice (pattern) For A Method On Model

Hi,

i have a question on what is the best practice pattern with this situation.

I have a Pages repository and Page model. And I need to get pageviews for all pages.

I have a simple Controller like this:

public function index(Pages $pages)
{
    $pages = $pages->all();

    return view('pages.index', [
      'pages' => $pages
    ]);
}

And in the model this method:

public function getPageviewsAttribute(){

        $cachekey = Auth::user()->id.'_pageviews_count_'.$this->id;
        $count = Cache::driver('user')->remember($cachekey, 15, function () {
            return DB::select('...')[0]->count;
        });

        return $count;
    }

This is accessor to appended pageviews property. I can then use $page->pageviews right in the view.

But this is not a good practice, is it? Too much logic in the model, with Cache, Auth and so on.

Where should this be? Not in Controller, right? In repository? How? Somewhere else? What is a good pattern?

Thank you very much.

03 Jul
2 years ago

Jantlap left a reply on Braintree\Configuration::merchantId Needs To Be Set

You need to add this to your config.services file:

'braintree' => [ 'model' => App\User::class, 'env' => env('BRAINTREE_ENV'), 'merchant_id' => env('BRAINTREE_MERCHANT_ID'), 'key' => env('BRAINTREE_KEY'), 'secret' => env('BRAINTREE_SECRET'), ],

27 Jan
2 years ago

Jantlap started a new conversation Cant Use Sqlite Databases - Identifier Name Is Too Long

Hi there,

for testing purposes I would like to use sqlite. But when migrating I get:

SQLSTATE[HY000] [1059] Identifier name '/Users/myusername/Code/laravel-app/database/testing/account.sqlite' is too long (SQL: create table
   `migrations` (`id` int unsigned not null auto_increment primary key, `migration` varchar(255) not null, `batch` int not null) default chara
  cter set utf8mb4 collate utf8mb4_general_ci)

I have tried to Google that but with no luck. Someone willing to help?

Thank you.