我目前正在寻找一种方法来为jQuery数据表过滤器添加额外的自定义类(每页记录和搜索)
这些项目呈现如下:
<div id="DataTables_Table_0_length" class="dataTables_length">
<label>
<select size="1" name="DataTables_Table_0_length"
aria-controls="DataTables_Table_0">
<option value="10" selected="selected">10</option>
<option value="25">25</option><option value="50">50</option>
<option value="100">100</option>
</select>
records per page
</label>
</div>
Run Code Online (Sandbox Code Playgroud)
和
<div class="dataTables_filter" id="DataTables_Table_0_filter">
<label>
Search: <input type="text" aria-controls="DataTables_Table_0">
</label>
</div>
Run Code Online (Sandbox Code Playgroud)
有谁知道我怎样才能最好地为每个人增加一个额外的课程?有些建议会像往常一样非常感激.
我正在尝试使用观察者来删除关系,但问题是当我在创建的函数中执行 DD 时,它工作正常,但是当我在删除的函数中执行 DD 时,它什么也不显示(POSTMAN)意味着既不工作也不出错
这是 API:
$api->post('store','App\Http\Controllers\CustomerController@store');
$api->delete('delete/{id}','App\Http\Controllers\CustomerController@destroy');
Run Code Online (Sandbox Code Playgroud)
这是工匠制作的观察者文件
namespace App\Observers;
use App\Customer;
class CustomerObserver
{
public function created(Customer $customer)
{
dd($customer);
}
public function deleted(Customer $customer)
{
dd($customer);
}
}
Run Code Online (Sandbox Code Playgroud)
这是客户控制器
class CustomerController extends Controller
{
public function store(Request $request)
{
return Customer::store($request->person);
}
public function destroy($id)
{
$delete = Customer::where('person_id',$id);
$delete->delete();
}
}
Run Code Online (Sandbox Code Playgroud)
这是客户模型文件。
class Customer extends Model
{
//Relationship Start From Here
public function person()
{
return $this->belongsTo(Person::class);
}
//End Here
public static function store($request)
{ …Run Code Online (Sandbox Code Playgroud) 因此,我尝试使用以下代码使用Laravel集合返回对象数组:
/**
* View a user's chat rooms.
*
* return \Illuminate\Http\Response|\Laravel\Lumen\Http\ResponseFactory\
*/
public function viewChatRooms()
{
$user = Auth::user(); // @var User $user
$username = $user->username;
$rooms = Room::with('messages')->get()
->filter(function ($val) use ($username){
foreach ($val->users as $user) {
if($user === $username){
return $val;
}
}
});
return response(['rooms' => $rooms]);
}
Run Code Online (Sandbox Code Playgroud)
响应不返回对象数组,而是返回以下内容:
{
"rooms": {
"0": {...},
"3": {...}
}
}
Run Code Online (Sandbox Code Playgroud)
这是期望的结果:
{
"rooms": [
{...},
{...}
]
}
Run Code Online (Sandbox Code Playgroud)
有点受此困扰,有人可以引导我朝正确的方向发展吗?
处理程序文件中的 Laravel dontReport 无法按照 dontReport 的代码工作
protected $dontReport = [
Illuminate\Auth\AuthenticationException::class,
Illuminate\Auth\Access\AuthorizationException::class,
Symfony\Component\HttpKernel\Exception\HttpException::class,
Illuminate\Database\Eloquent\ModelNotFoundException::class,
Illuminate\Session\TokenMismatchException::class,
Illuminate\Validation\ValidationException::class,
Illuminate\View\View::class,
Illuminate\Routing\RouteCollection::class,
Illuminate\Foundation\Http\Middleware\VerifyCsrfToken::class,
Illuminate\Session\Middleware\StartSession::class,
];
Run Code Online (Sandbox Code Playgroud) 我的数据库插入查询如下
DB::table('job_details')->insert([
'job_id' => $jobId,
'item_id' => $itemId,
'type_id' => $typeId,
'qty' => $qnty,
'laminating' => $laminating,
'mat_id' => $matId,
'rates' => $rates,
'sqft' => $sqft,
'ups' => $ups,
'master_qty' => $masterQnty
]);
Run Code Online (Sandbox Code Playgroud)
如果查询成功或失败,我想获取状态。
我的laravel项目中有以下代码
$config = DB::table('custom_config')->where('item_id', 5);
$cost = [
'car_service_fee' => $config->where('managed_by', 1)->first()->service_fee,
'bike_service_fee' => $config->where('managed_by', 2)->first()->service_fee
];
Run Code Online (Sandbox Code Playgroud)
我的custom_config表格如下.
+---------+------------+-------------+
| item_id | managed_by | service_fee |
|---------+------------+-------------|
| 5 | 1 | 8.5 |
|---------+------------+-------------|
| 5 | 2 | 2.0 |
+---------+------------+-------------+
Run Code Online (Sandbox Code Playgroud)
我car_service_fee正在取得结果8.5
但我bike_service_fee正在恢复null上first()
如果它如下所示,相同的代码可以工作,
$cost = [
'car_service_fee' => DB::table('custom_config')->where('item_id', 5)->where('managed_by', 1)->first()->service_fee,
'bike_service_fee' => DB::table('custom_config')->where('item_id', 5)->where('managed_by', 2)->first()->service_fee
];
Run Code Online (Sandbox Code Playgroud)
在first()存储在变量或laravel中的某个查询构建器上使用的背对背方法是否有任何问题?
谢谢
我是Laravel的新手在这里我试图将我的输入表单发布到会话中但是它不起作用我得到这个错误而没有任何消息:
Symfony \ Component \ HttpKernel \ Exception \ MethodNotAllowedHttpException
Run Code Online (Sandbox Code Playgroud)
我一无所获,在这里我分享了一些代码.
我的控制器:
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Category;
use \App\Product;
class ShopController extends Controller
{
public function index()
{
$categories = Category::with('products')->get();
return view('shop.index', compact('categories'));
}
public function category($id)
{
$products = Category::find($id)->products;
return view('shop.1', compact('products'));
}
public function addToShoppingCart(Request $request)
{
$request->session()->put('cart', 'id');
$request->session()->put('cart', 'number');
$request->session()->flash('status', 'Product is toegevoegd!');
return redirect()->back();
}
}
Run Code Online (Sandbox Code Playgroud)
我的看法:
@extends('layouts.app')
@section('content')
@if(Session::has('id', 'number'))
<div class="alert alert-success">
{{Session::get('id', 'number')}}
</div>
@endif
@foreach ($products as …Run Code Online (Sandbox Code Playgroud)