PHP code example of baconfy / support

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

    

baconfy / support example snippets


namespace App\Actions;

use App\Models\Post;
use App\Events\PostHasBeenCreated;
use Baconfy\Support\Concerns\Runner;

class CreatePostAction
{
    use Runner;

    public function handle(array $payload): Post
    {
        $post = Post::create($payload);

        event(new PostHasBeenCreated($post));

        return $post;
    }
}

namespace App\Controllers;

use App\Actions\CreatePostAction;

class PostController
{
    public function store(Request $request)
    {
        CreatePostAction::run($request->all());

        return back();
    }
}

use Baconfy\Support\Concerns\Uuid;

class User extends Model
{
    use Uuid;
}

use Baconfy\Support\Concerns\Slugfy;

class Post extends Model
{
    use Slugfy;
}