小编kip*_*zes的帖子

Laravel图像干预调整了质量损失

在我的Laravel网络应用程序中,我使用了干预图像库.我保存上传图像的三个版本:'original','500_auto'和自定义尺寸的图像.

$image = Image::make(Input::file('file');

// Save the orignal image
$image->save($folder . 'original.' . $extension);

// Save 500_auto image
$image->resize(500, null, function($constraint) {
    $constraint->aspectRatio();
});
$image->save($folder . '500_auto.' . $extension, 100);

// Check if size is set
if (isset($config->images->width) && isset($config->images->height)) {
    // Assign values
    $width  = $config->images->width;
    $height = $config->images->height;
    // Create the custom thumb
    $image->resize($width, $height, function($constraint) {
        $constraint->aspectRatio();
    });
    $image->save($folder . $width . '_' . $height . '.' . $extension, 100);
} …
Run Code Online (Sandbox Code Playgroud)

image image-resizing laravel intervention

5
推荐指数
2
解决办法
6558
查看次数

在 Laravel 中为日期配置荷兰语格式

在我的 Laravel 应用程序中,我想以荷兰语格式显示日期。在我的 config/app.php 文件中,我设置了时区和语言环境:

'timezone' => 'Europe/Amsterdam',
'locale' => 'nl',
Run Code Online (Sandbox Code Playgroud)

但是如果我在我的刀片文件中打印一个日期,如下所示:

strftime('%a %e %b', strtotime($day->date))
Run Code Online (Sandbox Code Playgroud)

它仍然没有以荷兰语格式显示。当我在相关控制器的构造函数中调用 setlocale() 方法时,它会起作用。

setlocale(LC_TIME, 'NL_nl');
Run Code Online (Sandbox Code Playgroud)

如何全局设置或在我的配置中定义它?

php date setlocale laravel-5.1

5
推荐指数
1
解决办法
6325
查看次数

使用带有数据表的Laravel存储库

在我的Laravel 5.1.*项目中,我通过这个https://github.com/andersao/l5-repository库来使用存储库.对于Datatables,我使用这个https://github.com/yajra/laravel-datatables库.现在,我可以通过控制器中的依赖注入从我的存储库中获取数据.

namespace Admin\Http\Controllers;

use App\Repositories\Contracts\ModuleRepository;

class ModuleController extends Controller
{
    /**
     * @var ModuleRepository
     */
    protected $repository;

    /**
     * ModuleController constructor.
     *
     * @param ModuleRepository $repository
     */
    public function __construct(ModuleRepository $repository)
    {
        $this->repository = $repository;
    }

    /**
     * Display a listing of the resource.
     *
     * @return Response
     */
    public function index()
    {
        return view('admin::pages.module.index');
    }

    /**
     * Return list with module data.
     *
     * @return mixed
     */
    public function data()
    {
        $modules = $this->repository->all(); …
Run Code Online (Sandbox Code Playgroud)

php repository datatables repository-pattern laravel

5
推荐指数
1
解决办法
1223
查看次数

MySQL Datase中ISBN10和ISBN13的最佳数据类型是什么

对于当前正在构建的应用程序,我需要一个数据库来存储书籍。books表的架构应包含以下属性:

id, isbn10, isbn13, title, summary

ISBN10和ISBN13应该使用什么数据类型?我的第一个想法是biginteger,但我读过一些未经证实的评论,说我应该使用varchar。

mysql database isbn

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