我正在尝试制作带有复选框的表格,管理员可以在其中检查多个产品并删除它们。到目前为止我已经制作了表格
@foreach($products as $product)
{{ Form::open() }}
<input type="checkbox" name="delete[]" value="{{ $product->product_id }}">
<a class="btn btn-primary" href="{{ URL::to('/admin/products/multiDdelete') }}?_token={{ csrf_token() }}">Delete</a>
{{ Form::close() }}
@endforeach
Run Code Online (Sandbox Code Playgroud)
这是我的路线
Route::get ('/admin/products/multiDdelete', ['uses' => 'AdminController@testDelete', 'before' => 'csrf|admin']);
Run Code Online (Sandbox Code Playgroud)
这在控制器中
public function testDelete() {
$delete = Input::only('delete')['delete'];
$pDel = Product::where('product_id', $delete);
$pDel->delete();
return Redirect::to('/admin/test')->with('message', 'Product(s) deleted.');
}
Run Code Online (Sandbox Code Playgroud)
到目前为止,当我检查产品并点击Delete页面重新加载时,我的产品已被删除,但产品并未被删除。我认为问题在于我如何通过ID's..但我无法弄清楚。
我正计划用PHP编写一个用于博客的视图计数.计数器的目的是指示博客文章的阅读频率,例如StackOverflow在问题页面上显示"浏览n次".
首先,我想将计数器数据存储在文件中,但通过研究,我改变了主意,将MySQL与几个InnoDB表一起使用,因为这些表的执行速度比硬盘查找速度快,从长远来看也不那么费力,而且本身也提供了有用的功能.
我坚持的问题是如何只为每个用户计算一次?
限制IP不是一种解决方案,因为动态IP和网络通常只有一个IP与所有连接的设备(例如学校,办公室,公共接入点)共享连接.
编辑:
受到fideloper的回答的启发,我正在研究基于会话的解决方案.
我已经在会话中使用单独的数据库表,所以我会按照建议将其合并到解决方案中.
这是我到目前为止(使用Laravel 4和Eloquent ORM):
SQL表设置:
--
-- Sessions Table
--
CREATE TABLE sessions (
id VARCHAR(255) NOT NULL COLLATE 'utf8_unicode_ci',
payload TEXT NOT NULL COLLATE 'utf8_unicode_ci',
last_activity INT(11) NOT NULL,
UNIQUE INDEX sessions_id_unique (id)
) COLLATE='utf8_unicode_ci' ENGINE=InnoDB;
--
-- Views Table
--
CREATE TABLE post_views (
id INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
post_id INT(11) UNSIGNED NOT NULL,
sess_id VARCHAR(255) NOT NULL COLLATE 'utf8_unicode_ci',
viewed_at TIMESTAMP NULL DEFAULT …Run Code Online (Sandbox Code Playgroud) 说我有这个SQL:
select *
from `fluents`
inner join `tests` on `fluents`.`id` = `tests`.`fluent_test_id`
inner join (
select `fluents`.`id` from `fluents` order by `fluents`.`id` desc limit 10
) as j on `fluents`.`id` = `j`.`id`
order by `fluents`.`created_at`;
Run Code Online (Sandbox Code Playgroud)
我知道我可以运行原始SQL,但作为一项学习练习,我试图将其转换为流利且失败,这甚至可能吗?
我有一个域名,但我没有root访问权限.我只能访问/ home/bkhan06/public_html文件夹.您能告诉我如何在没有root访问权限的情况下部署应用程序.
在我的应用程序中,用户可以上传其个人资料照片的图像.如何更新用户照片和删除以前上传的照片?这是我到目前为止在上传控制器中所拥有的:
照片模型
class Photos extends Eloquent {
protected $table = 'photos';
protected $fillable = array('user_id', 'location');
public function user (){
return $this->belongsTo('User');
}
}
Run Code Online (Sandbox Code Playgroud)
用户模型
public function photos()
{
return $this->hasOne('photos');
}
Run Code Online (Sandbox Code Playgroud)
上传控制器
class UploadController extends \BaseController {
public function postUpload (){
$id = Auth::user()->id;
$input = Input::all();
$rules = array(
'photo' => 'required|image|max:500'
);
$validator = Validator::make($input, $rules);
if($validator->fails()){
return Redirect::to('user/profile/'.$id.'/edit')->withErrors($validator);
}
$extension = Input::file('photo')->getClientOriginalExtension();
$directory = public_path('/var/chroot/home/content/59/11581559/html/beta') . '/uploads/'.sha1($id);
$filename = sha1($id.time()).".{$extension}";
$upload_success = Input::file('photo')->move($directory, $filename);
Image::make(Input::file('photo')->getRealPath())->resize(300, 200)->save('foo.jpg'); …Run Code Online (Sandbox Code Playgroud) 您可以将 a 显示Form::password为文本而不是默认的点/项目符号Laravel吗?
我要这个
而不是这个 
我正在尝试加载laravel项目,但在下面收到错误
Symfony \ Component \ Debug \ Exception \ FatalErrorException
syntax error, unexpected 'assets' (T_STRING)
Run Code Online (Sandbox Code Playgroud)

它的视图/ myview.blade.php下,我不明白为什么它在资产上抛出错误,这里是我的视图代码
<video id="example_video_1" class="video-js vjs-default-skin" controls preload="none" width="1000" height="563"
poster="{{ asset('assets/public/video/video.png')}}"
data-setup="{}">
Run Code Online (Sandbox Code Playgroud)
当我将路径更改为somepath/public/video/video.png时,错误是意外的'somepath'.任何帮助将不胜感激
我写了一个Laravel查询.我使用whereBetween,并orWhereBetween伴随着一个where名为"共享"列上声明,应返回一行.
但是这个查询没有考虑where条件.它只花了whereBetween和orWhereBetween.可能是什么原因.
我的查询
$childs = Program::whereIn('id', $programs_by_date)
->where('shareable', '=','1')
->wherebetween('starting_date', [$new_start_date,$new_end_date])
->orwherebetween('ending_date', [$new_start_date,$new_end_date])
->orderBy('starting_date')
->get();
Run Code Online (Sandbox Code Playgroud)
->where('shareable', '=','1')返回0行.可能是什么原因.
shareable 类型是枚举
我需要MySQL查询以下内容.我有一个时间表如下:
`active_periods`
+----+--------+---------+------------+------------+
| Id | Day | All Day | Start Time | End Time |
+----+--------+---------+------------+------------+
| 1 | Friday | 0 | 18:00:00 | 22:00:00 |
---- -------- --------- ------------ ------------
| 2 | Friday | 0 | 06:00:00 | 13:00:00 |
---- -------- --------- ------------ ------------
INT VARCHAR TINYINT TIME TIME
Run Code Online (Sandbox Code Playgroud)
使用MySQL查询,我需要能够计算这些时间段,并在星期五的这些给定时间段之间返回15分钟的块数.所以从上面的表格我会得到44分 15分钟的答案.
提前致谢.
没有现成的问题足以解决我的问题.我正在尝试安装Laravel来试用它并成功安装了Composer,但是关于安装Laravel本身的所有建议似乎都涉及一些叫做Git和'终端'的东西,我对此一无所知.我可以不下载安装文件并像其他应用程序一样运行吗?
麦克风
我需要一系列从初级到高级的Laravel 4视频教程.我在哪里可以免费获得一系列Laravel 4教程截屏视频?
我laravel第一次使用它来创建一个API,以便从angular.js单页应用程序使用AJAX访问。我不知道如何配置控制器和URL以将多个参数传递给任何方法
为我的API组配置路由,如下所示
Route::group(array('prefix' => 'api/v1'), function(){
Route::resource('event', 'EventController');
});
Run Code Online (Sandbox Code Playgroud)
EventController 方法都按文档所述工作,但是,我需要发送开始和结束日期作为检索事件的参数。
我也放置missingMethod($parameters = array())在控制器中,但从未运气过
我试图在show方法中添加一个额外的参数,function show($start, $end)但是无法弄清楚AJAX URL使其起作用。尝试了多种方法:
/myapp/api/v1/event/param1/param2
/myapp/api/v1/event/param1,param2
/* hoping missingMethod($parameters = array()) might get this one*/
/myapp/api/v1/event/[param1,param2]
Run Code Online (Sandbox Code Playgroud)
在大多数情况下,大多数尝试都抛出了一个show缺少第二个参数的异常。
我最终决定使用常规查询字符串并Input::get()在index()函数中进行测试。
/myapp/api/v1/event?param1=1¶m2=2
Run Code Online (Sandbox Code Playgroud)
Route::get('/event')在注册资源无效之前,我还尝试了几种使用通配符添加的方法。
我想有一种相对简单的方法来使资源控制器方法具有多个参数,如果没有,如何配置HTTP请求以missingMethod接收数组?