Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.buildpath
.idea
.project
.settings
bin
composer.lock
composer.phar
vendor
81 changes: 43 additions & 38 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,41 +1,46 @@
{
"name": "xatta-trone/laravel-backup-ui",
"description": ":package_description",
"license": "MIT",
"authors": [
{
"name": "Author Name",
"email": "author@email.com",
"homepage": "http://author.com"
}
],
"homepage": "https://github.com/xatta-trone/laravel-backup-ui",
"keywords": ["Laravel", "LaravelBackupUi"],
"require": {
"illuminate/support": "~9"
},
"require-dev": {
"phpunit/phpunit": "~9.0",
"orchestra/testbench": "~7"
},
"autoload": {
"psr-4": {
"XattaTrone\\LaravelBackupUi\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"XattaTrone\\LaravelBackupUi\\Tests\\": "tests"
}
},
"extra": {
"laravel": {
"providers": [
"XattaTrone\\LaravelBackupUi\\LaravelBackupUiServiceProvider"
],
"aliases": {
"LaravelBackupUi": "XattaTrone\\LaravelBackupUi\\Facades\\LaravelBackupUi"
}
}
"name": "xatta-trone/laravel-backup-ui",
"description": "Manage your laravel-backups from one place",
"license": "MIT",
"authors": [
{
"name": "Monzurul Islam",
"email": "monzurul.ce.buet@gmail.com",
"homepage": "https://github.com/Xatta-Trone"
}
],
"homepage": "https://github.com/xatta-trone/laravel-backup-ui",
"keywords": [
"Laravel",
"Laravel-backup",
"Laravel-backup-ui"
],
"require": {
"php": "^7.4|^8.0",
"illuminate/support": "^8.0"
},
"require-dev": {
"orchestra/testbench": "^6.0",
"phpunit/phpunit": "^9.0"
},
"autoload": {
"psr-4": {
"XattaTrone\\LaravelBackupUi\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"XattaTrone\\LaravelBackupUi\\Tests\\": "tests"
}
},
"extra": {
"laravel": {
"providers": [
"XattaTrone\\LaravelBackupUi\\LaravelBackupUiServiceProvider"
],
"aliases": {
"LaravelBackupUi": "XattaTrone\\LaravelBackupUi\\Facades\\LaravelBackupUi"
}
}
}
}
47 changes: 45 additions & 2 deletions config/laravel-backup-ui.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,48 @@
<?php
/*
|--------------------------------------------------------------------------
| Laravel Backup UI Configuration
|--------------------------------------------------------------------------
|
| The following options are configured for the Laravel Backup UI.
|
*/

return [
//
];
/*
|--------------------------------------------------------------------------
| Route Prefix
|--------------------------------------------------------------------------
|
| The prefix used in all available routes. Default set to laravel-backups.
|--------------------------------------------------------------------------
|
*/

'route_prefix' => 'laravel-backups',

/*
|--------------------------------------------------------------------------
| Route Middleware
|--------------------------------------------------------------------------
|
| The middleware listed here will be assigned to every route
|--------------------------------------------------------------------------
|
*/
'route_middleware' => [],


/*
|--------------------------------------------------------------------------
| Theme
|--------------------------------------------------------------------------
|
| The theme used in all available views. Default set to bootstrap-4.
| Available options are: bootstrap-4, bootstrap-5, tailwind and semantic-ui.
|--------------------------------------------------------------------------
|
*/

'theme' => 'bootstrap-4',
];
22 changes: 19 additions & 3 deletions license.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
# The license
The MIT License (MIT)

Copyright (c) Author Name <author@email.com>
Copyright (c) Spatie bvba <info@spatie.be>

...Add your license text here...
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
55 changes: 45 additions & 10 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
# LaravelBackupUi
# Laravel Backup UI

[![Latest Version on Packagist][ico-version]][link-packagist]
[![Total Downloads][ico-downloads]][link-downloads]
[![Build Status][ico-travis]][link-travis]
[![StyleCI][ico-styleci]][link-styleci]
### Manage your laravel backups from one place

This is where your description should go. Take a look at [contributing.md](contributing.md) to see a to do list.
[![MIT Licensed](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE.md)
[![Total Downloads](https://img.shields.io/packagist/dt/xatta-trone/laravel-backup-ui.svg?style=flat-square)](https://packagist.org/packages/xatta-trone/laravel-backup-ui)


### Features

- 📂 **View all the Laravel backups** in your application,
- 🎚 **Filter** by disk type, timestamp, pagination
- and more...


### Requirements

- **PHP 8.0+**
- **Laravel 8+**

## Installation

Expand All @@ -15,7 +26,32 @@ Via Composer
composer require xatta-trone/laravel-backup-ui
```

## Usage
### Usage

Once the installation is complete, you will be able to access **Log Viewer** directly in your browser.

By default, the application is available at: `{APP_URL}/laravel-backups`.

(for example: `https://my-app.test/laravel-backups`)

## Advanced usage
### Customize view
Publish `log.blade.php` into `/resources/views/vendor/laravel-log-viewer/` for view customization:

```bash
php artisan vendor:publish \
--provider="XattaTrone\LaravelBackupUi\LaravelBackupUiServiceProvider" \
--tag=laravel-backup-ui.views
```

### Edit configuration
Publish `logviewer.php` configuration file into `/config/` for configuration customization:

```bash
php artisan vendor:publish \
--provider="XattaTrone\LaravelBackupUi\LaravelBackupUiServiceProvider" \
--tag=laravel-backup-ui.config
```

## Change log

Expand All @@ -33,11 +69,11 @@ Please see [contributing.md](contributing.md) for details and a todolist.

## Security

If you discover any security related issues, please email author@email.com instead of using the issue tracker.
If you discover any security related issues, please email monzurul.ce.buet@gmail.com instead of using the issue tracker.

## Credits

- [Author Name][link-author]
- [Monzurul Islam][link-author]
- [All Contributors][link-contributors]

## License
Expand All @@ -52,6 +88,5 @@ MIT. Please see the [license file](license.md) for more information.
[link-packagist]: https://packagist.org/packages/xatta-trone/laravel-backup-ui
[link-downloads]: https://packagist.org/packages/xatta-trone/laravel-backup-ui
[link-travis]: https://travis-ci.org/xatta-trone/laravel-backup-ui
[link-styleci]: https://styleci.io/repos/12345678
[link-author]: https://github.com/xatta-trone
[link-contributors]: ../../contributors
68 changes: 68 additions & 0 deletions src/Http/Controllers/BackupController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<?php

namespace XattaTrone\LaravelBackupUi\Http\Controllers;

use Exception;
use Illuminate\Support\Facades\Session;
use Illuminate\Support\Facades\Storage;
use Illuminate\Pagination\LengthAwarePaginator;
use XattaTrone\LaravelBackupUi\Services\LaravelBackupUiService;
use XattaTrone\LaravelBackupUi\Http\Requests\LaravelBackupUiIndexRequest;
use XattaTrone\LaravelBackupUi\Http\Requests\LaravelBackupUiDownloadRequest;

class BackupController extends Controller
{
public $dir;
public $disks;
public function __construct()
{
$this->dir = config('backup.backup.name');
$this->disks = config('backup.backup.destination.disks', ['local']);
}

public function index(LaravelBackupUiIndexRequest $request)
{
$disk = $request->input('disk') ?: $this->disks[0];

$results = LaravelBackupUiService::getBackups(
$disk,
$this->dir,
$request->input('page'),
$request->input('per_page'),
$request->input('sort'),
);

$paginate = new LengthAwarePaginator(
$results['items'],
$results['total_items'],
$request->input('per_page'),
LengthAwarePaginator::resolveCurrentPage(),
array('path' => LengthAwarePaginator::resolveCurrentPath())
);
return view(
'xatta-trone::laravel-backups.' . config('laravel-backup-ui.theme', 'bootstrap-4'),
['paginate' => $paginate, 'disks' => $this->disks]
);
}

public function download(LaravelBackupUiDownloadRequest $request)
{
try {
$subPath = $this->dir . '/' . $request->input('filename');
return Storage::disk($request->input('disk'))->download($subPath);
} catch (Exception $e) {
return redirect()->back()->with('danger', 'Error downloading file: ' . $e->getMessage());
}
}

public function destroy(LaravelBackupUiDownloadRequest $request)
{
try {
$subPath = $this->dir . '/' . $request->input('filename');
Storage::disk($request->input('disk'))->delete($subPath);
return redirect()->back()->with('success', 'File deleted successfully.');
} catch (Exception $e) {
return redirect()->back()->with('danger', 'Error deleting file: ' . $e->getMessage());
}
}
}
13 changes: 13 additions & 0 deletions src/Http/Controllers/Controller.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace XattaTrone\LaravelBackupUi\Http\Controllers;

use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;

class Controller extends BaseController
{
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
}
31 changes: 31 additions & 0 deletions src/Http/Requests/LaravelBackupUiDownloadRequest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

namespace XattaTrone\LaravelBackupUi\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class LaravelBackupUiDownloadRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}

/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'disk' => ['required', 'string'],
'filename' => ['required', 'string'],
];
}
}
Loading