我有这个项目,我应该能够上传excel文件并读取内容,然后将信息上传到数据库.所以我决定使用一个库帮助我成为Maatwebsite/Laravel-Excel
但我尝试阅读文档http://www.maatwebsite.nl/laravel-excel/docs/import但我似乎无法找到我需要的文档.
例如,在第一行中我的excel文件John,Kennedy,Male
这在我的数据库corrensponds First Name,Last Name,Gender.我该如何阅读并上传?有人能帮我吗?
谢谢!
我的代码截至目前
public function postUploadCsv()
{
$rules = array(
'file' => 'required',
'num_records' => 'required',
);
$validator = Validator::make(Input::all(), $rules);
// process the form
if ($validator->fails())
{
return Redirect::to('customer-upload')->withErrors($validator);
}
else
{
$file = Input::file('file');
dd($file);
exit();
}
}
Run Code Online (Sandbox Code Playgroud) 我有一个在复选框字段中的onclick事件中调用的函数.
<input type='checkbox' checked='' onclick='return changeEnable();' id='someid'>
Run Code Online (Sandbox Code Playgroud)
和功能
function changeEnable()
{
var val = $(this).attr('id');
alert(val);
}
Run Code Online (Sandbox Code Playgroud)
我有,但它返回undefined.我的语法错了还是错过了什么?
这些复选框是动态创建的,具有不同的ID,这就是为什么我想获取某些任务的id.
我根据查询结果制作了一个Laravel分页,并在我的视图中呈现.我正在遵循本指南http://laravel.com/docs/5.1/pagination但我收到错误:
Call to a member function paginate() on a non-object
Run Code Online (Sandbox Code Playgroud)
我正在使用查询构建器,所以我认为应该没问题?这是我的代码
public function getDeliveries($date_from, $date_to)
{
$query = "Select order_confirmation.oc_number as oc,
order_confirmation.count as cnt,
order_confirmation.status as stat,
order_confirmation.po_number as pon,
order_summary.date_delivered as dd,
order_summary.delivery_quantity as dq,
order_summary.is_invoiced as iin,
order_summary.filename as fn,
order_summary.invoice_number as inum,
order_summary.oc_idfk as ocidfk,
order_summary.date_invoiced as di
FROM
order_confirmation,order_summary
where order_confirmation.id = order_summary.oc_idfk";
if (isset($date_from)) {
if (!empty($date_from))
{
$query .= " and order_summary.date_delivered >= '".$date_from."'";
}
}
if (isset($date_to)) {
if (!empty($date_to)) …Run Code Online (Sandbox Code Playgroud) 我正在创建一个模块,您可以从excel文件上传数据库中的记录.这些只是电话号码.所以这是我的代码:
$file = Input::file('file');
Excel::load($file, function($reader) {
// Getting all results
$results = $reader->get()->toArray();
//var_dump($results);exit;
foreach ($results as $key => $value) {
$phone = new Phone();
$phone->msisdn = $value['msisdn'];
$phone->save();
}
});
Run Code Online (Sandbox Code Playgroud)
我正在使用https://github.com/Maatwebsite/Laravel-Excel来读取excel文件.它工作正常,20分钟上传20,000条记录,我想,有没有办法上传或上传速度更快?我知道这也取决于服务器,但还有其他因素吗?我正在使用MySQL
谢谢
我正在研究基于Laravel 5.1的系统.我有一个路线资源:
Route::resource('applicant', 'ApplicantController');
Run Code Online (Sandbox Code Playgroud)
因此我们期望它在控制器中具有以下功能:
index, create, store, edit, update, delete
Run Code Online (Sandbox Code Playgroud)
我想要的只是在index函数中应用中间件auth .通常,如果要在整个控制器上应用Auth,则需要执行以下操作:
public function __construct()
{
$this->middleware('auth');
}
Run Code Online (Sandbox Code Playgroud)
但当我删除它时,只是做:
public function index()
{
$this->middleware('auth');
return view('applicant.index');
}
Run Code Online (Sandbox Code Playgroud)
它不起作用.我以前做过这个并且工作正常.这是在我的ApplicantController我希望该create功能是公开的,只应用登录身份验证index.我不会用edit, update, delete
我在我的视图列表中使用jQuery DataTables.我使用服务器端处理模式,特别适用于大型数据集.但我的问题是我只能使用单个数据库表来执行此操作.
使用多个表的自定义查询JOIN而不改变太多是我的代码呢?
所以我有这个:
HTML
<table id="CustomerList" class="table table-striped table-bordered" cellspacing="0" width="100%">
<thead>
<tr>
<th colspan="7"> <center>Customer Information<center></th>
<th colspan="1"> <center>Actions<center></th>
</tr>
<tr>
<th>ID</th>
<th>First Name</th>
<th>Last Name</th>
<th>Gender</th>
<th>Phone Number</th>
<th>Country</th>
<th>Postcode</th>
<th>Edit</th>
<!-- <th>Edit</th>
<th>Delete</th> -->
</tr>
</thead>
<tbody>
</tbody>
</table>
Run Code Online (Sandbox Code Playgroud)
阿贾克斯
<script type="text/javascript">
$(document).ready(function() {
$.fn.dataTable.ext.legacy.ajax = true;
var table = $('#CustomerList').DataTable( {
"processing": true,
"serverSide": true,
"ajax": "api/customer/all",
"columnDefs": [
{
"targets": 7,
"render": function(data, type, row, meta){
// return '<a href="/qms/public/customer/' + row[0] …Run Code Online (Sandbox Code Playgroud) 我正在使用Laravel 5中的实时聊天制作应用程序,我正在关注本教程,https://github.com/dazzz1er/confer/tree/master我已经关注了所有这些但是我的错误网络控制台:

似乎它正在我的网址http://localhost/joene_/public/index.php/auth上进行ajax调用,因为我没有处理该请求的路由,它说404.我不知道是否应该为它做一条路线,但我会在那里编码?我不知道.该教程甚至没有提到它.
谢谢
只是想问一下我的模态中是否可以有背景图像?我尝试过搜索,但我只看到模态的背景相关内容,它指的是页面本身.我想要的是我的模态框,上面有图像背景.或改变它的颜色?谢谢.我在CSS方面不是那么好.谢谢.
我是 Laravel 5 的新手,假设我的数据库中有名字和姓氏字段。我有这个验证吗?
public function create()
{
$rules = array(
'firstname' => 'required:unique',
'surname' => 'required:unique',
'phoneno' => 'required',
'mcmillan' => 'required',
'hri' => 'required',
'diabetes' => 'required',
'breastcancer' => 'required',
'gpt' => 'required',
);
$validator = Validator::make(Input::all(), $rules);
// Check if all fields is filled
if ($validator->fails())
{
return Redirect::to('brk')->withErrors($validator);
}
else
{
$flag = Input::get('flag');
/* If version 2 (Opt In) */
if($flag == "1")
{
if(Input::get('opt') != "")
{
$optMethod = Input::get('opt');
}
else
{
$optMethod …Run Code Online (Sandbox Code Playgroud) 我正在使用Laravel应用程序,我正在显示数据库中的内容,数据类型是text,这是内容
<span style="font-weight: bold; font-style: italic;">What is your dog's name?</span>
你可以看到它有HTML标签,但当我在我的视图中呈现它时,而不是格式化文本What is your dog's name?它显示整个内容
<span style="font-weight: bold; font-style: italic;">What is your dog's name?</span>
Run Code Online (Sandbox Code Playgroud)
它不是在阅读HTML标签.我需要在格式化中进行转换吗?当我查看源代码时,
<span style="font-weight: bold; font-style: italic;">What is your dog's name?</span>
Run Code Online (Sandbox Code Playgroud)
这是我的代码:
视图
<table class="table table-striped table-bordered">
<tbody>
@foreach($questions as $key => $value)
<tr>
<td class="">{{ $value->Question }}</td>
</tr>
@endforeach
</tbody>
Run Code Online (Sandbox Code Playgroud)
我的控制器:
public function create()
{
$questions = Question::where('IsEnabled', '=', 'Yes')->get();
return view('crm.create')->with(array('questions' => $questions));
}
Run Code Online (Sandbox Code Playgroud) laravel ×6
php ×6
laravel-5 ×3
excel ×2
jquery ×2
blade ×1
chat ×1
css ×1
datatables ×1
html ×1
import ×1
javascript ×1
laravel-5.1 ×1
modal-dialog ×1
mysql ×1
pagination ×1
pusher ×1
rendering ×1
upload ×1
validation ×1
view ×1
websocket ×1