我有下表:mysql数据库中的group_pages,页面名称为route name:
id name route
--------------------
0 About about
1 Contact contact
2 Blog blog
Run Code Online (Sandbox Code Playgroud)
我想要做的是在我的:routes.php中创建动态路由?
如果我去的例子:/about它会去AboutController.php(它将动态创建)可能吗?是否可以创建动态控制器文件?
我正在尝试创建链接到控制器的动态页面路由
例如,我想在我的动态生成这个 routes.php
Route::controller('about', 'AboutController');
Route::controller('contact', 'ContactController');
Route::controller('blog', 'BlogController');
Run Code Online (Sandbox Code Playgroud) 我正在使用Laravel 5开发应用程序.我的应用程序与VendHQ API相关联,我打算通过他们的webhook从VendHQ获取一些数据.根据他们的文档
当事件发生并触发webhook时,我们会向您选择的URL发送POST请求.POST请求将采用UTF-8字符集和application/x-www-form-urlencoded编码.
问题是,当他们尝试向我的Laravel应用程序发送POST请求时,他们的帖子请求中没有添加CSRF令牌,VerifyCsrfToken中间件正在寻找令牌,最后它会抛出一个TokenMismatchException.
我的问题是,如何VerifyCsrfToken在保持其他帖子请求有效的同时避免某些特定路由的默认中间件?
我在新的Laravel,并试图通过编码学习.我创建了迁移和种子,当我从终端调用它们时工作正常,但是我想在我的HomeController中尝试这个代码,我得到了一个很大的错误.
错误
FatalErrorException in HomeController.php line 23:
Class 'App\Http\Controllers\Artisan' not found
Run Code Online (Sandbox Code Playgroud)
家庭控制器中的代码
$hasTable = Schema::hasTable('users');
if ($hasTable==0)
{
echo "call cli to migration and seed";
$migrate = Artisan::call('migrate');
$seed = Artisan::call('db:seed');
echo "Migrate<br>";
print_r($migrate);
echo "Seed<br>";
print_r($seed);
}
Run Code Online (Sandbox Code Playgroud)
我相信,如果我加载正确的命名空间,我可以避免这个错误,但我不确定.
我试图用Webpack做一个简单的Bootstrap和Font-awesome.我设法加载Bootstrap CSS但Font-awesome无法正常工作.
这就是我得到的结果:
我的代码如下.我在这做什么错了?
资源:这里有Github代码.
的package.json
{
"name": "",
"version": "0.0.1",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "webpack -w"
},
"license": "MIT",
"devDependencies": {
"css-loader": "^0.21.0",
"expose-loader": "^0.7.0",
"file-loader": "^0.8.4",
"style-loader": "^0.13.0",
"url-loader": "^0.5.6",
"webpack": "^1.12.2"
},
"dependencies": {
"admin-lte": "^2.3.2",
"bootstrap": "^3.3.5",
"bootstrap-webpack": "0.0.5",
"exports-loader": "^0.6.2",
"extract-text-webpack-plugin": "^0.8.2",
"font-awesome": "^4.4.0",
"font-awesome-webpack": "0.0.4",
"imports-loader": "^0.6.5",
"jquery": "^2.1.4",
"less": "^2.5.3",
"less-loader": "^2.2.1"
}
}
Run Code Online (Sandbox Code Playgroud)
入口点: …
javascript font-awesome twitter-bootstrap-3 webpack webpack-style-loader
在维护SOLID原则的同时,我对使用Controller with Repository Pattern感到困惑.考虑一下,我有两种类型的报价
并且未来很有可能出现新类型的报价.每个报价都有不同的字段,业务逻辑,但它们共享许多常用功能.所以我创建了一个QuotationInterface
报价界面
interface QuotationInterface
{
public function save(array $data);
}
Run Code Online (Sandbox Code Playgroud)
实现接口的报价类
class CommercialQuotation implements QuotationInterface
{
public function(array $data)
{
// save commercial quotation
}
}
class PrivateQuotation implements QuotationInterface
{
public function(array $data)
{
// save Private quotation
}
}
Run Code Online (Sandbox Code Playgroud)
报价库
class QuotationRepository
{
public function save(array $data, QuotationInterface $quotation)
{
$quotation->save($data);
}
}
Run Code Online (Sandbox Code Playgroud)
QotationController
public function store(Resource $resource)
{
$inputs = $resource->all();
/**
* Clearly here Open/Close Principle is broken
*/
if …Run Code Online (Sandbox Code Playgroud) 我使用angularjs来调用Asp.net Web API.从表中删除一行后?
我也没有在w3schools找到解决方案.
我的HTML代码
<tr ng-repeat="user in users | filter: search">
<td>{{ user.Id }}</td>
<td>{{ user.FullName }}</td>
<td>{{ user.Mobile }}</td>
<td>{{ user.Birthdate }}</td>
<td>{{ user.Gender }}</td>
<td>{{ user.AcademicLevel }}</td>
<td>
Run Code Online (Sandbox Code Playgroud)
我的Angularjs代码
$scope.DeleteUser = function (id) {
UserID = $scope.users[id].Id;
$http.delete('/api/users/' + UserID).success(function (data) {
(function (data) {
$scope.error = "error " + data;
});
}
Run Code Online (Sandbox Code Playgroud)
我在Stackoverflow中搜索过,我发现其中一些不适合我的地方,他们让我很困惑.
$scope.refresh()
$scope.apply();
Run Code Online (Sandbox Code Playgroud) 我正在使用cc-avenue套件集成zend.我使用了cc-avenue提供的代码,但是当我尝试从我的网站结账时,它会出错
Code: 10002 Merchant Authentication failed.
Don't worry... It happens to the best of us.
Run Code Online (Sandbox Code Playgroud)
在cc-avenue网址中.
当我滚动时,我尝试浮动 2 个 div,但只会在左侧 div 的顶部显示右侧 div。知道如何解决这个问题吗?
超文本标记语言
<body>
<div id="scroller-left">Some controls left</div>
<div id="scroller-right">Some controls right</div>
</body>
Run Code Online (Sandbox Code Playgroud)
CSS
body{
height:2000px;
width: 100%;
margin:0;
padding:0;
}
#scroller-left{
float: left;
background:#CCC;
}
#scroller-right{
float: right;
background:#CCC;
}
Run Code Online (Sandbox Code Playgroud)
JavaScript
$(window).load(function(){
$(window).scroll(function(){
if($(window).scrollTop()>10){
$('#scroller-left').css('position', 'fixed');
$('#scroller-left').css('top', 0);
$('#scroller-right').css('position', 'fixed');
$('#scroller-right').css('top', 0);
} else {
$('#scroller-left').css('position', 'relative');
$('#scroller-left').css('top', 0);
$('#scroller-right').css('position', 'relative');
$('#scroller-right').css('top', 0);
}
});
});
Run Code Online (Sandbox Code Playgroud)
Jsfiddle
https://jsfiddle.net/q0fa81hf
谢谢。
我是ReactJS的新手,并从React开始我的第一个应用程序。我一直在观看视频并浏览各种教程,最后设法通过Login搭建了我的第一个ReactRedux应用程序。
我已经使用了ReactTraining网站的AuthWorkflow示例。他们在那里使用了一个PrivateRoute组件来保护受保护的路由。我已经实现了它及其工作。
问题:
现在我无法将任何自定义数据或类似用户数据发送到受保护的路由。如何发送?
码
import React from "react";
import {
BrowserRouter as Router,
Route,
Link,
Redirect,
withRouter
} from "react-router-dom";
////////////////////////////////////////////////////////////
// 1. Click the public page
// 2. Click the protected page
// 3. Log in
// 4. Click the back button, note the URL each time
const AuthExample = () => (
<Router>
<div>
<AuthButton />
<ul>
<li>
<Link to="/public">Public Page</Link>
</li>
<li>
<Link to="/protected">Protected Page</Link>
</li>
</ul>
<Route path="/public" component={Public} />
<Route …Run Code Online (Sandbox Code Playgroud) 码
Entry::updateOrCreate([
'intern_id'=>$intern['id'],
'created_at'=>Carbon::parse($input['date'])
],[
'company_id'=>$intern['supervisor']['company']['id'],
'content'=>$input['text']
]);
Run Code Online (Sandbox Code Playgroud)
我正在使用此代码尝试更新/创建新记录。假设首先匹配intern_id并匹配create_at列。如果找到,它将创建一个新的。但是,似乎总是在创建一个新值,当它创建一个新值时,company_idand intern_id列设置为0,而不是原始值。
注意:intern_id还是created_at不是PK列。注意2:created_at是日期类型,而不是日期时间
laravel ×5
php ×5
javascript ×3
laravel-5 ×3
ajax ×1
angularjs ×1
api ×1
artisan ×1
ccavenue ×1
dry ×1
font-awesome ×1
jquery ×1
laravel-4 ×1
namespaces ×1
oop ×1
paypal ×1
react-router ×1
reactjs ×1
redux ×1
webpack ×1