Questions tagged [laravel-controller]

218 questions
0
votes
1 answer

Laravel Eloquent: How to replace id with name

I have following models and controller. User.php public function reporting() { return $this->hasMany('App\Reporting','user_id','id'); } RegisterController.php public function viewUsers() { $users = User::with('reporting')->get(); …
Muhammad Kazim
  • 611
  • 2
  • 11
  • 26
0
votes
2 answers

Laravel passing data to controller using controller parameter vs request

I am new to Laravel and web programming things. I saw lecturer in tutorial, he passes an id to a controller by using controller parameter Route::get('/post/{id}', ['as'=>'home.post', 'uses'=>'AdminPostsController@post']); , what is the difference…
0
votes
1 answer

How to forward form values from one view to another using $request->all(); ? Laravel 5

I pull all the values (topup amount and phone number) from a form on the index page and forward it to the checkout page: public function topupPost(Request $request) { $validator = [ 'topupAmount'=> 'required|integer|between:1,100', …
Seif
  • 701
  • 4
  • 13
  • 32
0
votes
2 answers

Laravel 5.4: Passing a variable via Request to controller

Generally speaking this should be a rather simple problem. IT should be very similar to the following question on Stack Overflow But seeing as it has been two years, maybe some of the syntax has changed. All I want to do is pass a variable from the…
0
votes
4 answers

laravel 5.4 undefined variable in view

I'm kind of new to laravel and trying to pull data from a database but keep hitting an error page saying there's an undefined variable within the view. I'm supposing there's something I'm doing wrong (or not doing) within the controller. So I have…
0
votes
1 answer

Can't retrieve model with findOrFail(). IDE doesn't see this method. What is wrong?

I have method in controller: public function read(ReadRequest $request){ $r = $request; $id = $r->id; $order = null; try{ $order= Order::firstOrFail($id); }catch(ModelNotFoundException $e){ return…
Evgeniy Miroshnichenko
  • 1,788
  • 2
  • 19
  • 30
0
votes
3 answers

ErrorException in HasAttributes.php / Illegal offset type

i have problem in storing data of users ,when user sign up i store half of info in table user and other half in another table ,when hit register butttom i get that error i found that in table user info is stored correctley but in other table nothing…
brain pinky
  • 359
  • 1
  • 4
  • 17
0
votes
1 answer

How to pass a variable to two different view from a controller in Laravel

I am working on developing a social networking site. In my view folder there are two different folders: 1.layout: Layout have app.blade file: This file contain an notification header like fb. example: Notification example Image 2.user : User have…
0
votes
2 answers

Running shell_exec in background on windows using php

I have controller like this public function test() { shell_exec("node node-server\socket.server.js > node.log"); return 1; } but when I run this controller with ajax, status is (pending) and I want show me 1;
paranoid
  • 6,799
  • 19
  • 49
  • 86
-1
votes
1 answer

Laravel trying to store image file in 3 different folder

I'm trying to store image in 3 different folder inside public folder now I'm able to store in two different folder but when I added 3rd folder path but it was not coping in 3rd folder help me to solve this. my two folder copying Working…
-1
votes
1 answer

laravel nested controller with 3 model

is possible to use 3 model in laravel nested controller? this my route now: ... 'supplier' => SupplierController::class, 'supplier.item' => SupplierItemController::class, ... i want to use 3 like this one: ... 'supplier' =>…
-1
votes
1 answer

How to update table records, but only form fields that have data in them?

In my controller, I have my create record method, but I want to edit existing records, but only update the fields that are filled out. I try to only fill out one or two fields on the edit property file, but no matter what field I fill out, it…
JayDev95
  • 777
  • 2
  • 5
  • 18
-1
votes
1 answer

How to get change percentage value in laravel controller?

I want to get value change percentage from $userbalance change to $changebalance, I mean how much percentage change from 2500 to 2000? public function ChangeBalance() { $userbalance = '2500'; $changebalance = '2000'; …
Msu Rubel
  • 29
  • 1
  • 6
-1
votes
1 answer

How to Get data from an API every 2 min and use it in all of project?

I want to build a website which need to get gold price every 3 min and use with this price in many of my controller in my project. how can get gold price from another API and how use this in my controller?
yassin
  • 87
  • 1
  • 11
-1
votes
1 answer

What do callAction do in Laravel controller?

I am maintaining some Laravel 6 code written by my colleges. I find that they overrode the callAction method in controllers and initialise some variables in it. But I can't find the callAction method in Laravel 3-8 documentations. What is the point…
Nelson Luk
  • 171
  • 1
  • 11