Glowie
Edit this page
on GitHub

Retrieving data

Note: See Request in order to learn how to properly retrieve data in a much better way.

In order to retrieve a request data from a controller or middleware, there are three main properties that can be used:

All properties return an Element with the corresponding data.

Example 1
view

<form method="post" action="send">
    <input type="text" name="user" value="glowie">
    <input type="password" name="password" value="123">
    <button type="submit">Login</button>
</form>

controller

public function send(){
    $user = $this->post->user; # returns "glowie"
    $password = $this->post->password; # returns "123"
}

Example 2

# user types in myappurl.com/search?query=products&page=1
$query = $this->get->query; # returns "products"
$page = $this->get->page; # returns "1"

You can combine any of the Element methods to check for data, get default values or more.

Example

# user types in myappurl.com/search?query=products
$page = $this->get->get('page', 1); # returns "1" as the default value
$isSearching = $this->get->has('query'); # returns true