Category : php

so this is my route Route::group([‘prefix’ => ‘{locale}’],function(){ Route::get(‘/’,’[email protected]′)->name(‘post’)->middleware(‘setLocale’);}); for example, if I chose es in lang or any other language I want to go to Route::group([‘prefix’ => ‘{locale}’],function(){ Route::get(‘/’,’[email protected]′)->name(‘post’)->middleware(‘setLocale’);}); **so I can fetch data from another JSON file with another language ** Sourc..

Read more

What I have: I have table with a unique date column. id date 1 2021-09-01 2 2021-08-01 3 2021-07-01 4 2020-04-01 5 2020-03-01 6 2020-12-01 I pull data based on a month and year from a GET parameter. DB::table(‘budgets’)->whereMonth(‘created_at’, $request->get(‘month’))->whereYear(‘created_at’, $request->get(‘year’))->get()->first(); I do a check to see if a previous month is available in table ..

Read more

I never face this issue with creating laravel new project but today I face it unexpectedly for the first time ! I am using laravel 8. When I run laravel new project It shows me error saying Error Class ‘SymfonyComponentTranslationLoaderArrayLoader’ not found Here is full error message on pastebin https://pastebin.com/YqheTXe1 Sourc..

Read more

I have a project on a Cpanel host and when I edit and upload some of my files it will delete all spaces in the file and the program will be got errors. for instance, it converts this code : @section(‘content’) <div class="container-fluid"> <div class="row"> </div> </div> to this code : @section(‘content’)<div class="container-fluid"><div class="row"></div></div> Source: ..

Read more

I want to redirect to my new post when I created a new post in Laravel But I get a ArgumentCountError Too few arguments to function AppHttpControllersArticlesController::store(), 1 passed in C:xampphtdocsforumvendorlaravelframeworksrcIlluminateRoutingController.php on line 54 and exactly 2 expected How can I fix it? Thanks web.php <?php Route::resource(‘articles’, ArticlesController::class); Route::get(‘/’, [ArticlesController::class, ‘index’])->name(‘root’); Route::resource(‘articles.comments’, CommentsController::class); ArticlesController.php public ..

Read more

I have a table of data with such data [{"datetime":"2021-09-28 03:00:00","hour":"03:00:00","value":0.5}, {"datetime":"2021-09-28 03:00:00","hour":"03:00:00","value":0.6},….] How do I group the data by "hour", and find the average of each hour? I’m looking for output: [{"hour":"01:00:00","avg":"0.55"},….] Sourc..

Read more

I have an array with the ID of the services, and there is an array with the Product. They are related to each other as Many To Many. For expamle: Product [1, 2, 3] Service [2, 3, 6] Table product_id service_id 1 2 2 3 3 8 How can I check whether a product belongs ..

Read more

How to get heading from different table on export? class Kriteria_Export implements FromCollection, WithMapping, WithHeadings { public function collection() { return Alternatif::all(); } public function map($alternatif) :array { return [ $alternatif->nama_alt, ]; } public function headings(): array { return [ ‘Nama Alternatif’, ]; } } Tabel Alternatif Tabel Kriteria When Export I want like this ..

Read more

I have two tables properties (id, name, address, created_at, updated_at) bookings (id, property_id, booking_date, total_amount, comission, created_at, updated_at) Property.php model has this relation public function bookings() { return $this->hasMany(‘AppModelsAirbnbBooking’,’property_id’,’id’); } I want to return an JSON response (or eloquent collection) like below [{ "property_id": 1, "address": "Property ABC", "bookings": { "2021": { "Jul": [ { ..

Read more

I’m using SPATIE laravel-activitylog I followed all the instructions but still it only log the Create function not update while using it on a Modal My Modal <?php namespace AppModels; use IlluminateDatabaseEloquentFactoriesHasFactory; use IlluminateDatabaseEloquentModel; use SpatieActivitylogTraitsLogsActivity; class Contact extends Model { use HasFactory, LogsActivity; protected $fillable = [ ‘comp_name’, ‘cont_name’, ‘cont_email’, ‘cont_number’, ‘created_by’, ‘updated_by’, ]; ..

Read more

I have problem with my php on mac, previously I had 2 php versions php7.3 and php7.2. for some reason I uninstalled them then reinstall php7.2. when I run brew link [email protected] and php -v I’m getting message dyld: Library not loaded: /usr/local/opt/tidy-html5/lib/libtidy.5.dylib Referenced from: /usr/local/opt/[email protected]/bin/php I already run command brew update brew upgrade php ..

Read more

I’ve been investigating Laravel Octane as a possibility for performance improvements in an existing Laravel application and have found every 4000-5000 requests up to 15 requests are returning as failed. I currently have the laravel application deployed and running octane through supervisor with the following configuration in /etc/supervisor/conf.d/laravel-octane-worker.conf : process_name=%(program_name)s_%(process_num)02d command=php /var/www/html/artisan octane:start –server=swoole –workers=8 ..

Read more

I am very new to PHP(Laravel) and got some project. This is the explanation: One device exists someplace and it gathers some data. My project needs to log in to the device and need to get data by JSON file. I used this code for that work: $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "$url.0.json"); curl_setopt($ch, CURLOPT_USERPWD, ..

Read more