Ejemplo n.º 1
0
<?php

use Illuminate\Support\Facades\Input;
Route::group(['prefix' => '/admin/zaweb/gallery/', 'before' => 'authenticate'], function () {
    Route::post('photos/upload', function () {
        $model = new Zaweb\Gallery\Models\Attachment();
        $file = new System\Models\File();
        $file->data = Input::file('upl');
        $file->save();
        $model->photo()->add($file);
        $model->path = $model->photo->getPath();
        $model->save();
        return ['path' => $model->photo->getPath(), 'attachment_id' => $model->id];
    });
});
Ejemplo n.º 2
0
 /**
  * Save file attachment and set `attachment::ID`.
  *
  * @param array &$data List request data
  */
 protected function saveAttachments(array &$data)
 {
     foreach ($data as $key => $value) {
         if ($value instanceof \Symfony\Component\HttpFoundation\File\UploadedFile) {
             $file = new \System\Models\File();
             $file->data = $value;
             $file->save();
             $data[$key] = "attachment::{$file->id}";
         }
     }
 }