示例#1
0
 public function setup(Router $router)
 {
     // Need to be loaded first.
     $this->route('cms', function ($router) {
         $router->get('/', 'IndexController@index');
         $router->get('logout', 'Auth\\AuthController@logout');
         $router->get('login', 'Auth\\AuthController@index');
         $router->post('login', 'Auth\\AuthController@authenticate');
     });
     // API route to show that it's there.
     $this->route('api', function ($router) {
         $router->get('/', 'REST\\ModelController@index');
         $router->get('/{model}', 'REST\\ModelController@fetchAll')->middleware(['model']);
         $router->get('/{model}/{id}', 'REST\\ModelController@fetch')->middleware(['model']);
         $router->post('/{model}', 'REST\\ModelController@create')->middleware(['auth', 'model']);
         $router->put('/{model}/{id}', 'REST\\ModelController@update')->middleware(['auth', 'model']);
         $router->delete('/{model}/{id}', 'REST\\ModelController@destroy')->middleware(['auth', 'model']);
     });
     // Media uploading routes and controller.
     $this->route('cms', function ($router) {
         $router->post(Media::getLabel('slug') . '/upload', ['as' => 'mediaUpload', 'uses' => 'MediaController@upload']);
         $router->get(Media::getLabel('slug') . '/list', ['as' => 'mediaList', 'uses' => 'MediaController@select']);
     });
     $this->basicSetup();
 }
示例#2
0
 /**
  * Execute the console command.
  * @return mixed
  */
 public function handle()
 {
     $media = Media::all();
     foreach ($media as $item) {
         $item->delete();
     }
     $status = Site::handleImport(glob($this->importPath . DS . "*"));
     echo "Import complete.\n";
     echo $status;
 }
示例#3
0
 /**
  * Execute the console command.
  * @return mixed
  */
 public function handle()
 {
     // Delete media from the database and from the uploads directory.
     if (Schema::hasTable('media')) {
         $media = Media::all();
         $media->each(function ($item) {
             $item->delete();
         });
     }
     $this->call('migrate:reset');
     $this->call('birdmin:launch');
 }
 /**
  * Reverse the migrations.
  * @return void
  */
 public function down()
 {
     Media::blueprint()->dropSchema();
 }
示例#5
0
 /**
  * Generate a new manipulated file, such as a crop.
  * @param $name string directory
  * @param callable $callable  ($image)
  * @return \Exception|null|int
  */
 public function generate($name, callable $callable)
 {
     if (!$this->isImage()) {
         return null;
     }
     $path = Media::basePath($name);
     if (!file_exists($path)) {
         mkdir($path, 0755);
     }
     try {
         $img = Image::make($this->path());
         $callable($img);
     } catch (\Exception $error) {
         return $error;
     }
     return $img ? $img->save($path . $this->file_name) : null;
 }
示例#6
0
 /**
  * POST and Upload the media.
  * @param Request $request
  * @return \Illuminate\Http\Response
  */
 public function upload(Request $request)
 {
     $objects = new MediaCollection();
     foreach ($request->files->all() as $uploadedFile) {
         $objects[] = Media::upload($uploadedFile);
     }
     foreach ((array) $request->input('relate') as $parentObjectName) {
         $objects->attach($parentObjectName);
     }
     return $objects;
 }