本文整理汇总了PHP中Resource::create方法的典型用法代码示例。如果您正苦于以下问题:PHP Resource::create方法的具体用法?PHP Resource::create怎么用?PHP Resource::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Resource
的用法示例。
在下文中一共展示了Resource::create方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
public function run()
{
$faker = Faker::create();
foreach (range(1, 10) as $index) {
Resource::create([]);
}
}
示例2: run
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));
}
}
示例3: testUrlVisit
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');
}
示例4: GETPOST
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 {
示例5: function
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);