Skip to content

Início / Optitravel / Models

getAllowedColumns()

This method returns the list of columns that the model is allowed to interact with — meaning, the fields the system can read from or write to in the database.

The list is defined in each model using the $allowedColumns property. This helps protect against unwanted or accidental modifications to database fields that should remain untouched and can also improve performance by limiting which columns are used in queries.

Returns: - An array containing the names of the allowed columns for the model.

Example

use \App\Models\User;

$user = new User();
$columns = $user->getAllowedColumns();

print_r($columns);

Output:

Array
(
    [0] => id
    [1] => name
    [2] => username
    [3] => password
    [4] => email
    // ...
)

(Última atualização: 06/05/2025)