¨4.0.1¨
This commit is contained in:
@@ -14,6 +14,7 @@ class SliderTabs extends Tabs
|
||||
*/
|
||||
protected $buttonOffset = false;
|
||||
|
||||
|
||||
/**
|
||||
* Make new tabs with groups.
|
||||
*
|
||||
@@ -27,6 +28,7 @@ class SliderTabs extends Tabs
|
||||
->add($this->settings());
|
||||
}
|
||||
|
||||
|
||||
private function slides()
|
||||
{
|
||||
return tap(new Tab('slides', trans('slider::sliders.tabs.slides')), function (Tab $tab) {
|
||||
@@ -36,6 +38,7 @@ class SliderTabs extends Tabs
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private function settings()
|
||||
{
|
||||
return tap(new Tab('settings', trans('slider::sliders.tabs.settings')), function (Tab $tab) {
|
||||
|
||||
@@ -23,6 +23,7 @@ class CreateSlidersTable extends Migration
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
|
||||
@@ -24,6 +24,7 @@ class CreateSliderTranslationsTable extends Migration
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
|
||||
@@ -26,6 +26,7 @@ class CreateSliderSlidesTable extends Migration
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
|
||||
@@ -26,6 +26,7 @@ class CreateSliderSlideTranslationsTable extends Migration
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
|
||||
@@ -18,6 +18,7 @@ class AddPositionToSliderSlidesTable extends Migration
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
|
||||
@@ -18,6 +18,7 @@ class RemoveFileIdFromSliderSlidesTable extends Migration
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
|
||||
@@ -18,6 +18,7 @@ class AddFileIdToSliderSlideTranslationsTable extends Migration
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
|
||||
@@ -18,6 +18,7 @@ class AddDirectionColumnToSliderSlideTranslationsTable extends Migration
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
|
||||
@@ -18,6 +18,7 @@ class AddSpeedColumnToSlidersTable extends Migration
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
|
||||
@@ -18,6 +18,7 @@ class AddFadeColumnToSlidersTable extends Migration
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
|
||||
@@ -11,13 +11,18 @@ class Slider extends Model
|
||||
{
|
||||
use Translatable;
|
||||
|
||||
/**
|
||||
* The attributes that are translatable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $translatedAttributes = ['name'];
|
||||
/**
|
||||
* The relations to eager load on every query.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $with = ['translations', 'slides'];
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
@@ -25,12 +30,19 @@ class Slider extends Model
|
||||
*/
|
||||
protected $fillable = ['speed', 'autoplay', 'autoplay_speed', 'fade', 'dots', 'arrows'];
|
||||
|
||||
/**
|
||||
* The attributes that are translatable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $translatedAttributes = ['name'];
|
||||
|
||||
public static function findWithSlides($id)
|
||||
{
|
||||
if (is_null($id)) {
|
||||
return;
|
||||
}
|
||||
|
||||
return Cache::tags("sliders.{$id}")
|
||||
->rememberForever(md5("sliders.{$id}:" . locale()), function () use ($id) {
|
||||
return static::with('slides')->find($id);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Perform any actions required after the model boots.
|
||||
@@ -45,47 +57,12 @@ class Slider extends Model
|
||||
});
|
||||
}
|
||||
|
||||
public function shouldAutoPlay()
|
||||
{
|
||||
return $this->autoplay ? 'true' : 'false';
|
||||
}
|
||||
|
||||
public function clearCache()
|
||||
{
|
||||
Cache::tags("sliders.{$this->id}")->flush();
|
||||
}
|
||||
|
||||
public static function findWithSlides($id)
|
||||
{
|
||||
if (is_null($id)) {
|
||||
return;
|
||||
}
|
||||
|
||||
return Cache::tags("sliders.{$id}")
|
||||
->rememberForever(md5("sliders.{$id}:" . locale()), function () use ($id) {
|
||||
return static::with('slides')->find($id);
|
||||
});
|
||||
}
|
||||
|
||||
public function slides()
|
||||
{
|
||||
return $this->hasMany(SliderSlide::class)->orderBy('position');
|
||||
}
|
||||
|
||||
public function getAutoplaySpeedAttribute($autoplaySpeed)
|
||||
{
|
||||
return $autoplaySpeed ?: 3000;
|
||||
}
|
||||
|
||||
public function table()
|
||||
{
|
||||
return new AdminTable($this->newQuery());
|
||||
}
|
||||
|
||||
/**
|
||||
* Save slides for the slider.
|
||||
*
|
||||
* @param array $slides
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function saveSlides($slides)
|
||||
@@ -104,6 +81,43 @@ class Slider extends Model
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function slides()
|
||||
{
|
||||
return $this->hasMany(SliderSlide::class)->orderBy('position');
|
||||
}
|
||||
|
||||
|
||||
public function clearCache()
|
||||
{
|
||||
Cache::tags("sliders.{$this->id}")->flush();
|
||||
}
|
||||
|
||||
|
||||
public function shouldAutoPlay()
|
||||
{
|
||||
return $this->autoplay ? 'true' : 'false';
|
||||
}
|
||||
|
||||
|
||||
public function getSpeedAttribute($speed)
|
||||
{
|
||||
return $speed ?: 1000;
|
||||
}
|
||||
|
||||
|
||||
public function getAutoplaySpeedAttribute($autoplaySpeed)
|
||||
{
|
||||
return $autoplaySpeed ?: 3000;
|
||||
}
|
||||
|
||||
|
||||
public function table()
|
||||
{
|
||||
return new AdminTable($this->newQuery());
|
||||
}
|
||||
|
||||
|
||||
private function getDeleteCandidates($slides = [])
|
||||
{
|
||||
return $this->slides()
|
||||
|
||||
@@ -10,30 +10,6 @@ class SliderSlide extends Model
|
||||
{
|
||||
use Translatable;
|
||||
|
||||
/**
|
||||
* The relations to eager load on every query.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $with = ['translations', 'file'];
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = ['options', 'call_to_action_url', 'open_in_new_window', 'position'];
|
||||
|
||||
/**
|
||||
* The attributes that should be cast to native types.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $casts = [
|
||||
'options' => 'array',
|
||||
'open_in_new_window' => 'boolean',
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes that are translatable.
|
||||
*
|
||||
@@ -46,17 +22,41 @@ class SliderSlide extends Model
|
||||
'direction',
|
||||
'call_to_action_text',
|
||||
];
|
||||
/**
|
||||
* The relations to eager load on every query.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $with = ['translations', 'file'];
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = ['options', 'call_to_action_url', 'open_in_new_window', 'position'];
|
||||
/**
|
||||
* The attributes that should be cast to native types.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $casts = [
|
||||
'options' => 'array',
|
||||
'open_in_new_window' => 'boolean',
|
||||
];
|
||||
|
||||
|
||||
public function isAlignedLeft()
|
||||
{
|
||||
return $this->direction === 'left';
|
||||
}
|
||||
|
||||
|
||||
public function isAlignedRight()
|
||||
{
|
||||
return $this->direction === 'right';
|
||||
}
|
||||
|
||||
|
||||
public function file()
|
||||
{
|
||||
return $this->belongsTo(File::class)->withDefault();
|
||||
|
||||
@@ -13,6 +13,7 @@ class SaveSliderRequest extends Request
|
||||
*/
|
||||
protected $availableAttributes = 'slider::attributes';
|
||||
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
|
||||
@@ -3,14 +3,11 @@
|
||||
namespace Modules\Slider\Providers;
|
||||
|
||||
use Modules\Slider\Admin\SliderTabs;
|
||||
use Modules\Support\Traits\AddsAsset;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Modules\Admin\Ui\Facades\TabManager;
|
||||
|
||||
class SliderServiceProvider extends ServiceProvider
|
||||
{
|
||||
use AddsAsset;
|
||||
|
||||
/**
|
||||
* Bootstrap the application services.
|
||||
*
|
||||
@@ -19,7 +16,5 @@ class SliderServiceProvider extends ServiceProvider
|
||||
public function boot()
|
||||
{
|
||||
TabManager::register('sliders', SliderTabs::class);
|
||||
|
||||
$this->addAdminAssets('admin.sliders.(create|edit)', ['admin.media.js', 'admin.slider.css', 'admin.slider.js']);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,11 +27,21 @@
|
||||
|
||||
span {
|
||||
font-size: 16px;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.btn {
|
||||
color: #737881;
|
||||
padding: 0;
|
||||
background: transparent;
|
||||
|
||||
i {
|
||||
-webkit-text-stroke: 1px #f6f6f7;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
color: #333333;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,8 +57,12 @@
|
||||
margin: 0;
|
||||
border: none;
|
||||
|
||||
a[data-toggle=tab] {
|
||||
a[data-toggle="tab"] {
|
||||
outline: none;
|
||||
|
||||
&:after {
|
||||
bottom: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -122,12 +136,12 @@
|
||||
position: relative;
|
||||
left: auto;
|
||||
top: auto;
|
||||
margin: 15px auto 30px;
|
||||
margin: 10px 0 15px;
|
||||
display: table;
|
||||
}
|
||||
|
||||
.slide-body .slide-tabs {
|
||||
margin: 0;
|
||||
margin-left: 0;
|
||||
clear: both;
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
@endcomponent
|
||||
|
||||
@section('content')
|
||||
<form method="POST" action="{{ route('admin.sliders.store') }}" class="form-horizontal" id="slider-create-form" novalidate>
|
||||
<form method="POST" action="{{ route('admin.sliders.store') }}" id="slider-create-form" class="form-horizontal" novalidate>
|
||||
{{ csrf_field() }}
|
||||
|
||||
{!! $tabs->render(compact('slider')) !!}
|
||||
@@ -16,3 +16,12 @@
|
||||
@endsection
|
||||
|
||||
@include('slider::admin.sliders.partials.shortcuts')
|
||||
|
||||
@push('globals')
|
||||
@vite([
|
||||
'Modules/Slider/Resources/assets/admin/sass/main.scss',
|
||||
'Modules/Slider/Resources/assets/admin/js/main.js',
|
||||
'Modules/Media/Resources/assets/admin/sass/main.scss',
|
||||
'Modules/Media/Resources/assets/admin/js/main.js',
|
||||
])
|
||||
@endpush
|
||||
@@ -18,3 +18,10 @@
|
||||
@endsection
|
||||
|
||||
@include('slider::admin.sliders.partials.shortcuts')
|
||||
|
||||
@push('globals')
|
||||
@vite([
|
||||
'Modules/Slider/Resources/assets/admin/sass/main.scss',
|
||||
'Modules/Slider/Resources/assets/admin/js/main.js',
|
||||
])
|
||||
@endpush
|
||||
@@ -24,7 +24,7 @@
|
||||
@endcomponent
|
||||
|
||||
@push('scripts')
|
||||
<script>
|
||||
<script type="module">
|
||||
new DataTable('#sliders-table .table', {
|
||||
columns: [
|
||||
{ data: 'checkbox', orderable: false, searchable: false, width: '3%' },
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
@endpush
|
||||
|
||||
@push('scripts')
|
||||
<script>
|
||||
<script type="module">
|
||||
keypressAction([
|
||||
{ key: 'b', route: "{{ route('admin.sliders.index') }}" }
|
||||
]);
|
||||
|
||||
@@ -82,7 +82,7 @@
|
||||
|
||||
<select
|
||||
name="slides[<%- slideNumber %>][direction]"
|
||||
class="form-control"
|
||||
class="form-control custom-select-black"
|
||||
id="slides-<%- slideNumber %>-direction"
|
||||
value="<%- slide.direction %>"
|
||||
>
|
||||
|
||||
@@ -8,6 +8,12 @@ Route::get('sliders', [
|
||||
'middleware' => 'can:admin.sliders.index',
|
||||
]);
|
||||
|
||||
Route::get('sliders/index/table', [
|
||||
'as' => 'admin.sliders.table',
|
||||
'uses' => 'SliderController@table',
|
||||
'middleware' => 'can:admin.sliders.index',
|
||||
]);
|
||||
|
||||
Route::get('sliders/create', [
|
||||
'as' => 'admin.sliders.create',
|
||||
'uses' => 'SliderController@create',
|
||||
@@ -37,39 +43,3 @@ Route::delete('sliders/{ids?}', [
|
||||
'uses' => 'SliderController@destroy',
|
||||
'middleware' => 'can:admin.sliders.destroy',
|
||||
]);
|
||||
|
||||
Route::get('slider-options', [
|
||||
'as' => 'admin.slider_options.index',
|
||||
'uses' => 'SliderOptionController@index',
|
||||
'middleware' => 'can:admin.slider_options.index',
|
||||
]);
|
||||
|
||||
Route::get('slider-options/create', [
|
||||
'as' => 'admin.slider_options.create',
|
||||
'uses' => 'SliderOptionController@create',
|
||||
'middleware' => 'can:admin.slider_options.create',
|
||||
]);
|
||||
|
||||
Route::post('slider-options', [
|
||||
'as' => 'admin.slider_options.store',
|
||||
'uses' => 'SliderOptionController@store',
|
||||
'middleware' => 'can:admin.slider_options.create',
|
||||
]);
|
||||
|
||||
Route::get('slider-options/{id}/edit', [
|
||||
'as' => 'admin.slider_options.edit',
|
||||
'uses' => 'SliderOptionController@edit',
|
||||
'middleware' => 'can:admin.slider_options.edit',
|
||||
]);
|
||||
|
||||
Route::put('slider-options/{id}', [
|
||||
'as' => 'admin.slider_options.update',
|
||||
'uses' => 'SliderOptionController@update',
|
||||
'middleware' => 'can:admin.slider_options.edit',
|
||||
]);
|
||||
|
||||
Route::delete('slider-options/{ids?}', [
|
||||
'as' => 'admin.slider_options.destroy',
|
||||
'uses' => 'SliderOptionController@destroy',
|
||||
'middleware' => 'can:admin.slider_options.destroy',
|
||||
]);
|
||||
|
||||
Reference in New Issue
Block a user