mindz

mindz

Member Since 2 Years Ago

Experience Points 11,770
Experience Level 3

3,230 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 91
Lessons
Completed
Best Reply Awards 4
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.

17 Nov
1 year ago

mindz left a reply on GetAttribute In Laravel 5.5

For anyone who one day will be looking for an answer.Method getAttribute() is fired only when you call property like $model->property. If you returning collection which later is converted to array method that is used to do this is toArray() so to my Trait i had to add this method

public function toArray()
{
    $array = parent::toArray();

    foreach ($array as $key => $attribute) {
        if (in_array($key, $this->specialPropertyArray)) {
            $array[$key] = someFunction($attribute);
        }
    }
    return $array;
}
16 Nov
1 year ago

mindz left a reply on GetAttribute In Laravel 5.5

I have tried this on so many ways

  • ->relation()-first()
  • ->relation
  • ->find
  • ->where()->get()->first()

and sooo on.... and there is something wrong with it

this function works like a charm in all above ways

 public function getFieldAttribute($value)
{
        return someFunction($value);
}
    

this never works

public function getAttribute($key)
{
        $value = parent::getAttribute($key);

        return someFunction($value);
}
  

Does someone encounter this problem before?

mindz started a new conversation GetAttribute In Laravel 5.5

Is something has been changed?

in trait i created for eloquent model i can't use getAttribute($key) - it is completly skipped . However setAttibute($key, $value) works like charm

trait SomeTrait
{
    public function getAttribute($key)
    {
            return "it just not working";
    }

    public function setAttribute($key, $value)
    {
        if (in_array($key, $this->specialPropertyArray)) {
          
            return parent::setAttribute($key, someFunctionOn($value));
        }

        return parent::setAttribute($key, $value);
    }


}

In addition i have to say i have no custom accessors for my models

10 Nov
1 year ago

mindz left a reply on Get User In Singleton Class

OK. I resolved issue

 public function methodOne($someMethod, array $parameters = [])
    {

    $parameters['headers'] ['X-Authorization'] = $auth->guard()->getUser()->getToken();

    }

Unfortunatley i don't know why it exceeds memory when i call GuardHelpers trait method. When i call directly Guard class it appear to be working

mindz started a new conversation Get User In Singleton Class

Hi there. I have this issue: in my custom service provider i register an singleton

public function register()
    {
        $this->app->singleton('some-name', function ($app) {
            return new DefaultApi(env("ENV_1"), env("ENV_2"), new Client(), $app['auth']);
        });

    }

then in this class i construct singleton and it is failing on $auth->guard()->user()->getToken()

class DefaultApi implements DoesNotMatherWhat
{
    private $path;
    private $client;
    private $options;
    private $auth;

    function __construct($path, $token = null, Client $client, $auth)
    {
        $this->path = $path;
        $this->client = $client;
        $this->options = [
            'headers' => [
                'Accept' => 'application/json',
                'X-Authorization' => $auth->guard()->user()->getToken(), //here its failing with memory limit
            ]
        ];

        $this->auth = $auth;
    }

I can't pass user token to options. As for singleton it might be understandable but why i cant add it it to methodOne?

    public function methodOne($someMethod, array $parameters = [])
    {

    $parameters['headers'][ 'X-Authorization'] = $auth->guard()->user()->getToken();

    }

Error i get is Allowed memory size of 268435456 bytes exhausted

Thanks in advance

27 Sep
1 year ago

mindz left a reply on Notifications Not Saved To Database

provide notifications table migration please

mindz left a reply on Change Default Path For Storage Folder

So in bootstrap/app.php you should do this

$app->useStoragePath( env( 'APP_STORAGE', base_path() . '/storage' ) );

mindz left a reply on How To Log Single Queries?

DB::enableQueryLog();

$user = DB::table("users")->get();

$query = DB::getQueryLog();

$query = end($query);

dd($query);

mindz left a reply on Carbon Problem

It cant work.

You providing object where it should be matchable string

$posts = Post::orderBy('id')
->whereDate('created_at', '>', Carbon\Carbon::now()->subMinutes(5)->toDateString()))->get();

mindz left a reply on Change Default Path For Storage Folder

Or even simpler

 public function add(Request $request)
    {
        $file = $request->file('file');
        $path = $file->store('files/specific_files');           

mindz left a reply on Session Flash On L5.4

I cant recall any situation of automatic comment line of files ;) Regards

mindz left a reply on Button Component Rendering Incorrectly Inside Email

Maybe you can try with slots

I dig up something like this

@component('mail::layout')
    {{-- Header --}}
    @slot('header')
        @component('mail::header', ['url' => config('app.url')])
            Header Title
        @endcomponent
    @endslot
{{-- Body --}}
    This is our main message {{ $user }}
{{-- Subcopy --}}
    @isset($subcopy)
        @slot('subcopy')
            @component('mail::subcopy')
                {{ $subcopy }}
            @endcomponent
        @endslot
    @endisset
{{-- Footer --}}
    @slot('footer')
        @component('mail::footer')
            © {{ date('Y') }} {{ config('app.name') }}. Super FOOTER!
        @endcomponent
    @endslot
@endcomponent

mindz left a reply on Session Flash On L5.4

I pasted above to first nearby project with L5.4 and it worked.

string(7) "working"

did you clean cache or somethink? What is your SESSION_DRIVER?

mindz left a reply on Getting Time Values

If you want to get specyfic example you can even do 17 minutes interval if you want

$baseDate = Carbon::now();
$endDate = Carbon::now()->addDays(2); // two days from now

while($baseDate->lt($endDate)){
    echo $baseDate->format('H:i');
    $baseDate->addMinutes(17);
} 

You can do something similar in blade if you want

13 Sep
1 year ago

mindz left a reply on Swift_TransportException With Mailtrap

What smtp you using?

mindz left a reply on Store Date From Datepicker Into Db

Dont know what plugin you use but there is a possibility to customize format

var date = $('#datepicker').datepicker({ dateFormat: 'dd-mm-yy' }).val();

mindz left a reply on Pass A Variable Into A Data Array To Send Email

@almost_pitt

$posts = Post::all()->get(); // get() can be used on Builder object

either use

$posts = Post::all(); //returns collection

or

$posts = Post::get(); //returns collections

mindz left a reply on How To Show Old Value In Edit Blade.

After submit? Or Before? Or you not submitting at all? Can't see any textfield ( i assumed you ment textfield not textfiled) in not formatted text you provided

mindz left a reply on Swift_TransportException With Mailtrap

What OS you're using? You are aware you should have smpt server set up? Have you got it?

mindz left a reply on How To Show Old Value In Edit Blade.

You have to write again what you want to acomplish. What is Old Value Old Value of what?

mindz left a reply on Swift_TransportException With Mailtrap

provide mail.php config file from config/mail.php

mindz left a reply on When Posting Article, User_id Is 0.

At first sight and obviously in my opinion you not providing user_id when you call

Article::create($request->all());

Of course my conclusion is false if you pass hidden field named user_id in your form but that is not standard approach.

You can do this in some ways.

First and simplest

 Article::create(array_merge($request->all(),['user_id'=>Auth::user()->id]));

Second

$article = Article::create($request->all());
$article->user()->associate(Auth::user())

Third via Observer

<?php

namespace App\Observers;

use App\User;

class ArticleObserver
{

    public function created(Article $article) //or saved
    {
        $article->user()->associate(Auth::user());
    }


}

mindz left a reply on Swift_TransportException With Mailtrap

And you are sure that all config strings in .env are correct and not cached??

mindz left a reply on Swift_TransportException With Mailtrap

Maybe you have issue with internet connection when not on vpn?

mindz left a reply on How To Show Old Value In Edit Blade.

<input type="text" value="{{old('fieldName')}}" name="fieldName" />

mindz left a reply on Pusher Auth_key Error.

@skoobi

I think you pass double encapsulated configs togetConfig function

In config/pusher.php you have main key in main keyed element.

So maybe instead of passing array of elements you passing array with array ?

I am no specialist of pusher but maybe this is the case.

Besides exception you provided shows that you passing keyelement instead of auth_key in your config. Do you pick correct config?

mindz left a reply on Store Date From Datepicker Into Db

@Cosmin89

$formatOfDateYouWant = Carbon::parse($request->get('datepicker')
->eq(Carbon::today()))->format('yy-mm-dd')
12 Sep
1 year ago

mindz left a reply on Mail Queue - How To Handle Stacking Multiple Notifications / Messages Into 1 Email.

I think i understand what You want to achieve. Therefore I would work it out in different way.

I would persist those emails data to storage with date field shouldBeSendAt . If user sends another message in application you update this storage row where email = email you want. You update field shouldBeSendAt = now()->addMinutes(3). Then you create a command executed every 1-3 minutes that check if there is anything with shouldBeSendAt in past. If there is it sending it.

With queue that you wanted to use there is a problem regarding fact that queue uses its own driver. It is definitley more complex to do it your way. In some ways impossile.

mindz left a reply on Store Date From Datepicker Into Db

You must be more precise

If you want to check if datepickers date is current (i assume today)

Carbon::parse($request->get('datepicker')->eq(Carbon::today()))

mindz left a reply on Generate Dummy Data With Faker While Still Maintaining Consistent Data And Relationships

If that would be the case. I would do it like that.

If you said that organization is related to purchase

$factory->define(App\Assessment::class, function (Faker $faker) {

$organizationByRandom = Organization::all()->random(); //or whatever
$relatedPurchase = organizationByRandom->purchase;

    return [
        'name' => $faker->name(),
        'email' => $faker->email(),
        'organization_id' => $organizationByRandom->id
        'purchase_id' => $relatedPurchase->id
    ];
});

But remember that random is ineffective if you want to create milions of fake records. Better use randomElement on organizations ids array (pluck method)

Ps. That is weird that foreign keys to related tables are both in different table. Maybe you should reconsider your relations or you dont need to put both foreigh keys in assessment table.

17 Jun
2 years ago

mindz left a reply on Get Model Structure As Json

Data structure is not keept in model. You have to phisically connect to database to retrive attribtutes.

In my opinion good aproach is to use some House class property (maybe) fillable or one created by yourself depending on your needs and some getter. Pack it in nice trait and use as you like.