Category : mysql

how do I hasMany relationship, get the last 5 users, I try to use model and witch hasMany the relation appears empty. I have already done many tests, I always have problems with the relationships when obtaining the last 5 users in each query Query: $minute = Minute_Report::Query()->whereBetween(‘minutos.fecha’, [$from, $to]) ->join(‘clients’, ‘minutos.cliente’, ‘=’, ‘clients.id’) ->join(‘users ..

Read more

I’m working with Laravel 8 to develop my project and I have made this Migration: public function up() { Schema::create(‘activation_codes’, function (Blueprint $table) { $table->id(); $table->unsignedBigInteger(‘user_id’); $table->foreign(‘user_id’)->references(‘id’)->on(‘users’)->onDelete(‘cascade’); $table->string(‘code’); $table->boolean(‘used’)->default(false); $table->dateTime(‘expire’); $table->timestamps(); }); } And at the Model I added this: protected $fillable = [‘user_id’,’code’,’used’,’expire’]; public function scopeCreateCode($query, $user) { $code = $this->code(); return $query->create([ ‘user_id’ ..

Read more

I have the following eloquent collection: $cars = Car::with([‘model’])->get(); I also have a mysql stored procedure that calculates some measure based on a date range: $getMeasure = DB::select( ‘CALL measure("’.$start_date.’", "’.$end_date.’")’ ); The two columns resulted from the procedure are car_id and measure. Is it possible when selecting the cars to also get the measure ..

Read more

I am trying to copy the data from one database to another database on a different server. The databases are identical in structure. From searching around I have tried using the insertUsing() method in Laravel. $new_connection = DB::connection(‘mysql2’); //Insert Using requires an array of columns $column_list = Schema::getColumnListing(‘users’); //This is my select statement $select = ..

Read more

I’m new on this subject, I have one table called Users and that has a column called department_id I have another table called tasks and it has a column called user_id and completed_at I would like to know how many tasks were completed by each department please help me to do it in laravel Query ..

Read more

I want to insert " [email protected]#$%^&*()?<>:| " this string into my table but when I hit save it inserts only this much in table [email protected]#$%^, rest of the characters doesn’t store in the table. Here is my laravel controller code public function store(Request $request) { $x = $request->get(‘task_name’); DB::insert(‘insert into tasks (task_name) values (?)’, [$x]); ..

Read more

My Laravel application (version 5.0.33) has suddenly started throwing the following error: local.ERROR: exception ‘PDOException’ with message ‘SQLSTATE[HY000]: General error: 2014 Cannot execute queries while other unbuffered queries are active. Consider using PDOStatement::fetchAll(). Alternatively, if your code is only ever going to run against mysql, you may enable query buffering by setting the PDO::MYSQL_ATTR_USE_BUFFERED_QUERY attribute.’ ..

Read more

how i can get data from modal which already checked here is my modal <div class="modal fade" id="modalTT" tabindex="-1" role="dialog" aria-labelledby="staticBackdrop" aria-hidden="true"> <div class="modal-dialog modal-dialog-scrollable modal-xl" role="document"> <div class="modal-content"> <div class="modal-header"> <h5 class="modal-title" id="exampleModalLabel">add</h5> <button type="button" class="close" data-dismiss="modal" aria-label="Close"> <i aria-hidden="true" class="ki ki-close"></i> </button> </div> <div class="modal-body"> <div class="table-responsive"> <table class="table table-hover table-borderless cssTable"> <thead ..

Read more

I hosted my Laravel project on Namecheap but its displaying HTTP ERROR 500, when I complained to the Namecheap customer service, they showed me the error log message: PHP Fatal error: Uncaught Error: Call to undefined method IlluminateSupportCollection::getArrayableItems() in /home/kroooaux/kroofing/vendor/laravel/framework/src/Illuminate/Collections/Collection.php:31 The project is working perfectly offline with my Xampp but I don’t know why it’s ..

Read more

I’m using an MySQL database to store the input of a HTML tag: . I want to fill in some HTML input fields with some Java by doing the following: <script> document.getElementById(‘ownName’).value = "{{$userFirstName}} {{$userSurname}}"; document.getElementById(‘ownEmail’).value = "{{$userEmail}}"; document.getElementById(‘managerName’).value = "{{$managerFirstName}} {{$managerLastName}}"; document.getElementById(‘managerEmail’).value = "{{$managerEmail}}"; </script> The script as it stands above is inserted in ..

Read more