PHP code example of blackpig-creatif / chambre-noir
1. Go to this page and download the library: Download blackpig-creatif/chambre-noir 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/ */
use BlackpigCreatif\ChambreNoir\Forms\Components\RetouchMediaUpload;
use App\BlackpigCreatif\ChambreNoir\Conversions\HeroConversion;
RetouchMediaUpload::make('hero_image')
->preset(HeroConversion::class)
->disk('public')
->directory('pages/hero')
->
use BlackpigCreatif\ChambreNoir\Concerns\HasRetouchMedia;
class Page extends Model
{
use HasRetouchMedia;
protected $casts = [
'hero_image' => 'array',
];
}
// Inherits from component's l attribution fields l
->attributionRequired(false)
// Granular control
->attributionRequired(['name' => true, 'link' => false])
// Dynamic
->attributionRequired(fn ($get) => $get('
$model->getAttribution('image') // ['name' => '...', 'link' => '...'] or null
$model->getAttributionName('image') // string or null
$model->getAttributionLink('image') // string or null
$model->hasAttribution('image') // bool
use BlackpigCreatif\ChambreNoir\Models\Gallery;
class Page extends Model
{
public function galleries(): \Illuminate\Database\Eloquent\Relations\MorphToMany
{
return $this->morphToMany(Gallery::class, 'galleryable')
->withPivot('sort_order')
->orderBy('galleryables.sort_order');
}
}
use BlackpigCreatif\ChambreNoir\Forms\Components\GalleryPickerField;
GalleryPickerField::make('galleries')
->multiple()
// Include unpublished galleries
GalleryPickerField::make('galleries')
->multiple()
->unpublished()
// Restrict to a specific conversion preset
GalleryPickerField::make('galleries')
->multiple()
->conversion('product')
use BlackpigCreatif\ChambreNoir\Concerns\HasRetouchMedia;
class HeroBlock extends BaseBlock
{
use HasRetouchMedia;
// ...
}