Category : parameters

In my laravel (7.x) application, I have a method called _index in different controllers & models with exactly same functionality (fetch the data to display in the grid) and parameters (except 1, that requires an additional parameter called available). So, I created a super method in the base controller, something line this: Controller.php namespace AppHttpControllers; ..

Read more

I setup the url by JavaScript to call a function in controller with only one parameter($RoleID) like this $(document).on(‘change’,’#role’,function(){ $RoleID = $(this).val(); let $url = ‘{{route("Admin.role.permission.LoadMember",’:id’)}}’ $url = $url.replace(‘:id’, $RoleID); $.ajax({ url:$url, success:function(data) { $(‘#member’).append(data); }// end fucntion success }); }); It works ok, Now I would like to do the same with more than ..

Read more

This is my view code <table class="table"> <thead> <tr> <th scope="col">#</th> <th scope="col">Name</th> <th scope="col">Mobile</th> <th scope="col">Address</th> <th scope="col">Note</th> <th scope="col">Actions</th> </tr> </thead> <tbody> @foreach($suppliers as $supplier) <tr> <td>{{$supplier->id}}</td> <td>{{$supplier->name}}</td> <td>{{$supplier->mobile}}</td> <td>{{$supplier->address}}</td> <td>{{$supplier->note}}</td> <td> <div class="btn-group" role="group" aria-label="Button group with nested dropdown"> <div class="btn-group" role="group"> <button id="btnGroupDrop1" type="button" class="btn btn-outline-primary dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Actions </button> ..

Read more

I’m trying to add default parameter to resource routing as per documentation: my code looks like: Route::resource(‘flats’, FlatsController::class)->parameters([ ‘index’ => ‘test_parameter’, ‘create’ => ‘test_parameter1’, ‘update’ => ‘test_parameter2’ ]); but unfortunately all the time when listing the routing it gets like in the screenshot below: please help guide, at what point do I make a mistake? ..

Read more

I am trying to get my locale prefix to work on all my routings. It generally works but I get this issue where the header lang buttons are looking for a parameter from a specific page (I think). Tags from my header component: <li><a href="{{ route(Route::CurrentRouteName(), ‘nl’) }}">nl</a></li> <li><a href="{{ route(Route::CurrentRouteName(), ‘fr’) }}">fr</a></li> <li><a href="{{ ..

Read more

In Laravel, I am trying to pass multiple parameters to a controller through a route, but it is coming up with an error: Missing required parameter for [Route: allRequests.detailsP] [URI: allRequestsDetailsP/{aid}/user/{uid}] [Missing parameter: uid] The view to call the route is: <a href="{{route(‘allRequests.detailsC’, [‘aid’=>$npen->animals_id, ‘uid’=>$npen->user_id] )}}" >D</a> The route is: Route::get(‘/allRequestsDetailsP/{aid}/user/{uid}’, [AllRequestsController::Class, ‘detailsP’])->name(‘allRequests.detailsP’); The controller ..

Read more

When I extend a GET route with a parameter, the page is not loaded completely and there is delay in loading the page, so what is the solution? This is the route Route::get(‘/Report/{sub_date_number}’, [reportController::class,’show_orders_report’])->Middleware(‘isAdmin’); and this is the function definition of show_order_report function in the controller public function show_orders_report($sub_date_number){ Sourc..

Read more

This is my event Right now i’m using laravel 8.26 and pusher 4.1 ”’ class NotifSeller implements ShouldBroadcast { use Dispatchable, InteractsWithSockets, SerializesModels; public $fields; public function __construct($fields) { $this->fields = $fields->toArray(); } /** * Get the channels the event should broadcast on. * * @return IlluminateBroadcastingChannel|array */ public function broadcastOn() { // return new ..

Read more

Use Laravel 5.6, PHP 5.6.4, and MySQL 5.7 I have this variable in the frontend. let arrIds = [1,2,3,4]; In the controller I have: $this->validate($request, [‘arrIds’ => ‘required | array | min:1’]; $ids = preg_replace(‘/[^0-9,]/i’, ”, implode(",", $request->input(‘arrIds’))); $sql = DB::connection() ->select(DB::raw("SELECT * FROM table WHERE id IN (:idParam)"), [‘idParam’ => $ids]) If I use ..

Read more

I want to lazyload the products with a Laravel Eloquent Entity /** * This is in my Orders model */ public function product($lang = ”) { switch ($lang){ case ”: return $this->belongsTo(ViewProducts::class, ‘product_id’, ‘id’); case ‘en_us’: return $this->belongsTo(ViewProductsEnUs::class, ‘product_id’, ‘id’); } } /** * This is what works. But its not lazy */ $orders = ..

Read more

hey people i’m new to laravel and trying to show one company from a list of companies but when i’m click on a company it wil go to the right page but shows up empty(company has no atributes) my route: Route::resource(‘Companies’,AppHttpControllersCompanyController::class); my view(companies) <div class="card-body "> <ul> @forelse($companies as $Company) <li> <a href="{{route(‘Companies.show’,$company)}}"> <label>Name: {{$company->name}}</label><br> ..

Read more

I have a simple dropdown as a livewire component (say component A): <select wire:model="mould_id" wire:change="$emit(‘mouldSelected’, mould_id)" class="form-control w-75 float-left"> @foreach( $moulds as $mould ) <option value="{{ $mould->id }}">{{ $mould->code }}</option> @endforeach </select> The component’s class receives a collection of moulds to display the select, but also, when the mouldsUpdated is fired, the list should be ..

Read more