laravel

Laravel

拟墨画扇 提交于 2021-02-08 02:42:22
首先,登录网址 packagist.org 查找 laravel captcha ,找到 mews/captcha ,根据 packagist 上的使用方法一步步来实现验证码的安装。配置composer.json文件 composer 安装: composer require mews/captcha 注册 providers (config/app.php) ,在这个数组中的最后追加如下代码: Mews\Captcha\CaptchaServiceProvider::class, 注册 aliases (config/app.php) ,在这个数组中的最后追加如下代码:(laravel 5 以后不用注册) 'Captcha' => Mews\Captcha\Facades\Captcha::class, 生成配置文件,在 Composer 命令行中输入如下命令: php artisan vendor:publish 进入 config/captcha.php 文件,修改 default 数组 可以对验证码进行样式、数量、大小上的修改。 'default' => [ 'length' => 5, 'width' => 100, 'height' => 34, 'quality' => 90, ] , 页面中使用: <div class ="row"> <div class =

Fleet cart using middlewares in routes but i can not find any $routemiddleware in project…not even in kernel.php …where can i find it?

▼魔方 西西 提交于 2021-02-08 02:12:43
问题 Fleet cart using middlewares in routes but i can not find any $routemiddleware in project...not even in kernel.php ...where can i find it? Laravel Version : 5.7 Passport Version : 7.5 CMS : FleetCart Kernel.php namespace FleetCart\Http; use Illuminate\Foundation\Http\Kernel as HttpKernel; class Kernel extends HttpKernel { /** * The application's global HTTP middleware stack. * * These middleware are run during every request to your application. * * @var array */ protected $middleware = [

Unable to change upload_max_filesize to Azure

风流意气都作罢 提交于 2021-02-08 01:50:24
问题 I have a Laravel Azure website. I have a .user.ini file where I have some settings like upload_max_filesize=120M post_max_size=121M output_buffering=Off max_execution_time=3000 max_input_time=3000 memory_limit=140M But, strangely enough, only max_execution_time and memory_limit changed . I also tried ini_set() but with the same result. Is there a solution for this? 回答1: Basically I added in the settings PHP_INI_SCAN_DIR with the value of the folder path to the .user.ini 回答2: As PHP

Unable to change upload_max_filesize to Azure

女生的网名这么多〃 提交于 2021-02-08 01:49:51
问题 I have a Laravel Azure website. I have a .user.ini file where I have some settings like upload_max_filesize=120M post_max_size=121M output_buffering=Off max_execution_time=3000 max_input_time=3000 memory_limit=140M But, strangely enough, only max_execution_time and memory_limit changed . I also tried ini_set() but with the same result. Is there a solution for this? 回答1: Basically I added in the settings PHP_INI_SCAN_DIR with the value of the folder path to the .user.ini 回答2: As PHP

Missing required parameters for [Route: verification.verify] [URI: {locale}/email/verify/{id}/{hash}]

邮差的信 提交于 2021-02-07 23:25:13
问题 In registration process, while sending verification email issue with adding {locale}. Data is being added to database. But thereafter giving following issue. Missing required parameters for [Route: verification.verify] [URI: {locale}/email/verify/{id}/{hash}]. I think it will be some type of overriding the verification process. web.php Route::group([ 'prefix' => '{locale}', 'where' => ['locale' => '[a-zA-Z]{2}'], 'middleware' => 'setlocale'], function() { Auth::routes(['verify' => true]);

Laravel how do I get the row number of an object using Eloquent?

梦想的初衷 提交于 2021-02-07 20:49:38
问题 I'd like to know the position of a user based on its creation date. How do I do that using Eloquent? I'd like to be able to do something like this: User::getRowNumber($user_obj); 回答1: I suppose you want MySQL solution, so you can do this: DB::statement(DB::raw('set @row:=0')); User::selectRaw('*, @row:=@row+1 as row')->get(); // returns all users with ordinal 'row' So you could implement something like this: public function scopeWithRowNumber($query, $column = 'created_at', $order = 'asc') {

Laravel how do I get the row number of an object using Eloquent?

烂漫一生 提交于 2021-02-07 20:47:30
问题 I'd like to know the position of a user based on its creation date. How do I do that using Eloquent? I'd like to be able to do something like this: User::getRowNumber($user_obj); 回答1: I suppose you want MySQL solution, so you can do this: DB::statement(DB::raw('set @row:=0')); User::selectRaw('*, @row:=@row+1 as row')->get(); // returns all users with ordinal 'row' So you could implement something like this: public function scopeWithRowNumber($query, $column = 'created_at', $order = 'asc') {

Laravel 5.5 delete item with ajax call on click

落爺英雄遲暮 提交于 2021-02-07 20:18:36
问题 I am trying to delete a model item via an ajax call when you click on an icon. Without an ajax call and just with a form everything works great. This exception is thrown when I look in my network tab of my chrome dev tools "Symfony\Component\HttpKernel\Exception\HttpException" This is my icon: <i class="fa fa-trash-o deletebtn" aria-hidden="true" data-pointid="<?php echo $damagePoint->id ?>"></i> My ajax call: $(".deletebtn").click(function(ev){ let pointid = $(this).attr("data-pointid"); $

What are Mutators and Accessors in Laravel

北慕城南 提交于 2021-02-07 19:27:47
问题 I am trying to understand accessors & mutators and why I need them. And my another ask is the middle part of an attribute's method for an example: Accessor : public function getFirstNameAttribute($value) { return ucfirst($value); } Mutator: public function setFirstNameAttribute($value) { $this->attributes['first_name'] = strtolower($value); } Here, we can see getFirstNameAttribute and setFirstNameAttribute methods and I haven't been able to clear the middle part FirstName of them. I will

Access to another requested input in custom rule class - Laravel

北城余情 提交于 2021-02-07 19:16:48
问题 I need to access $request->important in passes method. I need it to validate name based on this value class TestCustom implements Rule { public function passes($attribute, $value) { // } public function message() { return 'some txt'; } } Used like this: use App\Rules\TestCustom; $request->validate([ 'name' => ['required', new TestCustom], 'important' => ['required', 'string'], ]); 回答1: It's much better to pass data to rule constructor and use it inside rule afterwards. This way you can use