Skip to content

Commit

Permalink
added media to setting
Browse files Browse the repository at this point in the history
  • Loading branch information
A1Gard committed Apr 10, 2024
1 parent 0abc96c commit ef29ae0
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 10 deletions.
9 changes: 5 additions & 4 deletions app/Http/Controllers/Admin/SettingController.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,11 @@ public function update(Request $request) {
$files = $request->allFiles();
if (isset($files['pic'])) {
foreach ($files['pic'] as $index => $file) {
// $name = time() . '.' . $file->getClientOriginalExtension();
// Setting::where('key',$key)->update(['value' => $name]);
// $request->file($index)->storeAs('public/setting', $name);
$file->move(public_path('/images/'), str_replace('_','.',$index) );//store('/images/'.,['disk' => 'public']);
if ($file->extension() == 'mp4' || $file->extension() == 'mp3'){
$file->move(public_path('/assets/file/'), str_replace('_','.',$index) );//store('/images/'.,['disk' => 'public']);
}else{
$file->move(public_path('/images/'), str_replace('_','.',$index) );//store('/images/'.,['disk' => 'public']);
}
}
}
return redirect()->back()->with(['message' => __('Setting of website updated')]);
Expand Down
3 changes: 2 additions & 1 deletion resources/lang/fa.json
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@
"Main product category": "دسته اصلی محصول",
"Manage": "مدیریت",
"Max click": "حداکثر تعداد کلیک",
"Media": "رسانه",
"Menu": "فهرست\/منو",
"Menus": "فهرست‌ها",
"Menus list": "فهرست منوها",
Expand Down Expand Up @@ -632,4 +633,4 @@
"user": "کاربر",
"weight": "وزن",
"yesterday": "دیروز"
}
}
1 change: 1 addition & 0 deletions resources/lang/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@
"Main product category": "«Основная категория товаров»",
"Manage": "Управлять",
"Max click": "«Макс клик»",
"Media": "",
"Menu": "",
"Menus": "«Меню»",
"Menus list": "«Список меню»",
Expand Down
26 changes: 21 additions & 5 deletions resources/views/admin/setting.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,26 @@ class="ckeditorx form-control"
</select>
@break
@case('image')
<img src="{{asset('images/'.str_replace('_','.',$set->key))}}?{{time()}}"
class="img-fluid" style="max-height: 150px;max-width: 45%" alt="cover">
@if(pathinfo(str_replace('_','.',$set->key), PATHINFO_EXTENSION) == 'mp4')
<video controls
src="{{asset('assets/file/'.str_replace('_','.',$set->key))}}?{{time()}}"
class="img-fluid"
style="max-height: 150px;max-width: 45%"></video>
<br>
@elseif(pathinfo(str_replace('_','.',$set->key), PATHINFO_EXTENSION) == 'mp3')
<audio controls
src="{{asset('assets/file/'.str_replace('_','.',$set->key))}}?{{time()}}"
class="img-fluid"
style="max-height: 150px;max-width: 45%"></audio>
<br>
@else
<img
src="{{asset('images/'.str_replace('_','.',$set->key))}}?{{time()}}"
class="img-fluid" style="max-height: 150px;max-width: 45%"
alt="cover">
@endif
<input type="file" name="pic[{{$set->key}}]" id="{{$set->key}}"
accept="image/*"
accept=".{{pathinfo(str_replace('_','.',$set->key), PATHINFO_EXTENSION)}}"
class="form-control-file"/>
@break
@default
Expand Down Expand Up @@ -152,7 +168,7 @@ class="form-control @error('section') is-invalid @enderror"
<option value="checkbox"
@if (old('type') == 'checkbox' ) selected @endif >{{__("Checkbox")}} </option>
<option value="image"
@if (old('type') == 'image' ) selected @endif >{{__("Image")}} </option>
@if (old('type') == 'image' ) selected @endif >{{__("Media")}} </option>

</select>
</div>
Expand Down Expand Up @@ -189,7 +205,7 @@ class="form-control @error('section') is-invalid @enderror"
<script>
try {
document.querySelector('#price').classList.add('currency');
} catch(e) {
} catch (e) {
// console.log(e.message);
}
Expand Down

0 comments on commit ef29ae0

Please sign in to comment.