我想在laravel(我是新手)中为我的web应用程序创建一个功能,即每个帖子/评论/主题(在我的情况下)用户有能力upVote和downVote。现在我正在用upVote开玩笑,但它并没有任何作用。正在更新内容Laravel
在视图(welcome.blade.php) 我:
<a href="{{ route('Voteplus', ['name' => $Theme->name]) }}"> <img class="media-object" style="height:40px; width:40px;" src="images/upVote.svg" alt="..."></a>
其中$主题 - >名称是用户要给予好评/像(任何)之一。
路线:
Route::put('/', [
'uses'=>'[email protected]',
'as' =>'Voteplus' //Name of route
]);
而且控制器:
<?php
namespace App\Http\Controllers;
use App\NewTheme;
use DB;
class Vote extends Controller {
public function VotePlus($name){
DB::table('New_Themes')
->where('name', $name)
->increment('upVotes', 1);
$Themes = NewTheme::paginate(5);
return redirect()->route('welcome', ['Themes'=>$Themes]);
}
};
我想要的一切,但它不工作。有人能帮助我吗?
' - > where('title',$ title)''应该是' - > where('title',$ name )'? –
我改变了,但它不起作用 – DomainFlag
也许投放路线是错误的,我使用它都是错误的? – DomainFlag