PHP code example of juampi92 / phpstan-eloquent-bounded-context

1. Go to this page and download the library: Download juampi92/phpstan-eloquent-bounded-context 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/ */

    

juampi92 / phpstan-eloquent-bounded-context example snippets


public function store(Request $request)
{
    $post = new Post($request->validated());
    $post->save();
}

📁 app
├─ 📁 Http
│  └─ 📁 Controllers
│     └─ 📃 PostController.php
└─ 📁 Domains
   └─ 📁 Posts
      └─ 📁 Actions
         └─ 📃 CreatePostAction.php
      └─ 📁 Models
         └─ 📃 Post.php
         └─ 📃 Comment.php

 ---------------------------------------------------------------------------
  app/Http/Controllers/PostController.php
 ---------------------------------------------------------------------------
  Calling 'save' on 'App\Models\Post' outside of its Domain is not allowed.
 ---------------------------------------------------------------------------