Repository URL to install this package:
|
Version:
3.2.0 ▾
|
<?php
namespace Evsmash\Files\Http\Admin;
use Evsmash\Core\Http\Base;
use Evsmash\Core\Dec\Bar;
use Evsmash\Core\Helpers\View;
use Evsmash\Core\Files\Upload;
use Evsmash\Core\Input\Flash;
use Evsmash\Core\Input\Route;
use Evsmash\Core\Simpy\Element;
use Evsmash\Files\Attachment;
class Attachments extends Base {
// index
public function index() {
// elements
$elements = Attachment::params()->where('rel', Route::get('rel'))->get();
// bar
$bar = [
'summary' => $elements
];
$bar = Bar::shared($bar);
// view
$this->view(compact(['elements', 'bar']));
}
// add
public function add() {
// upload
$file = Upload::file(cfg('upload-files'));
// insert
$element = new Attachment;
$element->rel = Route::get('rel');
$element->file = $file->path;
$element->name = $file->name;
$element->type = $file->type;
$element->ext = $file->ext;
$element->sort = 1000;
$element->save();
}
// inline
public function inline() {
Element::inline(new Attachment, ['name', 'description']);
}
// thumb
public function thumb() {
// element
$element = Element::check(new Attachment);
// view
$this->view(compact(['element']));
}
// thumb upload
public function thumbUpload() {
// element
$element = Element::check(new Attachment);
// upload
$file = Upload::file(cfg('upload-files'));
// update
$element->thumb = $file->path;
$element->save();
}
// sort
public function sort() {
Element::sort(new Attachment);
}
// delete
public function delete() {
Element::delete(new Attachment);
}
}