yu0307

Experience

2,310

0 Best Reply Awards

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

2nd January, 2018

yu0307 left a reply on [Package Development] Why Is Post Route In A Package Thrown An Exception Without A Message? • 3 months ago

Oh Well, I reinstalled another instance and moved everything over and it worked. I don't know what went wrong. sometimes maybe a fresh install was just what you needed. So I'm gonna close this one.

yu0307 left a reply on [Package Development] Why Is Post Route In A Package Thrown An Exception Without A Message? • 3 months ago

@GertjanRoke Hi I have narrowed it down to where the issue might be. Now all POST route will throw a

Symfony \ Component \ HttpKernel \ Exception \ MethodNotAllowedHttpException

And it seems RouteCollection.php -> matchAgainstRoutes() is causing a NULL return. That's why the system cannot bind a route.

yu0307 left a reply on [Package Development] Why Is Post Route In A Package Thrown An Exception Without A Message? • 3 months ago

@GertjanRoke Hi, I checked the Tab, there are responses with 200 which is success, but the response shows an httphandler exception from the laravel side.

yu0307 left a reply on [Package Development] Why Is Post Route In A Package Thrown An Exception Without A Message? • 3 months ago

@GertjanRoke Sorry for missing that part out, Here it is

request=$.ajax({
                 dataType : "Json",
                 type : "post",
                 url : '/login',
                 data : {
                     email:$('#email').val(),
                     password:$('#password').val(),
                     remember:$('#remember').prop('checked')
                     },
                 timeout:25000,
                 success: function(response) 
                 {  
                    if( response.status==='success' ){
                        setTimeout( function(){window.location = response.redirect;},1000 );
                    } 
                    noty({ text:response.message,type:response.status});
                    return false;
                 }
              });

yu0307 left a reply on [Package Development] Why Is Post Route In A Package Thrown An Exception Without A Message? • 3 months ago

I think I found out that all POST routes are having issue. not just one.

yu0307 left a reply on [Package Development] Why Is Post Route In A Package Thrown An Exception Without A Message? • 3 months ago

@GertjanRoke I didn't put the CSRF into the form html, I had the login process done in an Ajax request. So I had the html header initialized with CSRF like this

HTML Header:
<meta name="csrf-token" content="{{ csrf_token() }}">

JS File:
$(document).ready(function(e) {
$.ajaxSetup({
        headers: {
            'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
        }
    });
}


yu0307 left a reply on [Package Development] Why Is Post Route In A Package Thrown An Exception Without A Message? • 3 months ago

I figure putting the PostLogin function may help a little

public function postLogin(Request $request)
    {
        $credentials  = array('email' => $request->email, 'password' => $request->password);
        die('here');
        if (Auth::attempt($credentials, (($request->has('remember'))?$request->remember:false))){
            //var_dump(Auth::user());
            User::where('email',$request->email)->update(['Last_Login'=>date('Y-m-d H:i:s')]);
            return ['status'=>'success', 'message'=>'Successfully Logged in', 'redirect'=>$this->redirectTo];
        }else{
             return ['status'=>'error', 'message'=>'Login Failed<br/>Please check your credential and try again.'];
        }
    }

yu0307 left a reply on [Package Development] Why Is Post Route In A Package Thrown An Exception Without A Message? • 3 months ago

@GertjanRoke Hi, thank you for following up and helping out. I did attached a SCRF token to the header as well. But I manage to solve the undefined variable $error by putting

Route::middleware('web')->namespace($this->namespace)->group(__DIR__.'/routes/routes.php');

at package's boot function. This will attach the web middle ware by default to all the routes in the package. so that I can remove the route group for Web. and the new Package Route file looks like this

Route::group(['middleware' => 'auth'], function () {
    Route::get('/','controller\[email protected]');
}
Route::get('/login', 'controller\Auth\[email protected]')->name('login');
Route::post('/login', 'controller\Auth\[email protected]')->name('PostLogin');

But somehow the POST /login still shows Exception with no message.

yu0307 left a reply on [Package Development] Why Is Post Route In A Package Thrown An Exception Without A Message? • 3 months ago

@Snapey I checked the list and routes have only once for web and guest to it. I'm just not sure why a POST route would show an exception with no message.

yu0307 left a reply on [Package Development] Why Is Post Route In A Package Thrown An Exception Without A Message? • 3 months ago

@Snapey

You need it on both for things like csrf I didn't quite follow, What do you mean?

yu0307 left a reply on [Package Development] Why Is Post Route In A Package Thrown An Exception Without A Message? • 3 months ago

All these were in the Package Route file, not the routes/web.php. that's why I had to enclose all routes with the route group. Or are you saying even in the package routes I no longer need to put in the route groups anymore?

yu0307 left a reply on [Package Development] Why Is Post Route In A Package Thrown An Exception Without A Message? • 3 months ago

@Snapey

Yes, I'm sorry, If I remove the Route Group to be like the following:

Route::get('/login', 'Vendor\controller\[email protected]')->name('login');

it will give me the following errors

Undefined variable: errors
(View: /Packages/Vendor/Theme/src/resources/views/FrameWork/Auth/login.blade.php)

yu0307 left a reply on [Package Development] Why Is Post Route In A Package Thrown An Exception Without A Message? • 3 months ago

@Snapey The route::list returns:

 | GET|HEAD | login  | login | Vendor\controller\[email protected] | web,guest  |
| POST | login  |  PostLogin   | Vendor\controller\[email protected] | guest    |

Is it safe to say, its not persisting because it did not use the web middleware for route PostLogin?

yu0307 left a reply on [Package Development] Why Is Post Route In A Package Thrown An Exception Without A Message? • 3 months ago

@Snapey But when I remove the Route Group, all the routes will be prompting to me with undefined variable $Error in the blade file.

yu0307 left a reply on [Package Development] Why Is Post Route In A Package Thrown An Exception Without A Message? • 3 months ago

my route:list gives me this error T_T

Class Auth\ForgotPasswordController does not exist

yu0307 started a new conversation [Package Development] Why Is Post Route In A Package Thrown An Exception Without A Message? • 3 months ago

So here is what I was trying to do. In a nutshell, I'm trying to authenticate in a package. So I have: Route::group(['middleware' => ['web']], function(){ Route::get('/login', 'Vendor\controller\[email protected]')->name('login'); }

Route::post('/login', 'Vendor\controller\[email protected]');

Route::group(['middleware' => 'auth'], function () { Route::get('/','Vendor\controller\[email protected]')->name('Home'); }

I found out that If I go with the setup above. you can successfully authenticate under [email protected], but the session data will not persist which means if I redirect to another page it will ask me to login again. Because route POST /login is not using middleware web. But if I put the POST route into the web middleware group, like this: Route::group(['middleware' => ['web']], function(){ Route::get('/login', 'Vendor\controller\[email protected]oginForm')->name('login'); Route::post('/login', 'Vendor\controller\[email protected]'); } it gives me an exception without any message. "message": "", "exception": "Symfony\Component\HttpKernel\Exception\HttpException", "file": "/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php", "line": 203,

Please help~~~~~~~~~

26th June, 2017

yu0307 left a reply on Accessor On Demand But Not On Every Results. • 9 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. • 9 months ago

anyone?

24th June, 2017

yu0307 left a reply on Accessor On Demand But Not On Every Results. • 9 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. • 10 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. • 10 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. • 10 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. • 10 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. • 10 months ago

anyone?

21st June, 2017

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

anyone?

yu0307 left a reply on 500 Error On Any Use Of Eloquent • 10 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. • 10 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 • 10 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 • 10 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 • 10 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 • 10 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 • 10 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? • 10 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? • 10 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? • 10 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" • 10 months ago

sure

yu0307 left a reply on How Can We Share Data Among Controllers "NOT VIEWS" • 10 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" • 10 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" • 10 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" • 10 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" • 10 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" • 10 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" • 10 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.