Commit 6ed8975e authored by kay899's avatar kay899 Committed by Nicolas Widart

Using field name for both Media Blade Directives (#337)

* Update MediaSingleDirective.php

* Update MediaMultipleDirective.php

* Update new-file-link-single.blade.php

* Update new-file-link-multiple.blade.php
parent 255c93f2
......@@ -18,6 +18,10 @@ class MediaMultipleDirective
* @var string|null
*/
private $view;
/**
* @var string|null
*/
private $name;
public function show($arguments)
{
......@@ -27,12 +31,14 @@ class MediaMultipleDirective
view()->composer($view, PartialAssetComposer::class);
$zone = $this->zone;
$name = $this->name ?: ucwords(str_replace('_', ' ', $this->zone));
if ($this->entity !== null) {
$media = $this->entity->filesByZone($this->zone)->get();
}
return view($view, compact('media', 'zone'));
return view($view, compact('media', 'zone', 'name'));
}
/**
......@@ -44,5 +50,6 @@ class MediaMultipleDirective
$this->zone = array_get($arguments, 0);
$this->entity = array_get($arguments, 1);
$this->view = array_get($arguments, 2);
$this->name = array_get($arguments, 3);
}
}
......@@ -17,7 +17,11 @@ class MediaSingleDirective
/**
* @var string|null
*/
private $view;
private $view
/**
* @var string|null
*/
private $name;
public function show($arguments)
{
......@@ -27,12 +31,14 @@ class MediaSingleDirective
view()->composer($view, PartialAssetComposer::class);
$zone = $this->zone;
$name = $this->name ?: ucwords(str_replace('_', ' ', $this->zone));
if ($this->entity !== null) {
$media = $this->entity->filesByZone($this->zone)->first();
}
return view($view, compact('media', 'zone'));
return view($view, compact('media', 'zone', 'name'));
}
/**
......@@ -44,5 +50,6 @@ class MediaSingleDirective
$this->zone = array_get($arguments, 0);
$this->entity = array_get($arguments, 1);
$this->view = array_get($arguments, 2);
$this->name = array_get($arguments, 3);
}
}
<div class="form-group">
{!! Form::label($zone, ucwords(str_replace('_', ' ', $zone)) . ':') !!}
{!! Form::label($zone, $name) !!}
<div class="clearfix"></div>
<a class="btn btn-primary btn-upload" onclick="openMediaWindowMultiple(event, '{{ $zone }}')"><i class="fa fa-upload"></i>
{{ trans('media::media.Browse') }}
......
<div class="form-group">
{!! Form::label($zone, ucwords(str_replace('_', ' ', $zone)) . ':') !!}
{!! Form::label($zone, $name) !!}
<div class="clearfix"></div>
<a class="btn btn-primary btn-browse" onclick="openMediaWindowSingle(event, '{{ $zone }}');" <?php echo (isset($media->path))?'style="display:none;"':'' ?>><i class="fa fa-upload"></i>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment