Category : laravel

Here’s my JSON and I want to refactor those JSON in laravel [ { "TIMESTAMP": "2021-06-09 13:13:26", "COL1": "10", "COL2": "20", "COL3": "30" }, { "TIMESTAMP": "2021-06-22 13:13:26", "COL1": "20", "COL2": "30", "COL3": "40" }, { "TIMESTAMP": "2021-06-21 13:13:26", "COL1": "1", "COL2": "2", "COL3": "3" }, { "TIMESTAMP": "2021-06-20 13:13:26", "COL1": "40", "COL2": "50", "COL3": ..

Read more

I have fields in the table most_viewed and top_rated $most_viewed_posts = Blog::where(‘most_viewed’, 1)->orderBy(‘created_at’, ‘desc’)->get(); $top_rated_posts = Blog::where(‘top_rated’, 1)->orderBy(‘created_at’, ‘desc’)->get(); $featured_collection = collect(); foreach ($most_viewed_posts as $most_viewed_post) $featured_collection->push($most_viewed_post); foreach ($top_rated_posts as $top_rated_post) $featured_collection->push($top_rated_post); $featured_posts = $featured_collection->sortBy(‘id’, SORT_NUMERIC)->reverse()->chunk(2); What i’m trying to accomplish here is im chunking the results into 2. Because Im displaying it like on ..

Read more

I have a page controller which is used to control what template/view is displayed based on the URI requested. If the URI matches the ‘slug’ field in the Database then the controller serves up the related template/view that is associated with that page. There are separate Pages Model and Templates Model that are related via ..

Read more

I’ve been trying to load all of my data when the time I log in. Currently, I’ve only managed to display data through the console through vuex file. I just want to achieve this because wherever it loads all data when login, it will easier for me to call every function on every page. I ..

Read more

I am trying to create procedure migration in laravel but I am getting syntex error every time I tried so but didn’t make it work Below is the code $this->addSql("CREATE PROCEDURE Type_Store_Sync(IN name_it VARCHAR(255), IN guid VARCHAR(32), IN type VARCHAR(10), IN orgid INT(11), IN scheme VARCHAR(6)) LANGUAGE SQL BEGIN CALL mysql.lambda_async( ‘arn:aws:lambda:eu-west-2::function:triggersync’, CONCAT(‘{ "name" : ..

Read more

I want to use pagination for my page, so I added this at the Controller: $suspendeds = Order::where(‘status’, ‘awaiting’)->latest()->paginate(1); return view(‘profile.index’, compact(‘suspendeds’)); And on the Blade: {{ $suspendeds->links() }} But it looks like this somehow: So my question is, how can I properly load this pagination? Do I need to do change the css styles ..

Read more

To protect and authenticate all incoming routes in Laravel using Sanctum, we have to attache the sanctum authentication guard to our routes within routes/api.php route files: Route::middleware(‘auth:sanctum’)->get(‘/user’, function (Request $request) { return $request->user(); }); My question is about the middleware key auth:sanctum. Where is it defined/registered? Sourc..

Read more

I am new to Laravel and Lumen. I am developing an app to download file using lumen. I want to send id with url and after searching to database, get the $filename. with that filename use it to download that file. my code is bellow: public function getFile($id){ $filename = app(‘db’)->select("SELECT image FROM authors WHERE ..

Read more

laravel slowing down over thousand data, if i call the helper function in foreach loping over thousand data it slow down and take lot of time to load, i tried chunking the data still same issue. my helper code is below,if i call the helper function in a controller it takes sometimes 20minitues to load ..

Read more

When I route:list all routes in the system, I find some of the routes have Closure middleware. Although I did only assign api and auth a middlewares api.php Route::post(‘api/favorites/{post}’, ‘api/favorites/{post}’)->middleware(‘auth’); Output | Method | URI | Action | Middleware ————————————————————————————- | POST | api/favorites/{post} | [email protected] | api,auth,Closure Sourc..

Read more

I have relation like this: DB relation I have a code in my model that retrieves me just one parent: public function AllParents() { return $this->belongsToMany($this, ‘parent’, ‘product_id’, ‘parent_id’) ->select(‘parent’, ‘name’); } I get it in my controller like this: private function product(Product $product) { return $product->Product() ->with(‘AllParents’) ->get(); } Finally I need data like ..

Read more

I want to do email testing send fake data for partner registration. I create another route and another method in BackendDevelopentController.php and in web.php to run in browser. when I run in browser I get an error Class ‘AppHelpersGeneralMailHelperRoute’ not found below is my code: web.php namespace AppHelpersGeneralMailHelper; use AppHttpControllersLanguageController; use AppHttpControllersBackendDevelopmentController; use AppHelpersGeneralMailHelper; Route::get(‘/email/register-partner’, ..

Read more

I am using http://www.daterangepicker.com/#usage package and currently facing some difficulties in clearing the selection. Based on the documentation, there is a clear option but it doesn’t work/cleared after I click to apply button. This is the codes: $(function() { $(‘input[name="datefilter"]’).daterangepicker({ autoUpdateInput: false, locale: { cancelLabel: ‘Clear’ } }); $(‘input[name="datefilter"]’).on(‘apply.daterangepicker’, function(ev, picker) { $(this).val(picker.startDate.format(‘MM/DD/YYYY’) + ‘ ..

Read more

in my code is enter image description here and then when I click to edit or delete I found 404 not found on my website like this one this is an error problem for me and in code route web.php Route::get(‘/rekaman/blog/edit/{$id}’,’[email protected]’); Route::get(‘/blog/{$id}/hapus’,’[email protected]’); and then this my code for BlogController public function edit($id) { $artikel = ..

Read more

I have two similar methods in my controller: First method: public function parseDataLayerEvent() { $events = $this->pixel_log->data[‘dataLayer’]; if (!is_array($events)) { throw new Exception(‘dataLayer is not an array’); } foreach ($events as $event) { if (!isset($event[‘event’])) { continue; } if (!isset($event[‘ecommerce’])) { continue; } if (!isset($event[‘ecommerce’][‘purchase’])) { continue; } $purchase = $event[‘ecommerce’][‘purchase’]; $validator = Validator::make($purchase, [ ..

Read more

I have two similar methods in my controller: First method: public function parseDataLayerEvent() { $events = $this->pixel_log->data[‘dataLayer’]; if (!is_array($events)) { throw new Exception(‘dataLayer is not an array’); } foreach ($events as $event) { if (!isset($event[‘event’])) { continue; } if (!isset($event[‘ecommerce’])) { continue; } if (!isset($event[‘ecommerce’][‘purchase’])) { continue; } $purchase = $event[‘ecommerce’][‘purchase’]; $validator = Validator::make($purchase, [ ..

Read more