Skip to content

humans/laravel-sandbox

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

48 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Laravel Sandbox

Laravel Sandbox is a package to easily add front-end support to database factories.

Installation

composer require humans/laravel-sandbox

Create your first Sandbox

Sandbox provides an artisan command to create a sandbox class. All files are added to your app/Sandbox folder.

php artisan sandbox:make SalesDemo

Register your Sandbox in a Service Provider

The Sandboxes needs to be registered to something something.

Sandbox::register([
    \App\Sandbox\SalesDemo::class,
]);

Add functionality to your Sandbox

use Auth;
use Humans\Sandbox\Contracts\RefreshDatabase;
use Humans\Sandbox\Sandbox;

class SalesDemo extends Sandbox implements RefreshDatabase
{
    public function run()
    {
        Auth::login(
             factory(\App\User::class)->create()
        );

        return redirect()->route('home');
    }
}

Create a view for your sandboxes.

@foreach (Sandbox::sandboxes() as $sandbox)
  <h3>{{ $sandbox->title() }}</h3>
  <form method="POST" action="{{ route('sandbox.run') }}">
    @csrf
    <input type="hidden" name="sandbox" value="{{ $sandbox->id() }} >
    <button>Run</button>
  </form>
@endforeach

Make sure to add the prefix to the route name if you used a route name prefix.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages