#### Category : controller

I got a question about PHP compact. In the Laravel controller, I am returning the next values with compact: return view(‘vote.cast’, compact(‘canvote’, ‘opinionClosed’, ‘userVoteDecision’)); I have a problem here however. The variable ‘userVoteDecision’ is sometimes optional, and will not always be set by the controller. Is there a way, to let compact ignore a variable, ..

I Have a database that given to me, and I need to build an API on it but the columns in the table didn’t had a "created_at" & "Updated_at" column and every time I put code into the runtime it gives me this error. SQLSTATE[42S22]: Column not found: 1054 Unknown column ‘updated_at’ in ‘field list’ ..

I want to develop an API with Laravel 8 with resource controller. Previously we used id parameter to edit, delete and get single value from the database. But now, here is given model class as a parameter in show, edit, update and destroy method. How can I use this model class to perform crud operations ..

I have updated Laravel packages using Composer update. But now, I’m getting strange error. Below is error log: 2021-09-15 16:09:35] local.ERROR: Target class [MessagesController] does not exist. {"exception":"[object] (IlluminateContractsContainerBindingResolutionException(code: 0): Target class [MessagesController] does not exist. at /Applications/MAMP/htdocs/utiplhrms/vendor/laravel/framework/src/Illuminate/Container/Container.php:811) [ Sourc..

I am using Laravel 8 and the user has an option to upload their avatar pic. I am trying to set the requirement that the user has to change their avatar if it is the default one which is "/images/company_logo_default.png" inside the database. For some reason it is not saving if the file is uploaded ..

I placed my API controller inside an "API" folder, like this: "../Controllers/Api/V1/ResourceApiController" I just wanted to know what is the generally agreed name for this controller, "ResourceController" or "ResourceApiController"? Sourc..

I have a dashboard that shows 4 chart stats and an area chart. I know it’s impossible to use same URI in routes such as this: Route::get(‘dashboard’, [DashboardController::class, ‘createChartStats’]); Route::get(‘dashboard’, [DashboardController::class, ‘createChartMonthlyInvoicesAndSales’]); I haven’t created the createChartMonthlyInvoicesAndSales() method yet, but is there a way I can still use dashboard URI so I just can display ..

I created a laravel rest api project in my local pc with php version 8.0.3. Everything works fine in the localhost. But when I upload the files to cpanel. Below error occurs. My cpanel php version is 7.4.3. I cleared the cache before uploading. Here’s the error I get: { "message": "Target class [AppHttpcontrollersAdminAuthController] does ..

Just wondering where to position the pagination() of Laravel here in my query() in order for it to work. I tried adding it in the end of my $all_procedures. public function fetchprocedure(Request$search_procedure){ $filter_procedure =$search_procedure->input(‘search_procedure’); $all_procedures = HmsBbrKnowledgebaseProcedure::query() ->when(is_null($filter_procedure), function ($query) {$query->where(‘bbr_procedure_id’, ‘>=’, 1); }) //iLike is case insensitive ->when(!empty($filter_procedure), function ($query) use ..

I tried to create Incident chart which can change the periods (Last 7 days/Last 30 days/Last 90 days). However, I tried to pass it via ajax data to controller but I got NULL value there. How can I solve it? Below is my code. Blade: <div id="periods" class="btn-group float-right"> <button class="btn dropdown-toggle p-0" type="button" data-toggle="dropdown" ..

I had some problems with the task. I’m not very good with javascript. Please help. I display categories as form and I want to when the form to be typed to display products that are set for each category and sub-category. In the next task I have to make sure that when the form is ..

Hi I am not having much luck to try and use Intervention with an Image model. Really beginner to this, and have tried many many many changes to the code but not finding result, I have tried also to read online how to pass Intervention into model or model into Intervention but cannot find many ..

Hi I am not having much luck to try and use Intervention with my PostImage model. Really beginner to this, and have tried many many many changes to the code but not finding result, I have tried also to read online but cannot find many information. First I make image with Intervention, then try to ..

I’m working with this case where I need to instantiate an object after a form is submitted in a controller. Everything’s working fine until I call this object (as a property) from another method. It appears to be null. If I intentiate the object from constructor method, I have no problem at all. I can’t ..

Salam i am new in laravel i try to show & store data and index() and store() functions doesn’t work!! its display as result 500 | SERVER ERROR this is the controller code: namespace AppHttpControllers; use AppModelsEnseignant; use IlluminateHttpRequest; use IlluminateHttpResponse; class EnseignantController extends Controller { /** * Display a listing of the resource. * ..

public function fetchdrug(Request $search_drug){$filter_drug = $search_drug->input(‘search_drug’);$all_drugs = HmsBbrKnowledgebaseDrug::selectRaw(‘DISTINCT ON (drug_code) drug_code, drug_name, JSON_AGG(drug_dosage) AS dosage_list’) ->GroupBy(‘drug_code’, ‘drug_name’) ->orderBy(‘drug_code’, ‘ASC’) ->get(); return response()->json([ ‘all_drugs’=>$all_drugs, ]); } I am using JSON_AGG to retrieve multiple lines of drug_dosage and combine them into one, but I am getting a bracket and quotation in my output, how do .. Read more I am trying to use DISTINCT ON to show only one drug_code and to CONCAT the drug_dosage onto that one distinct drug_code here is the output without CONCAT:$all_drugs = HmsBbrKnowledgebaseDrug::selectRaw(‘DISTINCT ON (drug_code) bbr_drug_id, hospital_id, drug_code, drug_name, drug_dosage, display_flag’) ->orderBy(‘drug_code’, ‘ASC’) ->get(); as you can see, it works without a problem, but I am getting ..

I have a table displayed in my blade that shows a students score. The student score is displayed based on the calculation that I did in my controller. So I need to filter the table based on the score using checkbox either it more than 50% or less than 50%. The default will be both ..

I had the FirstController as follow stored on the Http/App/Controllers/Orders: class FirstController extends _BaseController { … public function getOrders() { Log::info("Orders"); Log::info(json_encode($this->request->all()));$orderId = $this->request->get(‘orderID’);$invoice = $this->request->get(‘invoice’);$zoneID = $this->request->get(‘zoneID’); … } } And I tried to get the$zoneID value into my Custom Class (below I di so far) stored in the Http/App/Custom/Service: ..

I’m adding a global handler in Handler.php. I need to kind of reload the page without having for the user to redo the whole operation. Sourc..