Skip to content

Commit

Permalink
minor doc fix
Browse files Browse the repository at this point in the history
  • Loading branch information
mvorisek committed Oct 1, 2021
1 parent 3f23749 commit a0651ef
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 33 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -565,14 +565,15 @@ Define your first model class:

``` php
namespace my;

class User extends \Atk4\Data\Model
{
public $table = 'user';
function init(): void
{
parent::init();

$this->addFields(['email','name','password']);
$this->addFields(['email', 'name', 'password']);
// use your table fields here
}
}
Expand All @@ -599,7 +600,7 @@ Now you can explore. Try typing:
> $m = new \my\User($db);
> $m->loadBy('email', 'example@example.com')
> $m->get()
> $m->export(['email','name'])
> $m->export(['email', 'name'])
> $m->action('count')
> $m->action('count')->getOne()
```
Expand Down
2 changes: 1 addition & 1 deletion docs/design.rst
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ Code::
class Model_Client extends Model_User {
public function sendPasswordReminder() {

mail($this->get('email'), 'Your password is: '.$this->get('password'));
mail($this->get('email'), 'Your password is: ' . $this->get('password'));
}
}

Expand Down
14 changes: 1 addition & 13 deletions docs/model.rst
Original file line number Diff line number Diff line change
Expand Up @@ -320,18 +320,6 @@ This can also be useful for calculating relative times::
}


Strict Fields
^^^^^^^^^^^^^

.. php:property:: strict_fields
By default model will only allow you to operate with values for the fields
that have been defined through addField(). If you attempt to get, set or
otherwise access the value of any other field that has not been properly
defined, you'll get an exception. Read more about :php:class:`Field`

If you set `strict_fields` to false, then the check will not be performed.

Actions
-------
Another common thing to define inside :php:meth:`Model::init()` would be
Expand All @@ -357,7 +345,7 @@ a user invokable actions::

$this->save(['password' => .. ]);

return 'generated and sent password to '.$m->get('name');
return 'generated and sent password to ' . $m->get('name');
}
}

Expand Down
2 changes: 1 addition & 1 deletion docs/persistence/csv.rst
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ which fields you would like to see in the CSV::

foreach (new Model_User($db) as $m) {
$m->withPersistence($csv)
->onlyFields(['id','name','password'])
->onlyFields(['id', 'name', 'password'])
->save();
}

Expand Down
17 changes: 1 addition & 16 deletions src/Persistence.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,22 +156,7 @@ public function load(Model $model, $id): array
/**
* Will convert one row of data from native PHP types into
* persistence types. This will also take care of the "actual"
* field keys. Example:.
*
* In:
* [
* 'name' => ' John Smith',
* 'age' => 30,
* 'password' => 'abc',
* 'is_married' => true,
* ]
*
* Out:
* [
* 'first_name' => 'John Smith',
* 'age' => 30,
* 'is_married' => 1
* ]
* field keys.
*
* @return array<scalar|Persistence\Sql\Expressionable|null>
*/
Expand Down

0 comments on commit a0651ef

Please sign in to comment.