#### Category : mysql

I have a User, who can create a membership. On the database, the membership has an expires_at, that I use on the frontend to display "Active" or "Inactive" depending on that time. I want some statistics. Newly created memberships are quite easy to handle, using the created_at field. When it comes to "active memberships", I’m ..

I’m currently working with an Activities table which has Thread and Replies records associated with it. When I try to join the tables, I get a mix and match and both records and it doesn’t return individual records, but with records containing both Thread and Reply "body" field. I’m hoping someone can see what I’m ..

I am working on a Laravel project that uses several models with plural database names. In this example, the model: class RedCar extends Model Is supported by the table: red_cars I have another model called Dog that has a belongsToMany relationship: class Dog extends Model { public function red_cars() { return $this->belongsToMany(RedCar::class) ->select( array(‘name’,’description’) ); .. Read more I have wallets table like that: user_id amount currency 1 100 EUR 2 50 USD 2 200 AUD 1 120 EUR So I need something like that: User::select(‘users.*’, ‘wallets.amount’) ->leftJoin(‘wallets.amount as wallets.eur’, [[‘wallets.user_id’, ‘=’, ‘users.id’], [‘wallets.currency’, ‘=’, ‘eur’]]); ->leftJoin(‘wallets.amount as wallets.usd’, [[‘wallets.user_id’, ‘=’, ‘users.id’], [‘wallets.currency’, ‘=’, ‘usd’]]); To explain more, I need query which will .. Read more I’m using mariadb and laravel for a project, I’m a fresh install of POP Os and using version 20.04, mysql version: mysql Ver 15.1 Distrib 10.3.22-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2 If i want to migrate my database i need to do this: sudo php artisan migrate If i want to insert data to .. Read more Updated: Hello my mysql install is broken i can’t uninstall or reinstall them i’m stuck. Os: POP Os 20.04 LTS Mysql: mysql Ver 8.0.21-0ubuntu0.20.04.4 for Linux on x86_64 ((Ubuntu)) Problem I have installed mysql properly and started to using them in local env, but if i wanted to connect me to mysql with this command: .. Read more I need to get the most updated distinct records of people. ID Name Balance Last Update ——- ——- ——- ——- 1 John 2500 2020-09-10 2 Ali 3900 2020-09-12 3 Steve 2000 2020-09-17 4 Ali 4500 2020-09-17 I need to get a list of unique Names with their most updated balance. I am using Laravel and .. Read more I am trying to submit form data to a database using Jquery Ajax, but I get the error message. It seems like the values of the input fields are not received at the Controller end, which is why it is not sent to the database for storing. Here is a brief description of what I .. Read more I’m currently writing a laravel application (7.4) and haven’t had that many problems, then I cam back from the just gone weekend, booted up the local environment with artisan serve, and I’ve gotten the following; SQLSTATE[HY000] [2006] MySQL server has gone away (SQL: select * from actions where date(time) = CURDATE() and type = hitBudget .. Read more I’m sending this data to the view part that is written in view but isn’t displayed, do you think?$itemsCount = DB::table(‘items’) ->groupBy(‘level_id’) ->selectRaw(‘level_id, count(*) as type’); $ItemsMdCount = DB::table(‘items’) ->groupBy(‘project_model_id’) ->selectRaw(‘project_model_id, count(*) as type’); return view(‘project.view’, compact(‘users’, ‘itemsCount’, ‘itemsMdCount’)); And in vue I make the display {{ itemsCount }} How can I send the .. Read more Error Class ‘DatabaseFactoriesOpportuniyFactory’ not found at C:laravalforestvendorlaravelframeworksrcIlluminateDatabaseEloquentFactoriesFactory.php:650 646▕ public static function factoryForModel(string$modelName) 647▕ { 648▕ $factory = static::resolveFactoryName($modelName); 649▕ ➜ 650▕ return $factory::new(); 651▕ } 652▕ 653▕ /** 654▕ * Specify the callback that should be invoked to guess factory names based on dynamic relationship names. 1 C:laravalforestvendorlaravelframeworksrcIlluminateDatabaseEloquentFactoriesHasFactory.php:15 IlluminateDatabaseEloquentFactoriesFactory::factoryForModel("AppModelsOpportuniy") 2 C:laravalforestdatabaseseedersOpportunitySeeder.php:18 AppModelsOpportuniy::factory("AppModelsOpportuniy") [error shows .. Read more Can someone help me to convert this query into Laravel ELOQUENT? The query is below on the screenshot link and also on comment section DB::select(‘SELECT t1.* FROM messages AS t1 INNER JOIN ( SELECT LEAST(sender_id, receiver_id) AS sender_id, GREATEST(sender_id, receiver_id) AS receiver_id, MAX(id) AS max_id FROM messages GROUP BY LEAST(sender_id, receiver_id), GREATEST(sender_id, receiver_id) ) AS .. Read more I have a problem with a query. in posts table, i have posts.id, then, in reviews table, i have posts_id(foreign key -> posts.id), reviews.id. i want to query those posts_id which doesn’t exist in reviews table(post_id). i am using laravel query builders. i am trying like ->$r = DB::table(‘reviews’) ->select(DB::raw(‘count(id) as rev_count, posts_id’)) ->groupBy(‘posts_id’) ..

I would like to calculate the apartments in the project according to the floor. How could I do that? This is db table->id(); $table->unsignedBigInteger(‘project_building_id’)->nullable();$table->unsignedBigInteger(‘project_model_id’); $table->string(‘apartment_number’)->nullable();$table->unsignedBigInteger(‘level_id’)->nullable(); Leve_id is based on the floor But I would like that depending on project_model_id E.g: I have a 6-story building. Those 6 floors each assigned apartments. I would ..

Im new to laravel and I cant seem to download the pdf of my blade php file. Please help me out! Thank you! This is what I get If i click my "Export to PDF" button in my productlist.blade.php: ErrorException Undefined variable: products (View: C:xampphtdocslaravelproductcrudresourcesviewsproductlist.blade.php) This is my product controller file: <?php namespace AppHttpControllers; use ..

So me and a friend are working on a admin-view for user management. I wanted this view to option to be able to delete users by clicking a button. The userlist itself looks like this: @section(‘main’) @csrf <ul class="collapsible"> @foreach($users as$user) <li method="POST" action="delete"> <div class="collapsible-header"><i class="material-icons">face</i>{{$user->fname}} {{$user->lname}}</div> <div class="collapsible-body" id="{{$user->id}}"> <p>Adresse: {{$user->address1}}, {{$user->postalcode}} .. Read more I am developing an app with Laravel + MySQL for online exam assessment. A lot of users submit their response at the same time (within the span for few mins) so there is heavy load on the database server. I am getting several General error: 1205 Lock wait timeout exceeded; try restarting transaction during many .. Read more Could someone help me with the following code please? I am using javascript to add a dynamic list using dropbox. In the first dropbox it works fine but in the second it only gives one item as shown enter image description here enter image description here <script type="text/javascript">$(document).ready(function(){ var postURL = "<?php echo url(‘/admin/service/{{$cust_id}}’); .. Read more I want to consult you If I have a built-in Laravel project and want to add a messaging feature that will have big traffic, I thought that using a NoSQL database with MySQL database may be better for the MySQL database in many ways like: Freeing up storage (as the data that will be stored .. Read more I am using eloquent where has relation in 3 global scopes and these scopes cause a significant performance drop this query takes about 140 seconds on the server to process!! this is the globalScopes protected static function boot() { parent::boot(); if ( !auth(‘admin’)->check() ) { static::addGlobalScope(new DoesntHaveForbiddenArtistScope()); static::addGlobalScope(‘has-artist’, function (Builder$builder) { $builder->whereHas(‘artists’); }); static::addGlobalScope(‘has-mp3’, .. Read more I want to know how can I write These two Eloquent Queries into raw SQL? also Is there a way to convert the Eloquent series into raw SQL series so that I could use those? public function items() { return$this->belongsToMany(Product::class, ‘order_items’, ‘order_id’, ‘product_id’)->withPivot(‘quantity’, ‘price’); } public function user() { return \$this->belongsTo(User::class); } Sourc..

let’s say I have 2 pages. On the first page I have an icon with a house and on the second page details about the project and below a menu with several pages. When I click on that box, how can I make it go to that page and have that tab open there? https://i.imgur.com/fJdyk6x.png ..