#### Category : mysql

Goodmorning everyone, As in the title I find myself developing a web application with Laravel where I need to take the data with a join between two tables. Tables are raccomandata and sap_abilitati where in the raccomandata table the idCliente field is foreign key and refers to the id field of the sap_abilitati table. When ..

how i can do this Ex : select 5 random rows from the 20 most recent row I need do this with eloqunet and get data with query from db not with mapping data I found this query but i cant convert this to laravel eloqunet … Query : select tbl1.* from (select *from DemoTable ..

my first database host in aws and secound database host in diedem server. and I want to reference one column from laravel_1.uesrs table to multiple other database server in employees table . Host: 192.168.0.100 Database:[laravel_1.uesrs]: https://i.stack.imgur.com/Tq5Mm.png CreateUsersTable Schema::create(‘users’, function (Blueprint $table) {$table->bigIncrements(‘id’); $table->string(‘name’);$table->string(’email’); } Host: 10.0.0.12 (different server) Database: [laravel_2.employees]: https://i.stack.imgur.com/QcLY5.png CreateEmployeesTable Schema::create(’employees’, ..

I am working on setinterval which will run an autosave function so that the user do not need to press submit button and it can save automatically, but am stuck on updating the table if user needs to change the value in the table Sourc..

I have page to insert/update invoice writing by LARAVEL & MariaDB Right after insert an item to invoice I call Load Invoice Detail function. The debug show that the dataset return does not contain the new item I’ve just inserted. But I copy the select query to select all items from this invoice in Load ..

I have data with the same invoices number and more than one sub total, the sub total should only be 1 even though there are many invoices number.. How do i make a query for that case? This picture is my query and result in phpmyadmin : enter image description here Thanksss. Sourc..

I am using laravel along with vagrant and homestead, the code from laravel is mapped to the vagrant virtual machine, when I work locally with the code and do migrations to mysql everything is fine, but as soon as I start making database queries like checking the email field with using the unique: users validator, ..

strong textI have a table which has dynamically data , so i handel the dynamic data row wise, now i want a column value where two values are matched of same column on one entery LIKE id rack_id data 1 101 Red 2 101 14CM 3 101 Open 4 102 Green 5 102 14CM 6 ..

I am new to Laravel. I am trying to insert some data into the table of the database at a particular time, say 12 am. What I have tried is: QuoteController.php use IlluminateHttpRequest; use AnomalyStreamsPlatformHttpControllerResourceController; use GuzzleHttpClient; use AppRating; use DB; //use IlluminateSupportFacadesDB; class QuoteController extends ResourceController { public function sendMessage(Request $request) { //dd($request->all()); $current_date .. Read more Has MySQL view ‘histstat’. In MySQL select * from histstat works fine. Laravel model is very simple: class HistStat extends Model { use HasFactory; protected$table = ‘histstat’; protected $fillable = [‘day’, ‘total’, ‘paid’]; } Then I want to get first 14 records of hisstat:$dynamic = HistStat::all()->slice(14); … and execution ends with error SQLSTATE[42000]: ..

Here loading orders data using below code but it takes too much time to load and I’m also using serverSide and there are only 320 data’s something and TTFB are very high and I also tried "pageLength": 30, "stateSave": true, but same result please let me know how i fix this issue. Controller.php $orders = .. Read more I’m trying to get today’s orders by a restaurant. Here is my table structure restaurants id – integer name – string categories id – integer restaurant_id- foreign name – string items id – integer category_id – foreign name – string orders id – integer amonut- double order_items (pivot table) id – integer order_id – foreign .. Read more i has tries to get it by this way but consume long time and feeling work around …$clinic=$user->Clinics->first();$userPerMonth= array(); for ($i=1;$i<=12; $i++){$checkups = Visit::where(‘clinic_id’, $clinic->id) ->whereMonth(‘created_at’, date(‘m’,strtotime(‘-‘.$i.’ month’))) ->whereHas(‘VisitCheckUps’) ->count(); $userPerMonth[$i]=[‘checkups’=>$checkups]; } dump($userPerMonth); Sourc..

I had tried to get it using the below approach, but it takes a long time. Is there a work around? $clinic=$user->Clinics->first(); $userPerMonth= array(); for ($i=1; $i<=12;$i++){ $checkups = Visit::where(‘clinic_id’,$clinic->id) ->whereMonth(‘created_at’, date(‘m’,strtotime(‘-‘.$i.’ month’))) ->whereHas(‘VisitCheckUps’) ->count();$userPerMonth[$i]=[‘checkups’=>$checkups]; } dump($userPerMonth); Sourc.. Read more I don’t know how to address this question properly but my problem is I can’t display my data in my chart using chart.js and laravel. To start with, I have a "sales" table in my database, and it has "total" and "created_at" fields which are the data that I wanted to reflect on my chart. .. Read more // this is my helper function function GetLanguagesWithoutDefault(){$languages = DB::table(‘languages’)->where(‘id’,’!=’,1)->get(); return $languages; } // My Controller code foreach ((array)GetLanguagesWithoutDefault() as$language) { MpInfoLang::updateOrCreate([ ‘parent_id’ => $instance->id, ‘language_id’ =>$language->id, ], [ ‘name’ => $request->input(‘name_’ .$language->id), ‘address’ => $request->input(‘address_’ .$language->id), ‘bio’ => $request->input(‘bio_’ .$language->id), ]); } Note: When i dd $language that .. Read more I am planning to write test for my brand new Laravel package. I am using Orchestra/Testbench laravel recommended library to test my package. I have a BaseTestCase.php which all of my test cases are extending this class. For each test case I am using RefreshDatabase trait to refresh my database migration before running any test. .. Read more The application is hosted in Bluehost in a Shared hosting. I tried executing the below query in phpMyAdmin and the results works fine: SELECT employee_id , floor(Datediff(max(to_date), min(from_date))/365) As diif FROM work_experiences group by employee_id having floor(Datediff(max(to_date), min(from_date))/365) >=15 Below is my Laravel Query builder:$query->groupBy(’employee_id’); $query->havingRaw(‘Floor(Datediff(Max(to_date), min(from_date))/365) >=’.$filterOverralExperienceA); $query->havingRaw(‘Floor(Datediff(Max(to_date), min(from_date))/365) <=’.$filterOverralExperienceB); The above ..

this Error comes after second create new order the first order was created successfully it comes if I had a one order and try to to go to create.blade.php again Column not found: 1054 Unknown column ‘order_id’ in ‘where clause’ (SQL: select * from amount_service where amount_service.order_service_id = 1 and amount_service.order_service_id is not null and ..

I have problem about queries on laravel. here is code on laravel : $tabel_data= AppModelsData::where(‘data_keys’,’element’)->whereJsonContains(‘data_values->trx_type’,’withdraw’)->get(); here is data on mysql: INSERT INTO Data(id, data_keys, data_values) VALUES (‘300′,’element’,'{"id":"300","trx_type":"withdraw","name":"John","date":"2021-09-12","amount":"10","gateway":"USD"}’) the query should be select * from frontends where data_keys = ‘transaction.element’and JSON_CONTAINS(data_values, ‘"withdraw"’, ‘$.trx_type’); but when running the code it changes to select * from frontends where ..
I’m using form request to validate data into update method. I’m trying to validate email as a unique value expect requested user email like this public function rules() { $user =$this->user(); return [ ‘name’ => ‘required|max:255|string’, ’email’ => ‘required|email|max:255|unique:users,email,’.$user->id, ‘restaurant’ => ‘required’, ]; } But it doesn’t work, how to access requested user id .. Read more Please assist me am Novice in laravel I want to limit number of withdrawal a day…for example I have a project where people requested for payment…I want to limit the number of the people that can request a day let say for example 10people request it we pompt a message that today limit reach please .. Read more Please help me am beginner in laravel I want to limit number of withdrawal a day…for example I have a project where people requested for payment…I want to limit the number of the people a day where after 10people request it pompt a message that today limit reach please check back tomorrow Sourc.. Read more In Illuminate/Database/Connectors/Connector.php protected function createPdoConnection($dsn, $username,$password, $options) { if (class_exists(PDOConnection::class) && !$this->isPersistentConnection($options)) { return new PDOConnection($dsn, $username,$password, $options); } return new PDO($dsn, $username,$password, $options); } The above function will execute forever at new PDO($dsn, $username,$password, \$options) at a high packet loss rate network environment. What I want is to not ..