Questions tagged [laravel-5]

18448 questions
1

votes
2

answer
455

Views

Call to a member function addEagerConstraints() on float LARAVEL

My objective is to get average review of the courses available. But when i am trying to get the average review of the course its throwing me an error saying 'message': 'Call to a member function addEagerConstraints() on float' My Course Model public function rating(){ return $this->hasMany(Rating::c...
user7747472
1

votes
2

answer
1.1k

Views

Laravel 5.5 Class 'Doctrine\DBAL\Driver\PDOPgSql\Driver' not found

I am working in laravel 5.5 with postgras 9.6, I manage to run all migration and rollback, but when I want to run migration for rename a column in Table i get the Class 'Doctrine\DBAL\Driver\PDOPgSql\Driver' not found error, hire is migration file: class CreateRenameApplicantIdInBillToApplicationId...
Joshua Kisanga
1

votes
2

answer
364

Views

Best way to write Group routes with prefix in laravel 5.5

What is the best and correct way to write the following routing: Route::group(['middleware' => ['web']],function (){ Route::prefix('user')->group(function () { //this address shows the login page Route::any('login', '[email protected]_page'); //others address that control the login action Route::prefix('lo...
Mahdi
1

votes
1

answer
540

Views

Class 'PragmaRX\Tracker\Vendor\Laravel\ServiceProvider' not found

I had installed PragmaRx\Tracker package several months ago into my project. I started to deleting the package from laravel project through following steps: 1. composer remove vendor/PragmaRx/Tracker 2. remove package name form composer.json file 3. removing package from provider and aliases list in...
blank94
0

votes
0

answer
8

Views

Laravel two similar routes, second route not found

Laravel 5.8, I have two routes: Route::get('/exam-info/{id}', '[email protected]')->name('main_exam_info'); Route::get('/exam/{id}', '[email protected]')->name('start_main_exam'); When I go to the second route it gives me 'page not found' error! Why?
Ahmad Mobaraki
0

votes
0

answer
4

Views

“Trying to get property 'id' of non-object (View: C:\xampp\htdocs\CERCAA\resources\views\admin\posts\edit.blade.php)”

When I am editing the post then it's showing 'Trying to get property 'id' of non-object (View: C:\xampp\htdocs\CERCAA\resources\views\admin\posts\edit.blade.php)'
user10945543
1

votes
1

answer
308

Views

How to get PhpStorm to recognize Laravel facades?

When using Laravel Framework (5.6), PhpStorm does not recognize methods when accessed via facades like this: $user = User::find($id); So it's always complaining that: 'Method 'find' not found in User' I've got the Laravel Plugin & the Barry IDE Helper. What else do I need to do?
BizzyBob
1

votes
4

answer
321

Views

Laravel - whereHas checking latest record of a relationship without checking others

I have two tables that has One to Many relationship. Bookings - (id) booking_tasks - (id, booking_id,user_id) one booking has many task one task has one booking Booking Model: public function tasks() { return $this->hasMany('App\BookingTask'); } BookingTask Model public function booking() { retu...
ashanrupasinghe
1

votes
2

answer
63

Views

Store Data in Multiple tables via single form

I want to store data in 3 tables via single registration form but getting error. I have tried all the way but it is not allowing due to primary key constraints violation Controller class UserController extends Controller { public function registerLawyer(Request $request){ $firstname = $request->get(...
Prathamesh Doke
1

votes
1

answer
35

Views

How to add unique constraint to column with LongText datatype in laravel 5.7

Can i add unique constraint to LongText column in laravel. I mean, for example i have table having body column with LongText datatype, then how i can make it unique. $table->LongText('body')->unique(); When i do this it will generate the following SQL error. Illuminate\Database\QueryException : SQL...
Riaz Khan
1

votes
1

answer
19

Views

How to get an array from a single field from related model in laravel?

The following: Customer::with('tickets:customer_id,subject')->get(); returns the following: [ { 'id': 1, 'company': 'Test Ltd', 'support': 'Standard', 'tickets': [ { 'customer_id': '1', 'name': 'Test ticket 1' }, { 'customer_id': '1', 'name': 'Test ticket 2' } ] } ] How can I flatten the related fie...
1

votes
1

answer
33

Views

How to get data out of the notifications?[Error retrieving data] laravel 5.8

When ever a user post on a thread its send an notifications and then form the navagition bar there is an drop down menu where the user can see all his notifications, but when I try to open it it gives an error Undefined index: thread (View: C:\Users\Merlijn\AppData\Roaming\Composer\Laravel Projects...
HashtagForgotName
1

votes
2

answer
24

Views

Laravel: Use same column as option name and its value in select box/drop-down?

I'm trying to create a form with a select box in Laravel. View {{ Form::select('cmp_type', $cmp_types, null, $attributes = ['class' => 'form-control']) }} Controller public function showAddCompany() { $cmp_types = cmpTypes::where('status', true)->pluck('type'); return view('addCompany', compact('cmp...
siri
1

votes
2

answer
44

Views

laravel Show only related data in search filter

I am trying to create a search filter: if ($request->has('street')) { $streets->where('name', 'like', '%'.$request->street.'%'); } if ($request->has('house')) { $streets->whereHas('properties', function ($query) use ($request) { $query->where('house_number', $request->house); }); } return $streets->...
Muhammad Shahzad
1

votes
1

answer
56

Views

Laravel passport: Manually create access token

I'm building an SPA using VueJS and Laravel. I'm using Laravel passport for logins which works fine. However I would like the ability to send users magic links to log in with. However I'm not sure how to create an access token without sending a request with the password to the oauth route. It seems...
John Mellor
1

votes
2

answer
42

Views

Laravel: How do I access the unique ID of a logged in user and use it in a database query?

I am making a website for college administration where professors log in and assign marks to the students they are teaching. There's a table, called 'IA_Marks' in my database: |Student_ID|Subject_Code|Name|Marks1|Marks2|Marks3|Semester|Division| There's also a table called 'Classroom_Mapper' in my d...
1

votes
2

answer
51

Views

Laravel Migration is working but cannot access with Eloquent

I have some issues with my Laravel. Migrations work fine but when I try to insert or access data with Eloquent I have an error: 'SQLSTATE[HY000] [2002] Connection refused' .env file: DB_CONNECTION=mysql DB_HOST=127.0.0.1 DB_PORT=3306 DB_DATABASE=myddb DB_USERNAME=root DB_PASSWORD=password database...
Gedaym
1

votes
4

answer
45

Views

How to pass extra data after validation?

After validation I want to pass some extra data to view. However, I can't send it. My controller is like, public function test() { $validator = Validator::make( request()->all(), [ 'ziptest' => 'regex:/^([0-9]{3}-[0-9]{4})$/'] ); $errors = $validator->errors(); if($errors->any()) { return back()...
Nabil Farhan
1

votes
5

answer
93

Views

Page not found in Laravel, routes problem

I have a problem with my Laravel and probably routes but I'm not sure. So, there is a contact form in modal window. When I click on Send button I've got page not found error. What I have in the web.php is Route::post('/apply_now','[email protected]_now')->name('apply_now'); In the HomeControlle...
Jordan
1

votes
2

answer
40

Views

Duplicating data in Controller Laravel

I am trying to duplicate data with a click of a button, in better terms, trying to reorder a previous order. This is my code $order = Order::find($id); $order_details = OrderDetail::where('order_id', $id)->get(); $reorder = $order->replicate(); $reorder_details = $order_details->replicate(); $reord...
John
1

votes
2

answer
29

Views

What is the difference between \Validator::make($input, $rules) and Validator::make($input, $rules)?

It seems like that the Validator::make($input, $rules) is not working when I try to validate the request. The added prefix of '\' makes the job done. What is the reason behind this mark use since lots of the documentation and lectures don't make use of it?
Aashish K
-1

votes
1

answer
17

Views

<UL> <LI> Foreach Loop Displaying all content on one <UL>

I know this is relatively simple but its driving me absolutely insane! a little background, my app takes an xml feed to parse, this has nested fields suchs as features its in my db, as an obj/array, with 'feature' as the key. now my for each loop is displaying all this data in one UL. Code Below. An...
Daniel Horrobin
0

votes
0

answer
5

Views

Call to undefined method Illuminate\Foundation\Application::withFacades()

I am trying to install laravel-auditing I am following these steps. but seems it says like Uncaught Error: Call to undefined method Illuminate\Foundation\Application::withFacades() Pre-Conditions Laravel version: 5.6.39 owen-it/laravel-auditing: 8.* My Composer.json file is 'require': { 'php': '^7.1...
sphere
0

votes
1

answer
34

Views

Set up Laravel project to work with multiple domain names

I have successfully configured multiple domains to point to my Laravel 5.1 project VirtualDocumentRoot '/Users/Sites/project/public' ServerName app.com UseCanonicalName Off VirtualDocumentRoot '/Users/Sites/project/public' ServerName app2.com UseCanonicalName Off VirtualDocumentRoot '/Users/Sites/p...
kyo
0

votes
0

answer
7

Views

How to fix trix editor in laravel 5.8

I am trying to add trix editor in a form. It appears but the toolbar is disabled its not working. After some research i found that was in the header of my layout file so i moved it in the end of the body and removed 'defer' and now trix editor is disappeared. layout file @yield('scripts') field whe...
Aadee Shah
0

votes
1

answer
15

Views

How do I change the key values after a groupBy in eloquent?

I've grouped a list of records by the month they were created in: $jobListings = JobListing::with('company')->orderBy('created_at')->get(); $jobListings = $jobListings->groupBy(function($j) { return Carbon::parse($j->created_at)->format('m'); }); return response()->json($jobListings); This will give...
Connor Leech
0

votes
0

answer
7

Views

i want to loop throw this custom query in users controller

i want to change in the dtajax function to loop throw the custom query not into the users table. public function dtajax() { $users = User::all(); $users = DB::table('tc_users') ->join('users_tc_users', 'users_tc_users.tc_users_id', '=', 'tc_users.id') ->join('users', 'users.id', '=', 'users_tc_user...
mohamed mohamed
0

votes
0

answer
8

Views

laravel create one rule with query based on several fields from the form

I'm creating a simple reservation system and I need to check that car is available. I'm gonna create a custom rule but I have following problems: 1. I need to pass an argument few values from form to passes method: date, time_form, time_to, car_id. The first and second question get excited because;...
simple_code
1

votes
1

answer
192

Views

Laravel select subquery

I'm rather stuck trying to figure out how I can run this as a single query from the database rather than fetching the results using one query then executing the other. $query->whereIn('page_user_id', Staff::lists('staff_id')); Thanks for the help
Shardj
0

votes
0

answer
7

Views

How does Auth works with subdomains?

I have two subdomains and one domain. api.pulsespace.test myshop.pulsespace.test pulsespace.test The problem is that after logging in, I have a controller that returns the user info using Auth::User(), but this is returning null every time. And if I try to visit the '/login' route, it will just red...
user8114666
1

votes
1

answer
472

Views

Not able to start Thread from Laravel Command

I am new to pthreads in php. I have learnt that it is not possible to start it from apache through a webserver so I have resorted into using laravel commands to run it from the command line but I get this error when I call the start() method of the thread PHP Fatal error: Uncaught Exception: Seri...
Algorithm
0

votes
0

answer
17

Views

How to debug/view SQL requests with Laravel / Laragon

My question is very simple but I have no clue: I have always been working with java and eclipse or C# until now so it's a 'new world' :) How can I debug my laravel code? I am using laravel and vuejs. I start my server with laragon, and I use VScode. I have tried starting it from VScode (added xdebug...
gertrude
1

votes
1

answer
4.2k

Views

Call to undefined function Symfony\Polyfill\Mbstring\iconv_strpos() error laravel 5.4

I am uploading a laravel 5.4 project to cpanel server. And i am serve with PHP Fatal error: Call to undefined function Symfony\Polyfill\Mbstring\iconv_strpos() on server. I have done composer require symfony/polyfill-iconv However, it does not change the error message. What thing i might miss out?
Brian Ruchiadi
1

votes
1

answer
1k

Views

Laravel 5.4: Password reset token custom length?

I am using laravel 5.4 building an API where I email the user a token on password reset if user verified, which user provides before resetting password. Currently the sent token has 64 characters and too large for user to grab, and I'm not sure if laravel has configuration to give a custom length to...
blazR
1

votes
2

answer
444

Views

concat collection in Laravel 5.3

I'm trying to concatenate a set collection to another set of collection. I see in Laravel 5.5 it has concat function, but for compatibility reason I have to use until Laravel 5.3 only. I tried merge function but it is not concatenating but merging instead. What are other workaround, or how can I upd...
sulaiman sudirman
0

votes
0

answer
30

Views

How to convert this sql query into laravel query builder?

I had a table(itemregistrationpangkat) with name(joined from other table itemregistrations), negeri(joined from other table named negeri) and year of start service and end service. I want to get the number of years a person served in a state: ID | Name | negeri | yearstart | yearend...
joun
1

votes
3

answer
118

Views

return first error in customized formatted in laravel 5.5 form requests

Before laravel 5.5 I used a form request like this with a customized format : namespace App\Http\Requests; use Illuminate\Foundation\Http\FormRequest; use Illuminate\Contracts\Validation\Validator; class StoreProductRequest extends FormRequest { public function authorize () { return true; } public...
A.B.Developer
1

votes
1

answer
380

Views

Laravel 5: assertSeeText() and html entities

I'm using PHP Faker to generate random data (using factories) in the database and sometimes it generates apostrophes. In my test, I use assertSeeText(). The problem is that when the tested string contains special characters such as apostrophes, these characters are converted to html entities in the...
SystemGlitch
1

votes
1

answer
2.3k

Views

Laravel - Delete with all relations

I have a system where a user is connected to alot of different tables, These tables are also connected to different tables. When I delete a user from my database, every relation associated with that user should also be deleted. My project's relation setup looks like this - A User user has multiple o...
Rainier Laan
1

votes
1

answer
698

Views

using React Native with Laravel

I need help regarding how to create an react native app of a project which is already made in the Laravel framework. As I am going to make a Laravel website. So I also want to create an IOS and Android app for it. Can anyone suggest me something for it?
akshay gaur

View additional questions