{"id":24727054,"url":"https://github.com/alexyaframework/database","last_synced_at":"2026-05-05T03:36:33.249Z","repository":{"id":56944900,"uuid":"64300610","full_name":"AlexyaFramework/Database","owner":"AlexyaFramework","description":"Alexya's database components","archived":false,"fork":false,"pushed_at":"2017-06-08T22:23:26.000Z","size":59,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-22T14:44:59.764Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AlexyaFramework.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-07-27T10:45:30.000Z","updated_at":"2016-08-17T17:54:10.000Z","dependencies_parsed_at":"2022-08-21T07:50:57.675Z","dependency_job_id":null,"html_url":"https://github.com/AlexyaFramework/Database","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlexyaFramework%2FDatabase","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlexyaFramework%2FDatabase/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlexyaFramework%2FDatabase/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlexyaFramework%2FDatabase/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AlexyaFramework","download_url":"https://codeload.github.com/AlexyaFramework/Database/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244973694,"owners_count":20541022,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-01-27T14:50:01.671Z","updated_at":"2026-05-05T03:36:33.208Z","avatar_url":"https://github.com/AlexyaFramework.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"Database\n========\nAlexya's database components\n\nContents\n--------\n\n - [Connection](#connection)\n    - [Connecting to a database](#connecting_to_a_database)\n    - [Executing queries](#executing_queries)\n    - [Advanced Database Functions](#advanced_database_functions)\n - [Query builder](#query_builder)\n    - [Select queries](#select_queries)\n    - [Insert queries](#insert_queries)\n    - [Update queries](#update_queries)\n    - [Delete queries](#delete_queries)\n    - [`WHERE` Syntax](#where_syntax)\n    - [Other SQL Functions](#other_sql_functions)\n - [ORM](#orm)\n    - [CRUD](#crud)\n       - [Creating records](#creating_recors)\n       - [Reading records](#reading_records)\n       - [Updating records](#updating_records)\n       - [Deleting records](#deleting_records)\n    - [Relations](#relations)\n\n\u003ca name=\"connection\"\u003e\u003c/a\u003e\nConnection\n----------\n\nThe class `\\Alexya\\Database\\Connection` provides an easy layer for connecting to a database and execute queries.\n\n\u003ca name=\"connecting_to_a_database\"\u003e\u003c/a\u003e\n### Connecting to a database\n\nTo connect to a database you'll need to instance a `\\Alexya\\Database\\Connection` object, the constructor accepts\nthe following parameters:\n\n * A string being server's host/ip\n * An integer being server's port\n * A string being database username\n * A string being database password\n * A string being database password\n\n\u003ca name=\"executing_queries\"\u003e\u003c/a\u003e\n### Executing queries\n\nThe method `\\Alexya\\Database\\Connection::execute` accepts as parameter a string that is the SQL query to execute:\n\n```php\n\u003c?php\n\n$Database = new \\Alexya\\Database\\Connection(\"localhost\", 3306, \"root\", \"\", \"alexya\");\n\n$users = $Database-\u003eexecute(\"SELECT * FROM `users`\");\n\nprint_r($users);\n```\n\nYou can also send a boolean indicating if the connection should fetch all results or just one, you can also\nspecify how the results will be fetched with a third parameter, by default it's `PDO::FETCH_ASSOC`.\n\n\u003ca name=\"advanced_database_functions\"\u003e\u003c/a\u003e\n### Advanced Database Functions\n\nIf you want to take a total control over `\\Alexya\\Database\\Connection` class you can use the method\n`\\Alexya\\Database\\Connection::getConnection` that retruns the current PDO object with the database connection.\n\nWhen an error happens the method `\\Alexya\\Database\\Connection::getError` returns the latest error:\n\n```php\n\u003c?php\n\n$Database = new \\Alexya\\Database\\Connection(\"localhost\", 3306, \"root\", \"\", \"alexya\");\n\n$users = $Database-\u003equery(\"SELECT FROM `users`\");\nif(empty($users)) {\n    echo \"An error happened!\\n\". $Database-\u003egetError();\n}\n```\n\nYou can see the last executed query with the property `\\Alexya\\Database\\Connection::lastQuery`:\n\n```php\n\u003c?php\n\n$Database = new \\Alexya\\Database\\Connection(\"localhost\", 3306, \"root\", \"\", \"alexya\");\n\n$users = $Database-\u003equery(\"SELECT FROM `users`\");\necho \"Last query: \". $Database-\u003elastQuery; // Last query: SELECT FROM `users`\n```\n\n\u003ca name=\"query_builder\"\u003e\u003c/a\u003e\nQuery builder\n-------------\nThe class `\\Alexya\\Database\\QueryBuilder` provides a fluent way for generating queries.\n\nThe constructor accepts as parameter the `\\Alexya\\Database\\Connection` object with the connection to the database.\nOnce you've generated the query you can execute it directly with the method `execute` or retrieve the SQL with the\nmethod `getQuery`.\n\nIf you want to build more than one query with the same `\\Alexya\\Database\\QueryBuilder` use the method `clear` each time\nyou finish a query.\n\n\u003ca name=\"select_queries\"\u003e\u003c/a\u003e\n### Select queries\n\nThe method `\\Alexya\\Database\\QueryBuilder::select` begins a `SELECT` query and accepts 3 types of parameters:\n * Nothing (the same as passing \"*\" as parameter)\n * A string that contains the name of the colum to select\n * An array containing the columns to select\n\n```php\n\u003c?php\n\n$query-\u003eselect(); // SELECT *\n$query-\u003eselect(\"name\"); // SELECT `name`\n$query-\u003eselect([\"name\", \"password\", \"email\"]); // SELECT `name`, `password`, `email`\n```\n\nNext we must indicate the table that we will use for getting the columns, we do that with the method `\\Alexya\\Database\\QueryBuilder::from`\nthat accepts as parameter a string containing the name of the table:\n\n```php\n\u003c?php\n\n$query-\u003eselect()\n      -\u003efrom(\"users\"); // SELECT * FROM `users`\n```\n\n\u003ca name=\"update_queries\"\u003e\u003c/a\u003e\n### Insert queries\n\nThe method `\\Alexya\\Database\\QueryBuilder::insert` begins an `INSERT` query and accepts as parameter a string\nthat is the name of the table to insert the new record:\n\n```php\n\u003c?php\n\n$query-\u003einsert(\"users\"); // INSERT INTO `users`\n```\n\nThe next thing is to add the values to insert to the table, for that we use the method `\\Alexya\\Database\\QueryBuilder::values`\nthat accepts an array as parameter, it contains the values to insert into table:\n\n```php\n\u003c?php\n\n$query-\u003einsert(\"users\")\n      -\u003evalues([\n            \"id\"       =\u003e 1,\n            \"name\"     =\u003e \"test\",\n            \"password\" =\u003e \"test\",\n            \"email\"    =\u003e \"test@test.test\"\n        ]); // INSERT INTO `users` (`id`, `name`, `password`, `email`) VALUES (1, 'test', 'test', 'test@test.test')\n```\n\nIf an index of the array is an object or an array it will serialize it to convert it to a string.\n\n```php\n\u003c?php\n\n$query-\u003einsert(\"users\")\n      -\u003evalues([\n            \"login_log\" =\u003e [\"date1\", \"date2\", \"date3\"]\n        ]); // INSERT INTO `users` (`login_log`) VALUES ('a:3:{i:0;s:5:\"date1\";i:1;s:5:\"date2\";i:2;s:5:\"date3\";}')\n\n$log = new LoginLog(); //Let's assume it exists and is the same as the array but in an object shape\n$query-\u003einsert(\"users\")\n      -\u003evalues([\n            \"login_log\" =\u003e $log\n        ]); // INSERT INTO `users` (`login_log`) VALUES ('O:3:\"Obj\":3:{s:5:\"date1\";s:5:\"date1\";s:5:\"date2\";s:5:\"date2\";s:5:\"date3\";s:5:\"date3\";}')\n```\n\nAlternatively you can encode the values with JSON:\n```php\n\u003c?php\n\n$query-\u003einsert(\"users\")\n      -\u003evalues([\n            \"(JSON)login_log\" =\u003e [\"date1\", \"date2\", \"date3\"]\n        ]); // INSERT INTO `users` (`login_log`) VALUES ('[\"date1\",\"date2\",\"date3\"]')\n\n$log = new LoginLog(); //Let's assume it exists and is the same as the array but in an object shape\n$query-\u003einsert(\"users\")\n      -\u003evalues([\n            \"(JSON)login_log\" =\u003e $log\n        ]); // INSERT INTO `users` (`login_log`) VALUES ('{\"date1\":\"date1\",\"date2\":\"date2\",\"date3\":\"date3\"}')\n```\n\n\u003ca name=\"update_queries\"\u003e\u003c/a\u003e\n### Update queries\n\nThe method `\\Alexya\\Database\\QueryBuilder::update` begins an `UPDATE` query and accepts as parameter a stringt\nthat is the name of the table to alter.\n```php\n\u003c?php\n/**\n * Load Alexya's core\n */\nrequire_once(\"bootstrap.php\");\n\n$query = new \\Alexya\\Database\\QueryBuilder();\n\n$query-\u003eupdate(\"users\"); // UPDATE `users`\n```\n\nNow we have to set the values to alter, we do that with the method `\\Alexya\\Database\\QueryBuilder::set` which accepts as parameter\nan array with the values to alter. You can append to the end of the key the following tags:\n * [+]\n * [-]\n * [*]\n * [/]\n\nYou can also serialize values like in `INSERT` queries.\n\n```php\n\u003c?php\n\n$query-\u003eupdate(\"users\")\n      -\u003eset([\n            \"name\"     =\u003e \"test\",\n            \"money[+]\" =\u003e 2\n        ]); // UPDATE `users` SET `name`='test', `money`=(`money`+2)\n```\n\n\u003ca name=\"delete_queries\"\u003e\u003c/a\u003e\n### Delete queries\n\nDelete queries begins with the method `\\Alexya\\Database\\QueryBuilder::delete` that accepts as parameter the table name as string:\n```php\n\u003c?php\n\n$query-\u003edelete(\"users\"); // DELETE FROM `users`\n```\n\n\u003ca name=\"where_syntax\"\u003e\u003c/a\u003e\n### `WHERE` Syntax\n\nThe method `\\Alexya\\Database\\QueryBuilder::where` starts the `WHERE` clause and accepts as parameter containing an array:\n\n```php\n\u003c?php\n\n$query-\u003eselect()\n      -\u003efrom(\"users\")\n      -\u003ewhere([\n            \"name\" =\u003e \"test\"\n        ]); // SELECT * FROM `users` WHERE `name`='test'\n```\n\nFor more advanced conditions you can use the followin tags:\n * [\u003e]\n * [\u003e=]\n * [!]\n * [\u003c\u003e]\n * [\u003e\u003c]\n\n```php\n\u003c?php\n\n$query-\u003ewhere([\n    \"id[\u003e]\" =\u003e 100\n]); // WHERE `id`\u003e100\n\n$query-\u003ewhere([\n    \"id[\u003e=]\" =\u003e 100\n]); // WHERE `id`\u003e=100\n\n$query-\u003ewhere([\n    \"id[!]\" =\u003e 100\n]); // WHERE `id`!=100\n\n$query-\u003ewhere([\n    \"id[\u003c\u003e]\" =\u003e [0, 1000]\n]); // WHERE `id` BETWEEN 0 AND 1000\n\n$query-\u003ewhere([\n    \"id[\u003e\u003c]\" =\u003e [0, 1000]\n]); // WHERE `id` NOT BETWEEN 0 AND 1000\n\n$query-\u003ewhere([\n    \"id\" =\u003e [0, 1, 2, 3, 4, 5, 6]\n]); // WHERE `id` IN(0,1,2,3,4,5,6)\n\n$query-\u003ewhere([\n    \"id[!]\" =\u003e [0, 1, 2, 3, 4, 5, 6]\n]); // WHERE `id` NOT IN(0,1,2,3,4,5,6)\n\n$query-\u003ewhere([\n    \"name\" =\u003e NULL\n]); // WHERE `name` IS NULL\n\n$query-\u003ewhere([\n    \"name[!]\" =\u003e NULL\n]); // WHERE `name` IS NOT NULL\n```\n\nYou can also serialize data by adding `(JSON)` to the begining of the key:\n\n```php\n\u003c?php\n\n$query-\u003ewhere([\n    \"(JSON)login_log\" =\u003e [\"date1\", \"date2\", \"date3\"]\n]); // WHERE `login_log`='[\"date1\",\"date2\",\"date3\"]'\n```\n\nYou can also add `AND` and `OR` statemets:\n\n```php\n\u003c?php\n\n$query-\u003ewhere([\n    \"AND\" =\u003e [\n        \"OR\" =\u003e [\n            \"username\" =\u003e \"test\",\n            \"email\"    =\u003e \"test@test.test\"\n        ],\n        \"password\" =\u003e \"test\"\n    ]\n]); // WHERE `username`='test' OR `email`='test@test.test' AND `password`='test'\n```\n\n\u003ca name=\"other_sql_functions\"\u003e\u003c/a\u003e\n### Other SQL functions\n\n`\\Alexya\\Database\\QueryBuilder` provides 3 other methods for SQL clauses:\n\nThe method `\\Alexya\\Database\\QueryBuilder::limit` begins a `LIMIT` clause and can accept an integer or an array as parameter:\n\n```php\n\u003c?php\n\n$query-\u003elimit(1); //LIMIT 1\n$query-\u003elimit([1, 10]); //LIMT 1, 10\n```\n\nThe method `\\Alexya\\Database\\QueryBuilder::offset` begins a `OFFSET` clause and accepts an integer as parameter:\n\n```php\n\u003c?php\n\n$query-\u003eoffset(10); //OFFSET 10\n```\n\nThe method `\\Alexya\\Database\\QueryBuilder::sql` appends raw SQL to the query, this method does not avoids SQL injection\nso it's not recommended to use unless you know what you're doing:\n\n```php\n\u003c?php\n\n$query-\u003esql(\"SELECT * FROM users WHERE username='test'\"); //SELECT * FROM users WHERE username='test'\n```\n\n\u003ca name=\"orm\"\u003e\u003c/a\u003e\nORM\n---\n\nThe class `\\Alexya\\Database\\ORM\\Model` acts as the mediator between the database table and the PHP code.\n\nBefore anything you should initialize the class with the method `initialize`.\nIt accepts as parameter an object of type `\\Alexya\\Database\\Connection` being the connection to the database\nand a string being the base namespace where the Model classes are located, this is if you want to store the Model\nclasses in a separated namespace (default is \"\\\"):\n\n```php\n\u003c?php\n\n$connection = new Connection(\"localhost\", 3306, \"root\", \"\", \"alexya\");\nModel::initialize($connection, \"\\Application\\ORM\");\n```\n\nYou should write a class that extends this for each model, but when you're following the naming conventions\nyou'll surely finish with a package full of empty classes.\nTo prevent this you can use the method `instance` which accepts as parameter the name of the database table.\nAlso, all static methods accepts as last parameter the name of the table.\n\nExtending this class allows you to take more control over it. You can specify the name of the table, the name of\nthe primary key, relations...\n\nThe table name is, by default, the `snake_case`, plural name of the class, if you want to override it change the\nproperty `_table` with the name of the table:\n\n```php\n\u003c?php\n\nclass UsersTable extends Model\n{\n    protected $_table = \"users\"; // Without this, the table name would be `userstables`, see \\Alexya\\Database\\ORM\\Model::getTable\n}\n```\n\nThe primary key is, by default, `id`, if you want to override it change the property `_primaryKey` with the name of\nthe primary key:\n\n```php\n\u003c?php\n\nclass UsersTable extends Model\n{\n    protected $_primaryKey = \"userID\";\n}\n```\n\nThe method `onInstance` is executed when the class has been instantiated, use it instead of the constructor.\n\n\u003ca name=\"crud\"\u003e\u003c/a\u003e\nCRUD\n----\n\nCRUD stands for Create, Read, Update, Delete.\n\n\u003ca name=\"creating_records\"\u003e\u003c/a\u003e\n### Creating records\n\nTo create a new record call the method `\\Alexya\\Database\\ORM\\Model::create`:\n\n```php\n\u003c?php\n\n$user = UsersTable::create();\n\n$user-\u003eid       = 1;\n$user-\u003ename     = \"test\";\n$user-\u003epassword = \"test\";\n$user-\u003eemail    = \"test@test.test\";\n\n$user-\u003esave();\n```\n\n\u003ca name=\"reading_records\"\u003e\u003c/a\u003e\n### Reading records\n\nThe method `find` finds a record from the database and returns an instance of the Model class.\nIt accepts as parameter an integer being the value of the primary key or an array contaning the `WHERE` clause of the query:\n\n```php\n\u003c?php\n\n$user      = UsersTable::find(1); // SELECT * FROM `users` WHERE `usersID`=1\n$otherUser = UsersTable::find([\n    \"name\" =\u003e \"test\"\n]); // SELECT * FROM `users` WHERE `name`='test'\n\nif($user-\u003ename == $otherUser-\u003ename) {\n    $user-\u003ename = \"Test\";\n    $user-\u003esave;\n\n    $otherUser-\u003eid = 2;\n    $otherUser-\u003esave;\n}\n```\n\nYou can send a second integer parameter being the amount of records to fetch from the database.\nIf it's omited it will return a single record, otherwise an array of speficied amount of records.\n\n\u003ca name=\"updating_records\"\u003e\u003c/a\u003e\n### Updating records\n\nOnce you have the ORM instance you can use the methods `\\Alexya\\Database\\ORM\\Model::get` and `\\Alexya\\Database\\ORM\\Model::set` to changes\nthe values of columns, it also has the [magic methods __get, __set, __isset and __unset](http://php.net/manual/en/language.oop5.overloading.php) for\nan alternative syntax. To update the database use the method `\\Alexya\\Database\\ORM\\Model::save`:\n\n```php\n\u003c?php\n\n$user = UsersTable::find(1); // SELECT * FROM `users` WHERE `usersID`=1\n\n$user-\u003ename     = \"test\";\n$user-\u003epassword = \"test\";\n\n$user-\u003esave(); // UPDATE `users` SET `name`='test', `password`='test' WHERE `usersID`=1\n```\n\n\u003ca name=\"deleting_records\"\u003e\u003c/a\u003e\n### Deleting records\n\nTo delete records you must call the method `\\Alexya\\Database\\ORM\\Model::delete`:\n\n```php\n\u003c?php\n\n$user = UsersTable::find(1); // SELECT * FROM `users` WHERE `usersID`=1\n\n$user-\u003edelete(); // DELETE FROM `users` WHERE `userID`=1\n```\n\n\u003ca name=\"relations\"\u003e\u003c/a\u003e\n### Relations\nThe relations are established between two tables that share something in common.\n\nThe `\\Alexya\\Database\\ORM\\Model` class offers an easy way for establishing relations\nthrough the static property `$_relations`, which can be public or protected, but never private.\n\nThe `$_relations` property is an array.\nEach index of this array will be interpreted as a relation rule.\n\nA rule can be:\n\n * A string being the class name of the Model class that represents the table or the table name (if the class doesn't exist).\n * An array containing the configuration of the rule.\n\nIf the index is an array, the key must be the name of the Model class and can have the following index:\n\n * `localKey`: Name of the local key used for the relation (defaults to the foreign table name followed by the local primary key).\n * `foreignKey`: Name of the foreign key used for the relation (defaults to the foreign primary key).\n * `type`: Type of the relation (`has_one` or `has_many`) (defaults to `has_one`).\n * `name`: Name of the property to create for the resulting relation (defaults to the name of the class).\n * `amount`: Amount of records to retrieve for the relation (defaults to all records in the table).\n * `class`: Name of the class that will be instanced for the relation (defaults to the Model class of the foreign table in case of a `has_one` relation and an array of Model classes of the foreign table in case of a `has_many` relation).\n * `setRelations`: Whether the instanced models of the relation should process their relations array too or not (defaults to `false`).\n\nThe name of the Model class can either start with the prefix sent to the `initialize` method, or the name of table.\n\nExample:\n\n```php\n\u003c?php\n\nclass User extends Model\n{\n    protected static $_relations = [\n        \"Message\" =\u003e [\n            \"type\" =\u003e \"has_many\"\n        ],\n        \"Configuration\"\n    ]\n}\n```\n\nThis example will make two relations:\n\n * One for the table `messages`.\n * One for the table `configurations`.\n\nThe relation for the `messages` table will load all records from the database that matches the local/foreign key relation.\n\nBy default, the local key is the name of the local table followed by the primary key of the foreign table, and the foreign key is the primary key of the foreign table.\n\nSo, given that `User and `Messages` follows the standards of this class the local key would be `messages_id` and the foreign key would be `id`, so the generated query would be `SELECT * FROM messages WHERE id=users.messages_id;`.\n\nFor overriding the default local key change the index `localKey` and for overriding the default foreign key, change the index `foreignKey`.\n\nAs the message have a sender and a recipient, assuming that the `id` column on the `messages` table is the `messages_id` of the user is wrong, so instead we change the foreign key to a more suitable one: `to_users_id`\n\n```php\n\u003c?php\n\nclass User extends Model\n{\n    protected static $_relations = [\n        \"Message\" =\u003e [\n            \"type\"       =\u003e \"has_many\",\n            \"foreignKey\" =\u003e \"to_users_id\"\n        ],\n        \"Configuration\"\n    ]\n}\n```\n\nBy default all the relations are `one to one`, meaning that only one from the database will be fetched.\n\nAs the user might have more than one message, we change the relation type by changing the `type` index in the value.\n\nAfter this, we are able to access to all messages sent to the user through the property `$user-\u003eMessage` which would be an array with all `Message` classes representing the records from the database.\n\nHowever, calling that property `Message` isn't the best option since it's not a single message, but a collection of messages.\nWe can change this name by setting the `name` index to something different.\n\n```php\n\u003c?php\n\nclass User extends Model\n{\n    protected static $_relations = [\n        \"Message\" =\u003e [\n            \"type\"       =\u003e \"has_many\",\n            \"foreignKey\" =\u003e \"to_users_id\",\n            \"name\"       =\u003e \"Messages\"\n        ],\n        \"Configuration\"\n    ]\n}\n```\n\nNow all messages are in the `$user-\u003eMessages` property.\n\nAnother thing that we would like to change is the amount of records to retrieve from the database and Whether the instanced models should process their relations too. We can do this by changing the index `amount` and `setRelations` respectively.\n\nFinally, we can decide if we should retrieve the messages only if the user has verified his email, we do this with the index `condition`, which is a closure that should return a boolean telling if the relation should be processed or not.\n\nThe closure must accept as parameter an array that will contain the result of the query.\n\n```php\n\u003c?php\n\nclass User extends Model\n{\n    protected static $_relations = [\n        \"Message\" =\u003e [\n            \"type\"       =\u003e \"has_many\",\n            \"foreignKey\" =\u003e \"to_users_id\",\n            \"name\"       =\u003e \"Messages\",\n            \"condition\"  =\u003e \"User::canSetMessage\"\n        ],\n        \"Configuration\"\n    ]\n\n    public static function canSetMessage(array $columns) : bool\n    {\n        // Check that the user has verified his email\n        if(!$this-\u003eemail_isVerified) {\n            return false;\n        }\n\n        // Check that the message isn't deleted by the user\n        if($columns[\"to_isDeleted\"]) {\n            return false;\n        }\n\n        return true;\n    }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falexyaframework%2Fdatabase","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falexyaframework%2Fdatabase","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falexyaframework%2Fdatabase/lists"}