PHP code example of smurfworks / model-finder
1. Go to this page and download the library: Download smurfworks/model-finder library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
smurfworks / model-finder example snippets
/**
* Get the index (implement laravel caching around this as you need)
*
* @var array $index
*/
$index = app('model-finder')->discover();
dd($index);
// Trimmed for verbosity (...)
array:3 [
"SmurfWorks\ModelFinderTests\SampleModels\User" => array:4 [
"meta" => array:2 [
"name" => "User"
"describe" => "A user record represents a person's access to this system"
]
"attributes" => array:9 [
"id" => array:4 [
"type" => "integer"
"default" => null
"fillable" => false
"hidden" => false
]
"name" => array:4 [
"type" => "string"
"default" => null
"fillable" => true
"hidden" => false
]
"email" => array:4 [
"type" => "string"
"default" => null
"fillable" => true
"hidden" => false
]
"password" => array:4 [
"type" => "string"
"default" => null
"fillable" => true
"hidden" => false
]
...
]
"relations" => array:1 [
"role" => array:3 [
"type" => "BelongsTo"
"model" => "SmurfWorks\ModelFinderTests\SampleModels\User\Role"
"meta" => array:2 [
"name" => "User role"
"describe" => "The user's system role"
]
]
]
"scopes" => array:2 [
"activated" => array:1 [
"meta" => array:2 [
"name" => "Activated users"
"describe" => "Activated users have set a password."
]
]
"subscribed" => array:1 [
"meta" => array:2 [
"name" => "Subscribed"
"describe" => "Users that are opted in to receive the newsletter."
]
]
]
]
"SmurfWorks\ModelFinderTests\SampleModels\User\Permission" => array:4 [
"meta" => array:2 [
"name" => "User permission"
"describe" => null
]
...
]
...
]