PHP code example of mateffy / laravel-introspect
1. Go to this page and download the library: Download mateffy/laravel-introspect 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/ */
mateffy / laravel-introspect example snippets
use Mateffy\Introspect\Facades\Introspect;
$views = Introspect::views()
->whereNameEquals('components.*.button')
->whereUsedBy('pages.admin.*')
->get();
$routes = Introspect::routes()
->whereUsesController(MyController::class)
->whereUsesMiddleware('auth')
->whereUsesMethod('POST')
->get();
$classes = Introspect::classes()
->whereImplements(MyInterface::class)
->whereUses(MyTrait::class)
->get();
$models = Introspect::models()
->whereHasProperties(['name', 'email'])
->whereHasFillable('password')
->get();
// Access Eloquent properties, relationships, casts, etc. directly
$detail = Introspect::model(User::class);
// Model to JSON schema
$schema = $detail->schema();
$views = Introspect::views()
// Supports wildcards
->whereNameEquals('*components.*item')
->get();
// -> ['components.item', 'filament::components.dropdown.list.item', ...]
$views = Introspect::views()
->whereNameStartsWith('filament::')
->get();
$views = Introspect::views()
->whereNameEndsWith('button')
->get();
$views = Introspect::views()
->whereNameContains('button')
->get();
$routes = Introspect::views()
->whereUsedBy('pages.welcome')
->get();
// -> ['components.button', 'filament::components.button', ...]
$routes = Introspect::views()
->whereUsedBy('pages.*')
->get();
$routes = Introspect::views()
->whereNotUsedBy('pages.*')
->get();
$routes = Introspect::views()
->whereUses('components.button')
->get();
$routes = Introspect::views()
->whereUses('*.button')
->get();
$routes = Introspect::views()
->whereDoesntUse('*.button')
->get();
$routes = Introspect::views()
->whereExtends('layouts.app')
->get();
$routes = Introspect::views()
->whereExtends('layouts.*')
->get();
$routes = Introspect::views()
->whereDoesntExtend('layouts.*')
->get();
$routes = Introspect::routes()
->whereUsesController(MyController::class)
->get();
// -> [\Illuminate\Routing\Route, \Illuminate\Routing\Route, ...]
$routes = Introspect::routes()
->whereUsesController(MyController::class, 'index')
->get();
$routes = Introspect::routes()
->whereUsesController(SingleActionController::class, 'index')
->get();
$routes = Introspect::routes()
->whereUsesMiddleware(MyMiddleware::class)
->get();
$routes = Introspect::routes()
->whereUsesMiddlewares(['tenant', 'auth'])
->get();
$routes = Introspect::routes()
// Match any of the middlewares
->whereUsesMiddlewares(['tenant', 'auth'], all: false)
->get();
$routes = Introspect::routes()
->whereDoesntUseMiddleware('api')
->get();
$routes = Introspect::routes()
->whereNameEquals('api.products.*')
->get();
$routes = Introspect::routes()
->whereNameStartsWith('api.products.')
->get();
$routes = Introspect::routes()
->whereNameEndsWith('api.products.')
->get();
$routes = Introspect::routes()
->whereNameDoesntEqual('api.products.*')
->get();
$routes = Introspect::routes()
->wherePathStartsWith('api/products')
->get();
$routes = Introspect::routes()
->wherePathEndsWith('products')
->get();
$routes = Introspect::routes()
->wherePathContains('products')
->get();
$routes = Introspect::routes()
->wherePathEquals('api/products*')
->get();
$services = Introspect::classes()
->whereName('\App\Services')
->get();
$blocks = Introspect::classes()
->whereExtends(CMS\Block::class)
->get();
$blocks = Introspect::classes()
->whereImplements(CMS\Block::class)
->get();
$blocks = Introspect::classes()
->whereUses(MyTrait::class)
->get();
$models = Introspect::models()
->whereHasProperty('created_at')
->get();
// Also available: whereDoesntHaveProperty, whereHasProperties, whereDoesntHaveProperties
// Example with multiple properties (any):
$models = Introspect::models()
->whereHasProperties(['first_name', 'last_name'], all: false)
->get();
$models = Introspect::models()
->whereHasFillable('title')
->get();
// Also available: whereDoesntHaveFillable, whereHasFillableProperties, etc.
$models = Introspect::models()
->whereHasFillableProperties(['name', 'description']) // all: true by default
->get();
$models = Introspect::models()
->whereHasHidden('password')
->get();
// Also available: whereDoesntHaveHidden, whereHasHiddenProperties, etc.
$models = Introspect::models()
->whereDoesntHaveHiddenProperties(['name', 'email'], all: false) // neither name nor email are hidden
->get();
$models = Introspect::models()
->whereHasAppended('full_name')
->get();
// Also available: whereDoesntHaveAppended, whereHasAppendedProperties, etc.
$models = Introspect::models()
->whereHasAppendedProperties(['is_active', 'resource_type'])
->get();
$models = Introspect::models()
->whereHasReadable('name')
->get();
// Also available: whereDoesntHaveReadable, whereHasReadableProperties, etc.
$models = Introspect::models()
->whereHasReadableProperties(['id', 'email'])
->get();
$models = Introspect::models()
->whereHasWritable('status')
->get();
// Also available: whereDoesntHaveWritable, whereHasWritableProperties, etc.
$models = Introspect::models()
->whereHasWritableProperties(['name', 'settings'])
->get();
$models = Introspect::models()
->whereHasRelationship('user')
->get();
$models = Introspect::models()
->whereDoesntHaveRelationship('logs')
->get();
use \Mateffy\Introspect\Query\Contracts\RouteQueryInterface;
$routes = Introspect::routes()
->whereNameEquals('api.*')
->whereMethod('POST')
->or(fn (RouteQueryInterface $query) => $query
->whereHasParameter('product') //
->whereHasParameter('category')
)
->get();
$routes = Introspect::routes()
->whereUsesMiddlewares(['tenant', 'auth'], all: false)
->get();
$models = Introspect::models()
->limit(10)
->offset(20)
->get();
$model = Introspect::model(User::class);
$properties = $models->properties();
$schema = Introspect::model(User::class)->schema();
// -> ['type' => 'object',...]