我是Laravel的新手,我试过这个:
路由器
Route::get('productdetails/{id}', function($id){
'ProductDetailsController@productdetails' .$id;
});
ProductDetailsController
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use DB;
use App\Http\Requests;
use App\Http\Controllers\Controller;
class ProductDetailsController extends Controller
{
public function inventory(){
$inventory = DB::select('select * FROM inventory WHERE barcode = ?', [$id]);;
return view('productdetails',['inventory'=>$inventory]);
}
}
我得到了:
RouteCollection.php第161行中的NotFoundHttpException:
答案 0 :(得分:1)
路由的正确语法是:
void IPushNotificationListener.OnMessage(JObject parameters, DeviceType deviceType)
{
try
{
Intent intent = new Intent(Android.App.Application.Context, typeof(MainActivity));
Intent[] intar = { intent };
PendingIntent pintent = PendingIntent.GetActivities(Android.App.Application.Context, 0, intar, 0);
intent.SetAction("notification");
//Json Response Recieved
Dictionary<string, string> results = JsonConvert.DeserializeObject<Dictionary<string, string>>(parameters.ToString());
Notification.Builder builder = new Notification.Builder(Android.App.Application.Context)
.SetContentTitle(results["contentTitle"])
.SetContentText(results["message"])
.SetContentIntent(pintent)
.SetSmallIcon(Resource.Drawable.icon);
// Build the notification:
Notification notification = builder.Build();
//Clear notification on click
notification.Flags = NotificationFlags.AutoCancel;
// Get the notification manager:
NotificationManager notificationManager =
Android.App.Application.Context.GetSystemService(PushNotificationService.NotificationService) as NotificationManager;
//notificationId need to be unique for each message same ID will update existing message
int notificationId = Convert.ToInt32(results["Id"]);
// Publish the notification:
notificationManager.Notify(notificationId, notification);
}
catch (Exception)
{
}
}
方法应如下所示:
Route::get('productdetails/{id}', 'ProductDetailsController@inventory');