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, ..

Read more

i am trying to pass button from controller to view here i tried this code function sendbutton (){ $order = 1; return ‘<a href="{{ url("user/order/geOrder/") . $order) }}" class="btn btn-primary" style="color:white">Edit Order</a>’ } it render successfully but problem is that my axpecting url should be "https://example.org/user/order/geOrder/1" but i am getting url https://example.org/user/order/create/Order/by/%7B%7B%20url( which is wrong ..

Read more

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..

Read more

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 ..

Read more

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 ..

Read more

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 ..

Read more

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" ..

Read more

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 ..

Read more

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: ..

Read more

Everytime, I create route and controller for it, i have to add it in routes like this. use AppHttpControllersForm; use AppHttpControllersForm2; use AppHttpControllersTestForm; use AppHttpControllersUser; use AppHttpControllersUser_2; use AppHttpControllersTableForm; use AppHttpControllersUserProfileHandle; use AppHttpControllersSessions; how can i stop doing this? I have read about autoloading the classes, but where should I have to make changes to ..

Read more

I have controller recieve 12 request from flutter app, the request is like this: data.map((e) async { Map list = { ‘username’: username, ‘club’: e.club, ‘price’: e.price, ‘surename’: e.surname, ‘id’: e.id, ‘league’: e.leagueName, }; try { var newurl = Uri.parse(url + ‘create_team’); var response = await http.post(newurl, body: jsonEncode(list), headers: { ‘Content-Type’: ‘application/json’, ‘Authorization’: ‘Bearer ..

Read more