laravel

Laravel Carbon returns incorrect time

微笑、不失礼 提交于 2021-01-28 13:52:48
问题 I have an issue with my Laravel app that I'm developing, the returns time is incorrect, I did specify the timezone on both config/app.php and php.ini file, and I did clear the cache on Laravel using the following commands: php artisan cache:clear php artisan view:clear php artisan config:cache Also, I restarted my PHP service after changing the timezone in php.ini file. I'm using XAMPP as a server. Please note: the only correct time is by using pure php function! Anyone can help me in

Laravel form request validation on store and update use same validation

≯℡__Kan透↙ 提交于 2021-01-28 13:39:25
问题 I create laravel form validation request and have unique rules on that validation. I want use it on store and update method without create new form request validation again. but the problem is when on store the id doesnt exist and the validate is passed and when on update i failed the pass the validating because the id is exist on storage i want to ignore the id on unique rules but use same form validate request what is best practice to check on form validate request class if this action from

How to get a user from post table when using hasMany relationship

前提是你 提交于 2021-01-28 12:13:13
问题 I am pretty new to Laravel and i have been stuck with this problem for quite a while now ,I face a problem when trying to get a user name through post table using hasMany relationship. Hope the added code helps to understand the problem better. Thank you public function main_page(){ $post= Post::all(); return view('main' , compact('post') ); } @extends('layouts.app') @section('content') @foreach ($post as $p) {{$p->users()->name }} @endforeach @endsection public function users(){ $this-

Apache Setup Multiple Project On Test Server

不想你离开。 提交于 2021-01-28 12:11:05
问题 I'm using CentOS 7 and Apache on my Virtualbox. This VM has its own IP address (XXX.XX.XX.XX). Having this setting below, I can access my project on the browser by typing http://XXX.XX.XX.XX <VirtualHost *:80> DocumentRoot /var/www/html/project_name/public/ <Directory /var/www/html/project_name/> AllowOverride All </Directory> ErrorLog /var/log/apache2/project_name-error_log CustomLog /var/log/apache2/project_name-common_log combined </VirtualHost> My problem is I have another web app project

Ghostscript PDF file compression using PHP's exec (Laravel on Docker)

风流意气都作罢 提交于 2021-01-28 12:02:08
问题 What needs to be done: User has to be able to upload a PDF, then the file is uploaded to an Amazon S3 bucket, the file should be compressed then. Current environment: Laravel application (mounted on Docker) ( php:7.4-fpm-alpine3.11 , GPL Ghostscript 9.50 , Laravel Framework 5.8.37 ) Amazon S3 bucket to save documents in Script is in a shell file which is made executable and added to /usr/local/bin as shrink Shell is not explicitly added in Docker container, should it be? Current flow: User

Laravel 7: MariaDB in combination with Redis but Redis behaves slower with large objects

六月ゝ 毕业季﹏ 提交于 2021-01-28 11:54:47
问题 I have successfully implemented a combination of redis and mysql. At one section of my application I thought I would reduce load on mysql server and use redis until the data gets changed, however I observe that it's still faster when the same data is fetched from Mysql than redis. Here is scenario. User1: 10,000 records with seldom one off change in a day or so. What I do is whole object that fetches these 10K records, (serialized object of about 20mb in size) is saved to redis. The idea is

Laravel in PHP General error: 1366 Incorrect integer value

☆樱花仙子☆ 提交于 2021-01-28 11:52:08
问题 $id = DB::table('utilisateur') ->select('idUtlstr') ->where('email','=',$request ->input("email")) ->get(); DB::table('client')->insert( [ 'idClient' => $id, 'nbrSignl' => 0, 'numPermis' => 0, 'quest1' => 'vide', 'quest2' => 'vide', 'quest3'=> 'vide', 'datePermis' => '2000-01-01', 'numCompte' => 0 , 'blocage' => 'non' ] ); SQLSTATE[HY000]: General error: 1366 Incorrect integer value: '[{"idUtlstr":25}]' for column 'idClient' at row 1 (SQL: insert into client ( idClient , nbrSignl , numPermis

Laravel Insert multiple records from one form

删除回忆录丶 提交于 2021-01-28 11:43:49
问题 I'm working on a task to add extra to items, I have a select field to add item_id and save it to extras table in the database. I'm trying to add more than 1 items to save my time instead of adding same extra to another items. I'll share the current code work for one item ONLY : View: {!! Form::select('food_id', $food, null, ['class' => 'select2 form-control']) !!} my try do make it insert multiple ids: {!! Form::select('food_id[]', $food, null, ['class' => 'select2 form-control', 'multiple'=>

Resource response is not wrapped with “data” [duplicate]

瘦欲@ 提交于 2021-01-28 11:31:10
问题 This question already has an answer here : Laravel paginate resources won't add meta (1 answer) Closed 12 months ago . I am very curious, why my resource response is not wrapped in data : This is my resource: App\Http\Resources\CategoryResource Object ( [resource] => stdClass Object ( [id] => 12 [title] => Category [description] => <p>Test</p> [with] => Array ( ) [additional] => Array ( ) ) Once this resource is returned like this: $response = $this->client->getApiResponse('/api/category/'.

Create redirect after registration Laravel

流过昼夜 提交于 2021-01-28 11:26:22
问题 I want after successful registration I was redirected to successfull.blade.php , but for some reason it either gives a 404 error, that the page was not found, or that it always throws me to home ... I can’t handle it please help me. After successful registration, I should be thrown to successfull.blade.php Please help me. RegistersUsers.php public function register(Request $request) { $this->validator($request->all())->validate(); event(new Registered($user = $this->create($request->all())));