tealiedie

tealiedie

Member Since 3 Years Ago

Experience Points 9,710
Experience Level 2

290 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 70
Lessons
Completed
Best Reply Awards 0
Best Reply
Awards
  • Start Your Engines Achievement

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • First Thousand Achievement

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • One Year Member Achievement

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • Two Year Member Achievement

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • Three Year Member Achievement

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • Four Year Member Achievement

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • Five Year Member Achievement

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • School In Session Achievement

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • Welcome To The Community Achievement

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • Full Time Learner Achievement

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • Pay It Forward Achievement

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • Subscriber Achievement

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • Lifer Achievement

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • Laracasts Evangelist Achievement

    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 Achievement

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • Laracasts Veteran Achievement

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • Ten Thousand Strong Achievement

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • Laracasts Master Achievement

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • Laracasts Tutor Achievement

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • Laracasts Sensei Achievement

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • Top 50 Achievement

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

07 Nov
7 months ago
25 Apr
1 year ago

tealiedie left a reply on Hadoop Big Data

i accidentally clicked it. dunno how to undo it.

07 Nov
1 year ago

tealiedie started a new conversation Laravel Passport: Get The Authenticated User Via Api In Web Routes.

Hi,

I have successfully authenticated users in my front-end via passport api.

but now i want to implement the Laravel socialite to connect/link their account to my app. so i want to get the authenticated user in routes/web.php because i put my redirects and callbacks in there.

is there a way to get the authenticated user in web routes? or is there a way i can use laravel/socialite package so i don't have to stress meself doing it?

thank you

09 Oct
1 year ago

tealiedie left a reply on Namespaces Convertion

@ejdelmonico so there's no way i can use the models without having to include the ModelsFolder in namespace? do i need to change the namespace according to the folder structure?

thanks

tealiedie started a new conversation Namespaces Convertion

Hi, i am not sure if this is possible in PHP namespaces. please help me

// folder structure
app
  -- ModelsFolder // the models folder
    -- ComponentsFolder // some traits
      -- Traits::class

    -- User::class
    -- OtherModel::class

the Classes are only using the app folder as namespace

// User class
<?php
namespace App;

in my controllers i use the class as..

<?php

namespace App\Http\Controllers;

use App\User; // import class
use App\OtherModel; 

i wonder if this setup is possible, because it's giving me FatalError saying the Class 'App\User' not found.

08 Jun
2 years ago

tealiedie started a new conversation Eloquent Bug/weird Behaviour

Guys i've got a question. is this the default laravel behaviour to revert back to original keyType and setkeyname of the model after the first successful setting??

look at my relation code . oh and btw. i extended the laravel's default belongsToMany to change the related model's primaryKey. (notice the uid).

    public function conditions()
    {
        $this->setIncrementing(false);
        $this->setKeyType('string');
        $this->setKeyName('uid');

        $rel = $this->belongsToMany(\App\Models\MedCondition::class, 'condition_symptom', 'symptom_id', 'condition_id', null, 'uid')
                    ->withPivot('tags')
                    ->withTimestamps();
        // $this->setIncrementing(true);
        // $this->setKeyName('id');
        return $rel;
    }

so when i tried to use it.

$symp = MedSymptom::whereUid('1qMepFlgaV');
dd ($symp->get()->load('conditions')->get(1));
// of course, the expected result is correct and it loaded the `MedCondition`.

but when i tried to do it like this

$symp = MedSymptom::with('conditions')->whereUid('1qMepFlgaV'); // no results either.
// or in the model directly
protected $with = [
  'conditions',
]; // no results at all
// or 
$symp = MedSymptom::whereUid('1qMepFlgaV'); // has two results.
return $symp->get()->load('conditions'); // result is unexpected. (see screenshot)

blob

tealiedie left a reply on Changing Model's Primary Key When Defining A Relation

thanks for your answer but i extended the belongsToMany function to modify the related model's primary key like this.

    public function belongsToMany($related, $table = null, $foreignKey = null, $otherKey = null, $relation = null, $relatedKey = 'id') {

    if ($relatedKey != 'id') {
            $instance->setKeyName($relatedKey);
            $instance->setIncrementing(false);
        }

}
 
07 Jun
2 years ago

tealiedie left a reply on Changing Model's Primary Key When Defining A Relation

@Snapey i need to use uid to temporarily use it to get the relations.

btw, i think i managed to changed it somehow. but the UID is a string so whenever i try to get the relation. it changes the type of uid to integer

public function conditions()
    {
        $this->setIncrementing(false)
            ->setKeyName('uid');

        return $this->belongsToMany(\App\Models\MedCondition::class, 'condition_symptom', 'condition_id', 'symptom_id');
        
        $this->setIncrementing(true)
            ->setKeyName('id');

    }

tealiedie left a reply on Changing Model's Primary Key When Defining A Relation

im not sure i get youre trying to point out. @Snapey

tealiedie started a new conversation Changing Model's Primary Key When Defining A Relation

guys in laravel relation, how can i change Model primary key on the fly? like


/** table structures
* model1
* -- id (primary_key)
* -- uid (i just used this as an identifier to another model)
* model2
* -- id (primary_key)
*  -- uid (i just used this as an identifier to another model)
* model1_model2
* -- id
* -- model1_id (uid of model1)
* -- model2_id (uid of model2)
**/
// Model1.php
public function relation()
{
  return $this->belongsToMany(Model2::class, 'model1_model2', 'mode1_id', 'mode2_id');
}

the question is. how can i change the Model1 primary key when calling the Model1::relation() ??..

31 May
2 years ago

tealiedie left a reply on [Socialite] Login/Register With Facebook

I was wondering, if a user presses the button that leads to the first route, if he doesn't have a record in the DB, my app will register him, right? And then if he has a record in the DB and presses the button, my app will just log him in, right?

-- yes

and yes. theyre the same button. the purpose of the route with /callback is for you to register them in either social provider.

17 May
2 years ago

tealiedie left a reply on Select Attributes To Return From Many-to-many Relation Fields

try this


public function getNonEmptyStates()
{
    return $this->with('games')
                ->where('id', 'like', '%_2017_2_3%')->withCunt('games')
                ->select('id', 'your fields that you want to select', 'fields')

}

tealiedie left a reply on How To Create Permission After Model Was Created ?

check https://github.com/Zizaco/entrust. it's a Role-based Permissions for Laravel 5

15 May
2 years ago

tealiedie left a reply on Mix Not Compiling JS File

try running gulp only first. then run npm run dev to run gulp watch. i don't know either if it is a bug.

tealiedie left a reply on Capturing Form

does your meta table has a Eloquent model? if so you can use

Meta::find(1)->update($request->except('_token'));
// or $request->all() 

tealiedie left a reply on How To Get Resource Data In Form Request

what do you mean by resource data? if it is the data passed from the client side. try $request->all(),

tealiedie started a new conversation Merging Millions Of Data Using Nodejs

i need help/tips

i have a huge amount of json data that needs to be merged, sorted and filtered. right now, they're separated into different folders. almost 2GB of json files.

what i'm doing right now is:

reading all files inside each folders appending JSON parsed data to an Array variable inside my script. sorting the Array variable filtering. save it to one file i'm rethinking that instead of appending parsed data to a variable, maybe i should store it inside a file ?.. what do you guys think ? what approach is better when dealing with this kind of situation ?

By the way, i'm experiencing a Javascript Heap out of memory

05 May
2 years ago

tealiedie started a new conversation How To Change Primary Key Of Related Model In BelongsToMany Relationship ?

guys. how can i set related model primary key in my belongsToMany relationship ?..

public function directories()
        return $this->belongsToMany(\App\Models\Provider::class, 'directories', 'user_id', 'provider_id');
    }

10 Apr
2 years ago

tealiedie left a reply on Sending Http Request To Servers Anonymously

i see. so perhaps i should make an interval between those http request.?.. hmm

tealiedie started a new conversation Sending Http Request To Servers Anonymously

I'm just wondering if we could send HTTP request to API / Web Server anonymously? right now after some googling. i cannot find any answer if it is possible.

i'm writing a code that will scrape the data from its server but i think they might have an API monitoring feature for their Data.

right now i am using node with Axios and the script i am using is fetching almost ~10k requests per minute, which i think is because their server could blew up.

i tried googling but i didn't find any answer to my problem.

31 Mar
2 years ago

tealiedie left a reply on Call To A Member Function Create() On Null [Cashier 7.0]

@theUnforgiven have you solved the issue? im having this issue as well

30 Mar
2 years ago

tealiedie left a reply on Cashier And Stripe: No Such Token Error Constantly!

@guycas same here. ping me if you have managed to solve this. thanks!

01 Mar
2 years ago

tealiedie left a reply on Laravel Controllers. Tips On Using Response()

@tykus i see, thanks!, i checked the response in network tab. yes youre right.

@SaeedPrez yep i get your point. because laravel automatically converts the response to json when youre return an array.

tealiedie started a new conversation Laravel Controllers. Tips On Using Response()

HI,

so i am building an API. and i just noticed that some of the coders uses return response()->json(['data' => 'some data]), others are using just return ['data' => 'some data'], i wonder what are the benefits using the response()

tealiedie left a reply on Insert Data Into DB After Through The Validator

have you tried to check if the validations rules are correct? maybe the $ttdlvalidator->fails() always return false.

23 Feb
2 years ago

tealiedie left a reply on Elixir Error When Running Webpack

updating the node worked for me.

08 Feb
2 years ago

tealiedie left a reply on Vue Component Is Not Emitting Parent's Method.

Hi @KamalKhan, yes it's strange. i think the docs is misleading. i've checked the _events hook of the parent. it shows the event being emitted but in a lowercase form. like this showmodaldoctor. now it triggers the doctorModal method from the parent

tealiedie left a reply on Vue Component Is Not Emitting Parent's Method.

@KamalKhan yes it does. it logs ('doctor from component')

tealiedie left a reply on Vue Component Is Not Emitting Parent's Method.

ah, my bad. ive updated my code but it still not triggering the showModalDoctor event

// from my component
triggerModalDoctor: function(doctor) {
            this.$emit('showModalDoctor', doctor);
            console.log('trigger from component');
        },

in my html

                                <specialists v-on:showModalDoctor="doctorModal" v-bind:name="specialistName"></specialists>

tealiedie started a new conversation Vue Component Is Not Emitting Parent's Method.

Hi, i followed the sample from the docs. but it doesnt seem to work for me. https://vuejs.org/v2/guide/components.html#Custom-Events

heres my component


Vue.component('specialists', {
    template: `
        <div class="list-group-item" v-for="doctor in doctors">
            <a href="#" @click="triggerModalDoctor(doctor)">
                {{ doctor.full_name }}
            </a>
        </div>
    `,
    methods: {
    triggerModalDoctor: function(doctor) {
            this.$emit('showModalDoctor', doctor);
            console.log('doctor from component');
        },
    }
    
});

var triageApp = new Vue({
    el: '#triage',
    methods: {
                doctorModal: function(doctor) {
                $('#doctor').modal('show');
                console.log('doctor from emitted event', doctor);
            },
    }
});

and from my html.

    <div class="list-group"  v-for="specialistName in suggestion.tests.specialists">
            <specialists v-on:showDoctorModal="doctorModal" v-bind:name="specialistName">
        </specialists>
     </div>

as far as i can see. it should trigger the doctorModal from my main Vue.

tealiedie left a reply on Hadoop Big Data

not yet.

07 Feb
2 years ago

tealiedie left a reply on ***Vue Component***: How To Pass Data From Parent To Child

HI @EventFellows thank you, i did what you said to pass the data via props.

However. i am not satisfied the way i did my components. because the doctors component can be <li> list.

can you recommend how can i make it more dynamic?..

as of now. i have <specialists v-bind:name="specialistName"></specialists> in my blade template. i know this is wrong.

tealiedie started a new conversation ***Vue Component***: How To Pass Data From Parent To Child

Hi. how can i access the doctor attribute from my doctor component ?

Vue.component('specialists', {
    template: `
    <div>
        <div class="list-group-item title">
            &raquo; {{ name }}
        </div>
        <doctor class="list-group-item" v-for="doctor in doctors">
            <a href="#" class="list-group-item-heading">
                {{ doctor.full_name }}
            </a>
        </doctor>
    </div>
    `,

    props: {
        name: {
            default: '',
        },
    },

    data: function() {
        return {
            algoliaClient: null,
            algoliaIndex: null,
            doctors: [],
        };
    },

    created: function() {
        this.algoliaClient = this.$parent.algoliaClient;
        this.algoliaIndex = this.algoliaClient.initIndex('medical_doctors');
    },

    mounted: function() {
        this.getDoctors();
    },

    methods: {
        getDoctors: function() {
            this.search(this.name);
        },

        search: function(input) {
            var _this = this;
            this.algoliaIndex.search(this.name, function(err, hits) {
                _this.setDoctors(hits.hits);
            });
        },

        setDoctors: function(data) {
            this.doctors = data;
        },
    },
});

// my doctor component
Vue.component('doctor', {
    template: `
        <div><slot></slot></div>
    `,

    data: function() {
        return {
            doctor: null, // here. how can i pass value to it? 
        };
    },
});

26 Jan
2 years ago

tealiedie left a reply on How Can I Make Model Relation Using Array Of Id As Local Key ?

is there any other method to define this kind of relationship ?

tealiedie started a new conversation How Can I Make Model Relation Using Array Of Id As Local Key ?

How can i make model relation using array of id as local key ?

for example:


$model1->model2_ids = "[1,2,3,4,5]"; // casted into an array.


// in my model1 relation
public function model2()
{
    return $this->hasMany(Model2::class, ??, ??); // how ?
}

i tried to make relation like this.

public function model2()
{
    return Model2::whereIn('id', $this->model2_ids); 
}

yes it's working. but i want to make it eloquent relation.. =)

09 Dec
2 years ago

tealiedie left a reply on How To Define Eloquent's MorphTo When Selector Is Not An 'id'

found it. morphTo will not work for this. i think it should be morphToMany or morphByMany ?..

tealiedie left a reply on How To Define Eloquent's MorphTo When Selector Is Not An 'id'

hmm i think it should be

Track::first()->trackable,

because Inventory doesnt have trackable method

tealiedie left a reply on How To Define Eloquent's MorphTo When Selector Is Not An 'id'

@tomi thanks, so i tried this.

// in my Inventory.php model
  public function tracks()
  {
      return $this->morphMany(Track::class, 'trackable', 'trackable_type', 'trackable_id', 'branch_id');
  }

but still Track::first()->trackable returns null

tealiedie started a new conversation How To Define Eloquent's MorphTo When Selector Is Not An 'id'

Hi, how can i setup my polymorphic relations where the id is not an id of a foreign table?

heres my table setup..

// tracks table
_____________________________
|                            |
| id | trackable_id | trackable_type |
|____________________________ |
|  1  | 123123           | App\Inventory |
|  2 | 123123           | App\Inventory |
|____________________________|
// where trackable_id value is batch_id of inventories

// inventories table
____________
| id | batch_id |
|___________ |
|  1  | 123123     |
|  2 | 123123     |
|___________|

// Track.php Model

public function trackable()
{
    return $this->morphTo();
}


// in my Inventory.php Model
public function tracks()
{
    return $this->morphMany(Track::class, 'trackable');
}
28 Nov
2 years ago

tealiedie left a reply on Eloquent OrderBy

based on the results. it seems like it orders the channels based on the first reply on that channel not on the latest one. for example

// channel-1 replies
[
    0 => [
        "id" => 1,
        "message" => "first message",
            "created_at" => "2016-11-28 00:00:00",
    ],
    1 => [
        "id" => 2,
        "message" => "second message",
            "created_at" => "2016-11-28 01:30:00",
    ],
]
// channel-2 replies
[
    0 => [
        "id" => 1,
        "message" => "first message",
            "created_at" => "2016-11-28 00:01:00",
    ],
    1 => [
        "id" => 2,
        "message" => "second message",
            "created_at" => "2016-11-28 01:29:00",
    ],
]

based on the data i provided. the eloquent relation would give me list

  • channel-2
  • channel-1

tealiedie left a reply on Eloquent OrderBy

@pmall i'm not using any DB facade. but i used join in my eloquent relationship. however it doesn't seem to return what iv'e expected.

here's my code for relationship

// channels relationship in User's Model
return $this->belongsToMany('App\Channel')
                    ->withPivot('is_approved')
                    ->leftJoin('replies', 'replies.channel_id', '=', 'channels.id')
                    ->orderBy('replies.created_at', 'DESC')
                    ->groupBy('channels.id');
// query log
select `channels`.*, `channel_user`.`user_id` as `pivot_user_id`, `channel_user`.`channel_id` as `pivot_channel_id`, `channel_user`.`is_approved` as `pivot_is_approved` 
from `channels` 
inner join `channel_user` on `channels`.`id` = `channel_user`.`channel_id` 
left join `replies` on `replies`.`channel_id` = `channels`.`id` 
where `channel_user`.`user_id` = 8 
group by `channels`.`id` order by `replies`.`created_at` desc

tealiedie left a reply on Eloquent OrderBy

perhaps, should i use Fluent than eloquent here?

tealiedie started a new conversation Eloquent Orderby

asdasdasd

tealiedie started a new conversation Eloquent OrderBy

Hi,

i have 3 models • User • Channel • Reply

`us have `belongsToMany('App\Channel'?? `cha have ve `hasMany('App\Reply', 'channel_id', 'id')->oldes

let's say i have 2 channels • channel-1 • channel-2 -2 `chann has latest replies than an `chann

now, i want to order the user's channel by its channel's current reply. just like some chat application. how can i order the user's channel just like this?

• channel-2 • channel-1

i already tried some codes. but nothing happen

// User Model
public function channels()
    {
        return $this->belongsToMany('App\Channel', 'channel_user')
                    ->withPivot('is_approved')
                    ->with(['replies'])
                    ->orderBy('replies.created_at'); // error
    
    }
// also
public function channels()
    {
        return $this->belongsToMany('App\Channel', 'channel_user')
                    ->withPivot('is_approved')
                    ->with(['replies' => function($qry) {
                        $qry->latest();
                    }]);
    }
// but i did not get the expected result

22 Nov
2 years ago

tealiedie left a reply on How To Trigger A Pusher Event Using Laravel 5.3's Notification?

@jekinney Hi, thank you, i am now checking the laravel-echo. but i've got a question. how can i do this without having to put it on resources/assets/js/bootstrap.js, iv'e got an error says unexpected token import from my browser's console

import Echo from "laravel-echo"

window.Echo = new Echo({
    broadcaster: 'pusher',
    key: 'your-pusher-key'
});

tealiedie left a reply on How To Trigger A Pusher Event Using Laravel 5.3's Notification?

@tisuchi thanks, but that's not that i was looking for.

tealiedie left a reply on How To Trigger A Pusher Event Using Laravel 5.3's Notification?

iv'e been looking into laravel notification package inside my vendor folder, and there, i see ChannelManager that fires an event. i was wondering if i could just edit that or if i could override the sendNow method to trigger my custom pusher event. thanks