PHP code example of mimisk / stagebox

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

    

mimisk / stagebox example snippets


use Illuminate\Database\Eloquent\Relations\MorphMany;
use Mimisk\Stagebox\Models\Stagebox;

class Festival extends Model
{
    public function stageboxes(): MorphMany
    {
        return $this->morphMany(Stagebox::class, 'stageboxable');
    }
}

$festival->stageboxes()->create([
    'name' => 'A',
    'channels' => 12,
    'returns' => 4,
    'color' => 'black',
    'notes' => 'Drum Riser',
]);

$stagebox->stageboxable()->associate($festival);
$stagebox->save();

use Mimisk\Stagebox\Models\Stagebox;

$all = Stagebox::orderBy('name')->get();
$single = Stagebox::query()
    ->where('stageboxable_type', $festival->getMorphClass())
    ->where('stageboxable_id', $festival->getKey())
    ->where('slug', 'a')
    ->first();

public function destroy(Festival $festival): RedirectResponse
{
    $festival->stageboxes()->delete();
    $festival->delete();

    return redirect()
        ->route('festivals.index')
        ->with('status', 'Festival deleted.');
}
bash
php artisan migrate
bash
php artisan stagebox:clean-orphans