public function run()
 {
     $faker = Faker::create();
     foreach (range(1, 10) as $index) {
         Resource::create([]);
     }
 }
 public function run()
 {
     $tableresource = "resource";
     $tablegroupresource = "group_resource";
     $resources = [["pattern" => "/stock", "name" => "stock/index", "target" => "StockController@indexAction", "secure" => true], ["pattern" => "/stock/add", "name" => "stock/add", "target" => "StockController@addAction", "secure" => true], ["pattern" => "/stock/edit", "name" => "stock/edit", "target" => "StockController@editAction", "secure" => true], ["pattern" => "/stock/delete", "name" => "stock/delete", "target" => "StockController@deleteAction", "secure" => true], ["pattern" => "/stock/addrow", "name" => "stock/addrow", "target" => "StockController@addrowAction", "secure" => true]];
     foreach ($resources as $resource) {
         DB::unprepared('ALTER TABLE ' . $tableresource . ' AUTO_INCREMENT = 1');
         DB::unprepared('ALTER TABLE ' . $tablegroupresource . ' AUTO_INCREMENT = 1');
         $r = Resource::create($resource);
         $id = Group::where('id', '=', 1)->first()->id;
         $r->groups()->attach(array($id));
     }
 }
Example #3
0
 public function testUrlVisit()
 {
     $uri = 'foo/bar/url-testing';
     $newUri = 'foo/new-url-testing';
     $title = 'URL testing';
     $resource = Resource::create(['title' => $title, 'uri' => $uri]);
     $response = $this->call('GET', '/' . $uri);
     $this->assertEquals($title, $response->getContent(), 'Invalid response from controller.');
     $resource->uri = $newUri;
     $resource->save();
     $response = $this->call('GET', '/' . $uri);
     $this->assertRedirectedTo('/' . $newUri);
     $this->setExpectedException('Symfony\\Component\\HttpKernel\\Exception\\NotFoundHttpException');
     $response = $this->call('GET', '/foo/bar');
 }
Example #4
0
 if (!$cancel) {
     $error = '';
     $ref = GETPOST('ref', 'alpha');
     $description = GETPOST('description', 'alpha');
     $fk_code_type_resource = GETPOST('fk_code_type_resource', 'alpha');
     if (empty($ref)) {
         $mesg = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Ref"));
         setEventMessage($mesg, 'errors');
         $error++;
     }
     if (!$error) {
         $object = new Resource($db);
         $object->ref = $ref;
         $object->description = $description;
         $object->fk_code_type_resource = $fk_code_type_resource;
         $result = $object->create($user);
         if ($result > 0) {
             // Creation OK
             $db->commit();
             setEventMessage($langs->trans('ResourceCreatedWithSuccess'));
             Header("Location: card.php?id=" . $object->id);
             return;
         } else {
             // Creation KO
             setEventMessage($object->error, 'errors');
             $action = '';
         }
     } else {
         $action = '';
     }
 } else {
Example #5
0
require_once 'Helper.php';
require_once 'routes/news.php';
require_once 'routes/tags.php';
require_once 'routes/resource.php';
require_once 'routes/category.php';
require_once 'routes/photo.php';
\Slim\Slim::registerAutoloader();
$app = new \Slim\Slim();
$app->group('/news', function () use($app) {
    News::create($app);
});
$app->group('/tags', function () use($app) {
    Tags::create($app);
});
$app->group('/resources', function () use($app) {
    Resource::create($app);
});
$app->group('/category', function () use($app) {
    Category::create($app);
});
$app->group('/album', function () use($app) {
    Photo::create($app);
});
$app->get('/ninja', function () use($app) {
    chdir('../ninja');
    $ninja = glob('*');
    $res = array();
    foreach ($ninja as $n) {
        array_push($res, ['name' => $n, 'url' => "/ninja/{$n}/"]);
    }
    echo json_encode($res);