I don't know if the Larvel 5.5 windows function is called correctly.

Asked 2 years ago, Updated 2 years ago, 108 views

In Ravel 5, I want to separate Create and Like operations with buttons, but I can't do it well.

Buttons are processed in a separate PHP file.

<button type="submit" class="btn btn-primary" name="create">question posting</button>

I know that create_qa and Update_likes_whenbuttonClick can be run as long as they are single, but they do not work as soon as they are put into the button_Click function for sorting.(The page is blank, and the DB processing described in each function is complete.
In return, I have verified that the distribution itself is ready (I was able to see the ID, so I think there is no problem).

I would appreciate it if you could let me know if something is wrong.If you need any other information, I will add it.

The controller contains the following contents:

public function button_click(Request$request,$session_id){ 
    if(isset($_POST["create"))){ 
        $this->create_qa($request,$session_id); 
    } 
    else if(isset($_POST["like"])){ 
        // return $session_id; this is working 
        $this->update_likes_whenbuttonClick($request,$session_id); 
    } 
}

public function create_qa(Request$request,$session_id){
    ~
}

public function update_likes_whenbuttonClick(Request$request,$qatable_id){
    ~
}

php laravel-5

2022-09-30 21:31

1 Answers

Cubick pointed it out, so I will leave it as an answer.

public function button_click(Request$request,$session_id){ 
    if(isset($_POST["create"))){ 
        $this->create_qa($request,$session_id); 
    } 
    else if(isset($_POST["like"])){ 
        // return $session_id; this is working 
        $this->update_likes_whenbuttonClick($request,$session_id); 
    } 
}

public function create_qa(Request$request,$session_id){
    ~

         return view('qaupdate');
}

public function update_likes_whenbuttonClick(Request$request,$qatable_id){
    ~
}

and the return view with the return view written in the method you want to call is described in the button distribution method

public function button_click(Request$request,$session_id){ 
    if(isset($_POST["create"))){ 
        $this->create_qa($request,$session_id); 
         return view('qaupdate');
    } 
    else if(isset($_POST["like"])){ 
        // return $session_id; this is working 
        $this->update_likes_whenbuttonClick($request,$session_id); 
         return view('likeupdate');
    } 
}

public function create_qa(Request$request,$session_id){
    ~

}

public function update_likes_whenbuttonClick(Request$request,$qatable_id){
    ~
}

Now the page is displayed successfully


2022-09-30 21:31

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.