Turned function findFile() into helper function
This commit is contained in:
parent
09c9bec168
commit
b9a371b924
|
@ -0,0 +1,12 @@
|
|||
<?php
|
||||
|
||||
function findFile($name){
|
||||
$directory = base_path('/littlelink/images/');
|
||||
$files = scandir($directory);
|
||||
$pathinfo = "error.error";
|
||||
foreach($files as $file) {
|
||||
if (strpos($file, $name.'.') !== false) {
|
||||
$pathinfo = $name. "." . pathinfo($file, PATHINFO_EXTENSION);
|
||||
}}
|
||||
return $pathinfo;
|
||||
}
|
|
@ -30,6 +30,9 @@
|
|||
"phpunit/phpunit": "^9.3.3"
|
||||
},
|
||||
"autoload": {
|
||||
"files": [
|
||||
"app/Functions/findfile.php"
|
||||
],
|
||||
"psr-4": {
|
||||
"App\\": "app/",
|
||||
"Database\\Factories\\": "database/factories/",
|
||||
|
|
|
@ -5,19 +5,6 @@
|
|||
<html lang="en">
|
||||
@endif
|
||||
|
||||
@php
|
||||
function findFile($name){
|
||||
$directory = base_path('/littlelink/images/');
|
||||
$files = scandir($directory);
|
||||
$pathinfo = "error.error";
|
||||
foreach($files as $file) {
|
||||
if (strpos($file, $name.'.') !== false) {
|
||||
$pathinfo = $name. "." . pathinfo($file, PATHINFO_EXTENSION);
|
||||
}}
|
||||
return $pathinfo;
|
||||
}
|
||||
@endphp
|
||||
|
||||
{{-- Redirects to https if enabled in the advanced-config --}}
|
||||
@if(env('FORCE_ROUTE_HTTPS') == 'true')
|
||||
@php
|
||||
|
|
|
@ -1,16 +1,5 @@
|
|||
@extends('layouts.sidebar')
|
||||
|
||||
@php
|
||||
function findFiles($name){
|
||||
$directory = base_path('/littlelink/images/');
|
||||
$files = scandir($directory);
|
||||
$pathinfo = "error.error";
|
||||
foreach($files as $file) {
|
||||
if (strpos($file, $name.'.') !== false) {
|
||||
$pathinfo = $name. "." . pathinfo($file, PATHINFO_EXTENSION);}}
|
||||
return $pathinfo;}
|
||||
@endphp
|
||||
|
||||
@section('content')
|
||||
|
||||
<section class="shadow text-gray-400">
|
||||
|
|
|
@ -3,18 +3,7 @@
|
|||
@section('content')
|
||||
|
||||
<script src="{{ asset('resources/ckeditor/ckeditor.js') }}"></script>
|
||||
@php
|
||||
function findFileSite($name){
|
||||
$directory = base_path('/littlelink/images/');
|
||||
$files = scandir($directory);
|
||||
$pathinfo = "error.error";
|
||||
foreach($files as $file) {
|
||||
if (strpos($file, $name.'.') !== false) {
|
||||
$pathinfo = $name. "." . pathinfo($file, PATHINFO_EXTENSION);
|
||||
}}
|
||||
return $pathinfo;
|
||||
}
|
||||
@endphp
|
||||
|
||||
<section class="shadow text-gray-400">
|
||||
<h2 class="mb-4 card-header"><i class="bi bi-person"> Site</i></h2>
|
||||
<div class="card-body p-0 p-md-3">
|
||||
|
@ -22,11 +11,11 @@ function findFileSite($name){
|
|||
<form action="{{ route('editSite') }}" enctype="multipart/form-data" method="post">
|
||||
@csrf
|
||||
<div class="form-group col-lg-8">
|
||||
<label>Site logo</label>@if(file_exists(base_path("littlelink/images/").findFileSite('avatar')))<a title="Remove icon" class="hvr-grow p-1 text-danger" style="padding-left:5px;" href="{{ route('delAvatar') }}"><i class="bi bi-trash-fill"></i></a>@endif
|
||||
<label>Site logo</label>@if(file_exists(base_path("littlelink/images/").findFile('avatar')))<a title="Remove icon" class="hvr-grow p-1 text-danger" style="padding-left:5px;" href="{{ route('delAvatar') }}"><i class="bi bi-trash-fill"></i></a>@endif
|
||||
<input type="file" class="form-control-file" name="image">
|
||||
</div>
|
||||
<div class="form-group col-lg-8">
|
||||
<label>Favicon</label>@if(file_exists(base_path("littlelink/images/").findFileSite('favicon')))<a title="Remove icon" class="hvr-grow p-1 text-danger" style="padding-left:5px;" href="{{ route('delFavicon') }}"><i class="bi bi-trash-fill"></i></a>@endif
|
||||
<label>Favicon</label>@if(file_exists(base_path("littlelink/images/").findFile('favicon')))<a title="Remove icon" class="hvr-grow p-1 text-danger" style="padding-left:5px;" href="{{ route('delFavicon') }}"><i class="bi bi-trash-fill"></i></a>@endif
|
||||
<input type="file" class="form-control-file" name="icon">
|
||||
</div>
|
||||
<div class="form-group col-lg-8">
|
||||
|
|
Loading…
Reference in New Issue