Пример #1
0
 /**
  * A basic functional test example.
  *
  * @return void
  */
 public function testCreateResource()
 {
     $this->actingAs(User::find(1))->visit('admin/resources/create')->type('Events', 'title')->type('events', 'slug')->type('Laradev', 'namespace')->type('Models\\Event', 'model')->type('0', 'order_column')->type('asc', 'order_direction')->type('uk-icon-calendar', 'icon')->press('Save')->seePageIs('admin/resources/1/fields');
     $retrievedResource = Resource::find(1);
     $this->assertEquals('Events', $retrievedResource->title);
     $this->assertEquals('events', $retrievedResource->slug);
     $this->assertEquals('Laradev', $retrievedResource->namespace);
     $this->assertEquals('Models\\Event', $retrievedResource->model);
     $this->assertEquals('0', $retrievedResource->order_column);
     $this->assertEquals('asc', $retrievedResource->order_direction);
     $this->assertEquals('uk-icon-calendar', $retrievedResource->icon);
 }
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     $resources = Resource::with('fields')->get();
     $resources->filter(function ($resource) {
         return $resource->fields->contains(function ($key, $field) {
             return $field->type == 'images';
         });
     })->each(function ($resource, $key) {
         $resource->fields->filter(function ($field) {
             return $field->type == 'images';
         })->each(function ($field, $key) use($resource) {
             if ($this->belongsToManyMethodDoesNotExists($field)) {
                 throw new Exception('Method not defined');
             }
             $this->getEntities($field, $resource)->each(function ($entity, $key) use($field) {
                 $this->syncImageIds($entity, $field);
             });
         });
     });
 }
Пример #3
0
 Route::group(['prefix' => 'admin', 'middleware' => 'admin'], function () {
     Route::get('/', 'AdminController@index');
     Route::get('dashboard', 'AdminController@dashboard');
     Route::get('images/browser', 'ImagesController@imageBrowser');
     Route::post('images/upload', 'ImagesController@upload');
     Route::get('images', 'ImagesController@index');
     Route::post('images/search', 'ImagesController@search');
     Route::resource('images', 'ImagesController', ['except' => ['create', 'store', 'destroy']]);
     // Redirects
     Route::resource('redirects', 'RedirectsController');
     // RSS Feeds
     Route::resource('feeds', 'RssFeedsController', ['except' => ['show']]);
     // Users
     Route::resource('users', 'UsersController', ['except' => ['show']]);
     if (Schema::hasTable('resources')) {
         foreach (Resource::all() as $resource) {
             Route::resource($resource->slug, 'ResourcesController');
             Route::get('objects/{resource}/{resourceId}/{objects}/create', 'ResourceObjectsController@create');
             Route::post('objects/{resource}/{resourceId}/{objects}', 'ResourceObjectsController@store');
             Route::get('objects/{resource}/{resourceId}/{id}/edit', 'ResourceObjectsController@edit');
             Route::put('objects/{resource}/{resourceId}/{id}', 'ResourceObjectsController@update');
             Route::put('objects/reorder', 'ResourceObjectsController@reorder');
             Route::delete('objects/{id}', ['before' => 'ajax', 'uses' => 'ResourceObjectsController@destroy']);
         }
     }
     Route::get('resources/fields/getOptions/{type}', 'ResourceFieldController@getOptions');
     Route::get('resources/{resources}/fields/{fields}/edit', 'ResourceFieldController@edit');
     Route::put('resources/{resources}/fields/{fields}/edit', 'ResourceFieldController@update');
     Route::get('resources/{resources}/fields', 'ResourceFieldController@index');
     Route::get('resources/{resources}/fields/create', 'ResourceFieldController@create');
     Route::post('resources/{resources}/fields/create', 'ResourceFieldController@store');