stupidlysimple /
php
| 1 | <!DOCTYPE HTML> |
||
| 2 | <!-- |
||
| 3 | Phantom by HTML5 UP |
||
| 4 | html5up.net | @ajlkn |
||
| 5 | Free for personal and commercial use under the CCA 3.0 license (html5up.net/license) |
||
| 6 | --> |
||
| 7 | <html> |
||
| 8 | <?php |
||
| 9 | $data = ['title' => 'StupidlySimple PHP | Service']; |
||
| 10 | Core\Viewer::file('layouts/head', $data); |
||
| 11 | ?> |
||
| 12 | <body> |
||
| 13 | <!-- Wrapper --> |
||
| 14 | <div id="wrapper"> |
||
| 15 | |||
| 16 | <?php Viewer::file('layouts/top') ?>
|
||
|
0 ignored issues
–
show
|
|||
| 17 | |||
| 18 | <?php Viewer::file('layouts/menu') ?>
|
||
| 19 | |||
| 20 | <!-- Main --> |
||
| 21 | <div id="main"> |
||
| 22 | <div class="inner"> |
||
| 23 | <div class="contents"> |
||
| 24 | <h1>Introduction to Model</h1> |
||
| 25 | <p>The Model in any MVC frameworks will be responsible for maintaining data, which primarily listen to Controllers to update itself.</p> |
||
| 26 | <p>The Eloquent ORM included with StupidlySimple provides a beautiful, simple ActiveRecord implementation for |
||
| 27 | working with your database. Each database table has a corresponding "Model" which is used to interact |
||
| 28 | with that table. Models allow you to query for data in your tables, as well as insert new records |
||
| 29 | into the table.</p> |
||
| 30 | <p>Services are defined on <code>/app/Models</code> and are automatically included by Composer. See how we define them <a target="_blank" href="https://github.com/stupidlysimple/framework/tree/master/app/Model">on GitHub</a>.</p> |
||
| 31 | |||
| 32 | <h1>Model Demonstration</h1> |
||
| 33 | <p>We have a couple of test functions to demonstrate how to use model in the framework:</p> |
||
| 34 | |||
| 35 | <h3>Load all Post </h3> |
||
| 36 | <p>Load the whole post with <code>Model\Post::all()</code> </p> |
||
| 37 | <p> |
||
| 38 | <?php |
||
| 39 | $i = 1; |
||
| 40 | foreach (Model\Post::all() as $post) { |
||
| 41 | echo ' |
||
| 42 | <div class="alert alert-info"> |
||
| 43 | |||
| 44 | <b><?= $first_post->'.$post->title.'</b><br> |
||
|
0 ignored issues
–
show
|
|||
| 45 | <span><?= $first_post->'.$post->content.'</span> |
||
|
0 ignored issues
–
show
|
|||
| 46 | </div>'; |
||
| 47 | } |
||
| 48 | echo 'There are: '.Model\Post::all()->count().' posts.'; |
||
| 49 | ?> |
||
| 50 | </p> |
||
| 51 | |||
| 52 | <h2>Get the first Post</h2> |
||
| 53 | <p>Load the Post model <code>$first_post = Model\Post::all()->first();</code> then echo <code>$first_post->title</code> and <br> |
||
| 54 | <code>$first_post->content</code></p> |
||
| 55 | <p>Output:</p> |
||
| 56 | <p class="alert alert-info"> |
||
| 57 | <?php $first_post = Model\Post::all()->first(); ?> |
||
| 58 | <b><?= $first_post->title ?></b><br> |
||
| 59 | <span><?= $first_post->content ?></span> |
||
| 60 | </p> |
||
| 61 | |||
| 62 | <h2>Searching for the POST with id 3</h2> |
||
| 63 | <p>Search the Post model <code>$search_post = Model\Post::find(3);</code> then echo <code>$search_post->title</code> and <br> |
||
| 64 | <code>$search_post->content</code></p> |
||
| 65 | <p>Output:</p> |
||
| 66 | <p class="alert alert-info"> |
||
| 67 | <?php $search_post = Model\Post::find(3); ?> |
||
| 68 | <b><?= $search_post->title ?></b><br> |
||
| 69 | <span><?= $search_post->content ?></span> |
||
| 70 | </p> |
||
| 71 | </div> |
||
| 72 | </div> |
||
| 73 | </div> |
||
| 74 | |||
| 75 | <?php Viewer::file('layouts/footer') ?>
|
||
| 76 | |||
| 77 | </div> |
||
| 78 | |||
| 79 | <?php Viewer::file('layouts/scripts') ?>
|
||
| 80 | </body> |
||
| 81 | </html> |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths