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

yu0307

Experience

2,120

0 Best Reply Awards

  • Member Since 6 Months Ago
  • 17 Lessons Completed
  • 0 Favorites

26th June, 2017

yu0307 left a reply on Accessor On Demand But Not On Every Results. • 5 months ago

@jlrdw You really have issue understanding people's question. I'm not here to start dramas, just don't come and pick a fight. Stay outta my posts.

25th June, 2017

yu0307 left a reply on Accessor On Demand But Not On Every Results. • 5 months ago

anyone?

24th June, 2017

yu0307 left a reply on Accessor On Demand But Not On Every Results. • 5 months ago

@Borisu Hi, Thank you for taking the time and clarify this. Here is what happend.

Model::where('something', 'somethingElse')->first()

returns a Model::class therefore it has the append Traits. Your example works perfectly on single result. I appreciate the demonstration.

In addition, Is there a way we can apply the attributes on a collection::class? something like this:

Model::where('something', 'somethingElse')->get()->append('accessor');

Thank you all.

22nd June, 2017

yu0307 left a reply on Accessor On Demand But Not On Every Results. • 5 months ago

@Francismori7 Hi man, SetAppends and Appends are both instance methods. It will not work by calling them statically. I even tried something like this

public function getOptControlAttribute(){ 
        return 'Yay';
    }


public static function WithControlBtn(){
        $ins=new foo();
        $ins->append('OptControl');
        return $ins;
    }
Model::WithControlBtn()->get();

Still no luck, it returns all the fields in the model just not with the accessor.

goodness..... Are we really limited just to filters and global accessor appendings??????

(T_T)

yu0307 left a reply on Accessor On Demand But Not On Every Results. • 5 months ago

@Francismori7, I think. Just I think, there is no Append method in QueryBuilder class. therefore Model::append will not work. and that's probably why I got the "method not found error" when I tried.

What should I do?

yu0307 left a reply on Accessor On Demand But Not On Every Results. • 5 months ago

@Borisu Hi, I think there is an append method, but I was not sure it was in the queryBuilder class. I thought it was in the model class, but i'm gonna give it a try and see. Thank you for your suggestion.

yu0307 left a reply on Accessor On Demand But Not On Every Results. • 5 months ago

@Borisu Hi, thank you for your response. I was saying "NOT ALWAYS" but "ON Demand". but I think your Scope with Accessor will work. I'm gonna give it a try. Thank you~

yu0307 left a reply on Accessor On Demand But Not On Every Results. • 5 months ago

anyone?

21st June, 2017

yu0307 left a reply on Accessor On Demand But Not On Every Results. • 5 months ago

anyone?

yu0307 left a reply on 500 Error On Any Use Of Eloquent • 5 months ago

@tisuchi read his other comments, he got a 500 when he tries the ::

yu0307 started a new conversation Accessor On Demand But Not On Every Results. • 5 months ago

Hi all, I was just wondering if it's even possible in laravel to append an accessor to every row of a result? !!! Not using $appends in the model. That will append that accessor to every results!!!

I'm trying to do something like this:

foo::find(2)->get('id','name',etc')->with('accessor');

as you can see, the accessor is appended to the result on a demand but not always and not to every results.

Thank you ~

19th June, 2017

yu0307 left a reply on Loading Package Assets (css/js) Into The View NOT Using Artisan Publish • 5 months ago

@clay Thank you for taking the time and follow up. I think before I found any better way of doing this, Setting up a symbolic link is the best approach in my own opinion.

18th June, 2017

yu0307 left a reply on Loading Package Assets (css/js) Into The View NOT Using Artisan Publish • 5 months ago

@clay Thank you for your answer, 5.5 seems solve the burden of of manual publish the package assets. But one last question remains, What if the package has an update, or I just made some changes to the package assets, how is that change going to be carried over to the published folder? I still have to do a manual publish every time I make a change.

yu0307 left a reply on Loading Package Assets (css/js) Into The View NOT Using Artisan Publish • 5 months ago

So this is what I did. instead of using the artisan publish every time where there is a change made. I just created a symbolic link to the public/asset/vendor/... It get the jobs done. but still, if you were to publish this package to anyone else, They have to create a symbolic link to use it? I mean the purpose of publish is to let end users customize the behaviors, but what if no customization is needed, how are they going to utilize the package assets?

Any thoughts guys?

Thank you

yu0307 left a reply on Loading Package Assets (css/js) Into The View NOT Using Artisan Publish • 5 months ago

I tried to avoid having to manually do a publish every time I make a change to the package asset files. also I tried to group package assets in their own vendor folder for easier management. I don't know if there is a way to just load the assets directly from the vendor folder.

Thanks

yu0307 started a new conversation Loading Package Assets (css/js) Into The View NOT Using Artisan Publish • 5 months ago

Hi all, Is there a way to have the views load the js/css files that are stored in the package assets folder? Not using the artisan publish method.

Thank you

16th June, 2017

yu0307 left a reply on Package Subscribe To An Event? • 5 months ago

Well, I will just close this thread I guess since I think from every source it suggest to use the public variable to access the target object. To sum up for anyone who might land on this thread. just do

    $event_wrapper->SomeEventsWrapper_instance

yu0307 left a reply on Package Subscribe To An Event? • 5 months ago

Well, for anyone who might be searching the same thing online. there is an initial solution to myself.

Raise the event in the view like

/*In some blade file*/
{!!
    App\Events\SomeEventsWrapper::Create(function($shared_var){
        event(new App\Events\SomeEventBuilder($shared_var);
    })->Render()
!!}

Then in some Package Service provider boot

public function boot(){
    Event::listen('App\Events\SomeEventBuilder', function ($event_wrapper) {
            Some_action_from_Package();
});

I was able to capture the event within a package. but for some reason the $event_wrapper in the closure function is not referencing App\Events\SomeEventsWrapper, but rather App\Events\SomeEventBuilder. Can some one explain this a little bit?

to rephrase the question. in a listening closure, how can you capture that $shared_var?

15th June, 2017

yu0307 started a new conversation Package Subscribe To An Event? • 5 months ago

So here is the crazy thing, first: is it possible to raise an event from a view? 2nd: is it possible to listen to that event from a package not from the general laravel app?

If they are possible, How do you listen to an event from a package for one raised in a view(blade)?

Thank you.

14th June, 2017

yu0307 left a reply on How Can We Share Data Among Controllers "NOT VIEWS" • 5 months ago

Man, Understand what I'm asking, I asked for a way to share data. through methods, facade, helpers , session or whatever, that's for you to tell me. You got me explain my question over and over and now it seems you got your feeling hurt just because you didn't know what to say.

yu0307 left a reply on How Can We Share Data Among Controllers "NOT VIEWS" • 5 months ago

Build a helper function Is what I think the closest solution to my question. it's centralized and can be managed from one location without having to worried about the rest of the project.

Thanks Jobcerto.

yu0307 left a reply on How Can We Share Data Among Controllers "NOT VIEWS" • 5 months ago

Man, Please read my original question. I felt like I'm explaining my question.

yu0307 left a reply on How Can We Share Data Among Controllers "NOT VIEWS" • 5 months ago

But it will save so much more time later on when you build more dynamics to user data. you gonna have to go through all controllers to make the change.

yu0307 left a reply on How Can We Share Data Among Controllers "NOT VIEWS" • 5 months ago

Auth::user() to start out with? I know you can just pull in the facade and use it anywhere. I'm just lazy, I don't want to type that use statement on the top. LOL

yu0307 left a reply on How Can We Share Data Among Controllers "NOT VIEWS" • 5 months ago

Yah, but I would imagine having session data set anywhere in my project and becoming very hard to track down where that data was actually set. like a central place like view composer where I will always know that my Data is set from that class. I guess I'm really looking for a view composer kind of deal that will work in a controller as well.

yu0307 started a new conversation How Can We Share Data Among Controllers "NOT VIEWS" • 5 months ago

We probably all aware that we can share data with view composer, but that data is loaded into the blade file, I can't seem to utilize that data while inside the controller. Furthermore, I seen people tried to use a class with needed data and extend that class. but I don't really want to extend every controller to just use a global data between them.

Is there a better way? once again, Not sharing with views but controllers.

Thank you very much

Edit Your Profile
Update

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