PHP code example of titasgailius / larastan-extended

1. Go to this page and download the library: Download titasgailius/larastan-extended 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/ */

    

titasgailius / larastan-extended example snippets

diff
/**
 * Get the attributes that should be cast.
- *
- * @return array{
- *     user_id: 'integer',
- *     published_at: 'datetime',
- * }
 */
public function casts(): array
{
    return [
        'user_id' => 'integer',
        'published_at' => 'datetime',
    ];
}
diff
Route::get('posts', function (Request $request) {
-    /** @var \App\Models\User */
-    $user = $request->user();
-
-    return $user->posts;
+    return $request->user()->posts;
})->middleware('auth');
diff
Route::get('teams/{team}/owner', function (Team $team) {
-  /** @var \App\Models\User */
-  $owner = $team->owner;
-
-  return $owner;
+  return $team->owner;
});