Buy your loved one the ultimate gift. Lifetime gift certificates are $100 off.

tealiedie

Experience

8,900

0 Best Reply Awards

  • Member Since 1 Year Ago
  • 62 Lessons Completed
  • 1 Favorite

7th November, 2017

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

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

9th October, 2017

tealiedie left a reply on Namespaces Convertion • 2 months ago

@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 • 2 months ago

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.

8th June, 2017

tealiedie started a new conversation Eloquent Bug/weird Behaviour • 6 months ago

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 • 6 months ago

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);
        }

}
 

7th June, 2017

tealiedie left a reply on Changing Model's Primary Key When Defining A Relation • 6 months ago

@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 • 6 months ago

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 • 6 months ago

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() ??..

31st May, 2017

tealiedie left a reply on [Socialite] Login/Register With Facebook • 6 months ago

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.

17th May, 2017

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

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 ? • 6 months ago

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

15th May, 2017

tealiedie left a reply on Mix Not Compiling JS File • 6 months ago

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 • 6 months ago

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 • 6 months ago

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 • 6 months ago

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

5th May, 2017

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

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');
    }

10th April, 2017

tealiedie left a reply on Sending Http Request To Servers Anonymously • 8 months ago

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 • 8 months ago

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.

31st March, 2017

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

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

30th March, 2017

tealiedie left a reply on Cashier And Stripe: No Such Token Error Constantly! • 8 months ago

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

1st March, 2017

tealiedie left a reply on Laravel Controllers. Tips On Using Response() • 9 months ago

@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() • 9 months ago

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 • 9 months ago

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

23rd February, 2017

tealiedie left a reply on Elixir Error When Running Webpack • 9 months ago

updating the node worked for me.

8th February, 2017

tealiedie left a reply on Vue Component Is Not Emitting Parent's Method. • 10 months ago

yes it worked.

tealiedie left a reply on Vue Component Is Not Emitting Parent's Method. • 10 months ago

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. • 10 months ago

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

tealiedie left a reply on Vue Component Is Not Emitting Parent's Method. • 10 months ago

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. • 10 months ago

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 • 10 months ago

not yet.

7th February, 2017

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

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 • 10 months ago

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? 
        };
    },
});

26th January, 2017

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

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 ? • 10 months ago

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.. =)

9th December, 2016

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

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' • 1 year ago

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' • 1 year ago

@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' • 1 year ago

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');
}

28th November, 2016

tealiedie left a reply on Eloquent OrderBy • 1 year ago

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 • 1 year ago

@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 • 1 year ago

perhaps, should i use Fluent than eloquent here?

tealiedie started a new conversation Eloquent Orderby • 1 year ago

asdasdasd

tealiedie started a new conversation Eloquent OrderBy • 1 year ago

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

22nd November, 2016

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

iv'e put it inside my app.js

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

@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? • 1 year ago

@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? • 1 year ago

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

tealiedie started a new conversation How To Trigger A Pusher Event Using Laravel 5.3's Notification? • 1 year ago

Hi, iv'e been wondering where should i my code to trigger pusher events on client side using laravel notication?

11th November, 2016

tealiedie left a reply on Serialization Of Illuminate\Http\UploadFile Is Not Allowed • 1 year ago

@martinbean yes, thank you , iv'e figured it out. i just need to remove the job from the queue service.

9th November, 2016

tealiedie left a reply on Serialization Of Illuminate\Http\UploadFile Is Not Allowed • 1 year ago

@martinbean hi, ive got the same problem. iv'e got mind when i passed it to Job

Edit Your Profile
Update

Want to change your profile photo? We pull from gravatar.com.