Category : mysql

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

Read more

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

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

Read more

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

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

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

Read more

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

Read more

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

Read more

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

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

Read more