小编Baj*_*kie的帖子

Laravel - Paginate和get()

使用下面的代码,我想要的是对我创建的查询进行分页.但是,当我尝试在get之后添加paginate时,会抛出错误.我想保持得到,因为我想限制在$ fields上设置的列.分页这个东西应该是更好的想法?或者什么是获取和限制列的良好替代品?

我尝试了什么:

->get($this->fields)->paginate($this->limit)
Run Code Online (Sandbox Code Playgroud)

我控制器的一部分:

class PhonesController extends BaseController {

    protected $limit = 5;
    protected $fields = array('Phones.*','manufacturers.name as manufacturer');
    /**
     * Display a listing of the resource.
     *
     * @return Response
     */
    public function index()
    {



        if (Request::query("str")) {
            $phones = Phone::where("model", 'LIKE', '%'. Request::query('str') . '%')
                        ->join('manufacturers', 'manufacturers_id', '=', 'manufacturers.id')
                        ->get($this->fields);

        } else {
            $phones = Phone::join('manufacturers', 'manufacturers_id', '=', 'manufacturers.id')
                            ->get($this->fields);
        }



        return View::make('phones.index')->with('phones', $phones);
    }
Run Code Online (Sandbox Code Playgroud)

}

php pagination laravel laravel-4

11
推荐指数
1
解决办法
2万
查看次数

将DomPDF作为phpWord的pdf编写器

我使用laravel为我的应用程序和dompdf找到:

../vendor/dompdf/dompdf

我想要实现的是将我的.docx文件(Microsoft Word)转换为.pdf文件.docx文件是由phpWord通过加载模板文件并替换值生成的.

这是片段:

 // Get the absolute path of the template file
 $wordTemplatePath = $this->getDocumentTemplatePath('resignation.docx');

 // Load the template file
  $document = $this->phpWord->loadTemplate($wordTemplatePath);

// This will be filled with data
 $wordData = []

.... Process to fill the data .....

// Replace value to actual word document
  $this->setTemplateValues($wordData, $document);


// Generate its filename
  $file = $this->generateFileName('Retirement-Certificate.docx', $id);

        // Fetch the absolute path to save the document
        $filepath = $this->getSavePath($file);

        // Save the word document
        $document->saveAs( $filepath );
Run Code Online (Sandbox Code Playgroud)

之后,将生成.docx文件.我也想制作一个PDF版本.所以我搜索并找到了这段代码片段并添加到我的代码中: …

php dompdf composer-php phpword

8
推荐指数
1
解决办法
1万
查看次数

CSS浮动权问题

我正在设计我的页面,我很难调整标题.正如你在这里看到的:

在此输入图像描述

我希望"添加"与员工列表一致.我该怎么办?

顺便说一句这里是html代码:我使用过bootstrap.但一个本地的CSS建议仍然很好.

    <div class="title">
                <h4>Employee list</h4> 
                <span class="pull-right">Add</span>
            </div>
Run Code Online (Sandbox Code Playgroud)

谢谢

html css twitter-bootstrap

4
推荐指数
1
解决办法
1316
查看次数

将第一行作为下一行哈希的键?

我很难弄清楚如何使用第一行中的键使下一行成为哈希.

我有一个像这样结构的数组:

[["id", "name", "address"], [1, "James", "...."], [2, "John", "...."] ]
Run Code Online (Sandbox Code Playgroud)

成为:

[{ id : 1, name: "James", address: "..."}, ...]
Run Code Online (Sandbox Code Playgroud)

我使用了一个gem"simple_xlsx_reader",我只提取出第一张.

wb.sheets.first.row
Run Code Online (Sandbox Code Playgroud)

从上面得到一个类似的数组输出.

谢谢!

ruby excel hash parsing

2
推荐指数
1
解决办法
606
查看次数

PHP - 防止客户端篡改表单的ID

如何修复此代码的安全流程:

 <a href="http://localhost/mypay/admin/company/#" 
   data-pk="26" data-url="http://localhost/mypay/admin/company/update/profile" 
   id="name" 
   name="name" 
   data-type="text" 
   data-source="">dfg</a>
Run Code Online (Sandbox Code Playgroud)

这使用x-editable [bootstrap] - http://vitalets.github.io/x-editable/

我很好奇如果客户端更改数据的"PK"主键,如何提高我的应用程序的安全性.身份证必须放在哪里或者我会创建哪些其他安全措施来阻止他们这样做?

我使用:Bootstrap和Codeigniter.

php security codeigniter twitter-bootstrap x-editable

0
推荐指数
1
解决办法
1067
查看次数