laravel

Laravel 5.5 : Dynamically change throttle time

半城伤御伤魂 提交于 2021-01-29 11:10:42
问题 Currently i am working on login throttle, I have to change the throttle time on 2nd throttle dynamically. How will i be able to do that ? 回答1: Middleware (such as throttle ) can be defined inside controllers as well. A solution would be to conditionally set the middleware in the controllers' constructor, something along the lines of: if (true) { $this->middleware('throttle:60,1'); } else { $this->middleware('throttle:30,1'); } In Laravel 5.6, here’s how you specify a User model attribute used

PHP Fatal error: Maximum execution time of 60 seconds exceeded in C:\xampp\htdocs\vendor\symfony\process\Pipes\WindowsPipes.php on line 140

不打扰是莪最后的温柔 提交于 2021-01-29 11:10:15
问题 Error when i upload video more than 15MB using ajax and Laravel Its show me this error : PHP Fatal error: Maximum execution time of 60 seconds exceeded in C:\xampp\htdocs\vendor\symfony\process\Pipes\WindowsPipes.php on line 140 I use Ffmpeg and Symfony/process the error in symfony windowsPipes.php in laravel So what is problem? 回答1: You can set max_execution_time in your php.ini: max_execution_time=300 Or, in your PHP code: ini_set('max_execution_time', 300); // 5 minutes Setting it to zero

Can't write image data to path - Intervention Image

三世轮回 提交于 2021-01-29 10:55:52
问题 I'm trying to resize my images using Intervention package in my laravel project. I'm able to store images using Storage facade, but when I store them with Image class it throws below error. Can't write image data to path (/var/www/commerce/storage/featureds/2-1537128615.jpg) if ($request->has("featured_img")) { $file_path = $request->get("featured_img"); $exp = explode("/",$file_path); $filename = $exp[1]; $featured_path = "featureds/".$filename; \Storage::copy($request->get("featured_img"),

Laravel relationship based on custom attribute not working both directions

て烟熏妆下的殇ゞ 提交于 2021-01-29 10:53:33
问题 Models Product and Category. Product model has this custom attribute: getCategoryIdAttribute() . because the way to get category id is a bit complex. With that attribute I can define the relationship (Product -> Category): public function category() { return $this->belongsTo(Category::class, 'category_id', 'id'); } This relationship works fine! But now on the Category model: public function products() { return $this->hasMany(Product::class, 'category_id', 'id'); } If I use this relationship

Connecting to Sequel Pro with Homestead issues

我是研究僧i 提交于 2021-01-29 10:47:14
问题 I have been checking out a lot of answers here and on GitHub regarding this issue, but whatever I try there is always something wrong. I also don´t get why with the same credentials sometimes I am able to connect other times I am not even able to do that. So right now I get the following error: "SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: nodename nor servname provided, or not known and I am not able to connect: My .env credentials: DB_CONNECTION=mysql DB_HOST=mysql

passing multiple variable to one view in laravel 5.6

我只是一个虾纸丫 提交于 2021-01-29 10:44:23
问题 hello to all I want to pass multiple variables to one view this is my CategoryController.php public function site() { $categories = Category::all(); return view('template.sitemap', ['categories' => $categories]); } and this is SubCategoryController.php public function index2(){ $subcategories = SubCategory::all(); return view('template.sitemap',['subcategories'=>$subcategories]); } this is my route for this action in web.php Route::get('sitemap.html','CategoryController@site')->name('sitemap'

SQLSTATE[23000]: Integrity constraint violation: 1048 laravel

随声附和 提交于 2021-01-29 10:42:20
问题 I'm getting the following MYSQL error while trying to attach products to an order: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'order_id' cannot be null (SQL: insert into order_product ( amount , history_price , order_id , product_id ) values (1, 5.35, , )) I've already searched for a solution, however all solutions I managed to find seemed to talk about not using default laravel id's as primary keys, while I am using default ID's. Here are the three migrations: Schema:

How to group and count record by date using Laravel?

北慕城南 提交于 2021-01-29 10:41:53
问题 I have an issues table, it has a column created_at , and status which can be 'Open' or 'Closed' I need to get the count of issues depending on the status per month. I want to get something like this: January 2018: { open: 300, closed: 28, }, February 2018: { open: 250, closed: 80 } I don't know if there's a better approach, I'm open to suggestion in how I would retrieve the data. Basically I'm creating an admin dashboard and want to display the data in a chart. 回答1: Assuming you are using

How to access Laravel Folder in Google Cloud

与世无争的帅哥 提交于 2021-01-29 10:28:37
问题 I received an error on my Laravel App /app/storage/logs/laravel-2020-02-20.log" could not be opened: failed to open stream: Permission denied So I google the error, and I discovered it a permission error. chmod -R 775 storage chmod -R 775 bootstrap/cache Apparently, this fixes the error, but anytime I tried to run the command in the cloud console. It keeps saying No directory found. Can someone advice me on how to access storage directory. 回答1: From the tags, I can tell it is GAE flex on GCP.

Getting 404 in laravel 6.x

我的梦境 提交于 2021-01-29 10:18:16
问题 I have created ApiController in App\Http\Controllers\Api\v1 Also created auth using laravel/ui Default created function for front end working perfectly. But issue is when try to call the ApiController My API Rout e file is as below Route::group(['prefix' => 'api/v1', 'namespace' => 'Api\v1'], function () { Route::post('register', 'ApiController@register'); }); And my API controller look like namespace App\Http\Controllers\Api\v1; use App\Http\Controllers\Controller; use Illuminate\Http