YuraLons YuraLons
7
How do I correctly add fields from a post form to other tables? I have a post table containing records, it is necessary to specify data in 4 other tables (store1, store2, store3, store4). I thought I should do it this way: [email protected] functi...
rafaeladi rafaeladi
0
So currently ive been working on a project and this is one of the problem that i had. I want to have this data in my application and want the data to be viewed as a progressbar in my view. I want the data to be like this | CaseName | Duration | Verd...
Spyralex Spyralex
3
I have three tables: Products, Categories and a pivot one CategoryProduct. I have an attribute updated_by and I want this to be automatically set to Auth::id() upon all create/update requests. So far I am able to save data by using the sync() method...
I'm curious that is possible to search in array with array. If yes, how? I have a filter with these values: ["value1","value2"] In the database I have these values: ["value1","value2","value3"] or [&q...
handisb handisb
5
I need to arrange my data in a way that might need a different structure on top of Laravel. The schema that I am talking about will allow more flexibility in the fields of our models. We want to do this because we want to be able to more simply and r...
Haseeb69 Haseeb69
1
i have three tables Permit ( pid, userid , companionid) , User(id,name etc) , Companion(cid, userid1,userid2,userid3,userid4 which are foreign keys to user table) here are my relations in models Permit: public function user() { return $th...
i try to get articles, and some articles have dublicated title i want to groub by title $articles=Article::select( 'id', 'img', 'created_at', 'title_ar', )->groupBy('title_ar')->l...
theone theone
12
$this->hasMany('App\Models\DispatchLoadsPickupInfo','load_id') ->whereBetween('date',[Carbon::now()->subDays(30), Carbon::now()->addDays(30)]); I'm using the above query But my date is not in the prefect format so the weherbetween not ove...
maltekiefer maltekiefer
6
Good morning, I have a question about querying data from the database, in conjunction with ->with(). Namely I have a table users, files and user_files. In the table files all files from the whole application are stored. user_files stores the useri...
reaz replied
Solved
laracoft laracoft
2
Hi, I like to ask, if we don't specify our field in $fillable, How do we assign a value to the field? I mean, what's the opposite of Mass assignment? What are the points of consideration when deciding whether to place a field into $fillable? The Lar...
JustSomeoneWhoLovesWatchingJapaneseWeatherRepotto JustSomeoneWhoLovesWatchingJapaneseWeatherRepotto
3
Let's say I have three tables. table A -------------------- id description table b -------------------- id a_id description table c -------------------- id b_id description Whenever I do $a->save(); $a->b()->save(); $a->c()->save();...
croftCoder croftCoder
2
working on a directory listings app and faced with this scenario: how do I select the various categories through the businesses found in a district and the same for a region as well without duplicates? models and relationships are as follows: Region...
jrdavidson jrdavidson
2
I enlisted the HasManyDeep package written by Jonas Staudenmeir located here: https://github.com/staudenmeir/eloquent-has-many-deep.I'm retrieving all courses that were taken during a semester. As you can see there is not a has many relationship betw...
baspax1 baspax1
11
Hi i have two tables customers and charges I want to sort the third field that will be balance on customers foreach blade, as you can see i comment out the ->selectRaw('*, total_charges - total_payments as balance',) Because i get error that field...
grozavule grozavule
1
I have a form that uploads multiple files. Somehow the controller that handles the request creates two database records for each uploaded file. The HTTP request shows the proper number of files sent. The $request object passed into the controller met...
zakiaziz zakiaziz
3
I'm on laravel 5.1 and after looking through the docs and noticed there is the ability to "sync" many-to-many relationships. I have a polymorphic many-to-many and goes something like this: class Team extends Model { public function memb...
Jakub003 Jakub003
1
This is probably a huge newb question, but I can't seem to find any tutorials or examples for how to write out the livewire public function to make the group thing work. Any links to a guide would be much appreciated as well :) In this documentation...
Hammadrashid Hammadrashid
3
I'm getting the same response below when find category by id $category = App\Category::find(12)->first(); // or this $collection = collect((object) $category); { "id": 12, "name": "Bearings", "description&q...
ldommer replied
Solved
DaniloP DaniloP
4
I don't know how to get the data from this foreign key I have followed all steps from the documentation, but I still don't know what needs to be done I've tried all the possible solution that i found online and still i don't get it This is my product...
I have two models: User and Department Department hasMany User User belongsTo Department I want to sort the users based on department name with pagination. But results are still not sorted. $sortType = request("sortType") ?? "asc&quo...
binggle binggle
3
Manager belongsTo Country . Manager BelongsTo Post. Post BelongsTo Cat. So Cat hasManyThrough Manager. Country class extends Model { function managers(){ return $this->hasMany( Manager::class ); } } Manager class extends Model {...
binggle replied
Solved
stefanhaerter stefanhaerter
2
Dear all, I have a Use Case where I execute several Database Changes in a Function. I would like to provide the user with a possibility to rollback the action for 30 or 60 seconds. Is there a chance to rollback the already committed Database Transact...
jrdavidson jrdavidson
4
I have a deep count that I'm need to retrieve and would like some help figuring this out if anyone is willing to look at the current code and the database structure and assess what I have so far. I know the first parameter of the withCount method if...
Haseeb69 Haseeb69
4
i have a timeofvisit field in table permits of time type (e.g 14:45:00 ) i'm trying to get all records where time is less than current time but im not getting any . AM i using this right? $permitsdata1 = Permit::whereRaw('Time(timeofvisit) <= CUR...
vincent15000 vincent15000
7
Hello, I have a problem again with count and group by. Here is the mysql query. select societies.name, trainings.title, count(employees.id), alerts.* from alerts inner join employees on employees.id = alerts.employee_id inner join trainings...
Hello everyone ! I'm trying to make some custom factory for my project, the goal is to be able to have in memory objects with their relations and being able to save them on demand. For context it's because sometimes in my app I'll need to generate so...
Dibbert replied
Solved
baspax1 baspax1
2
Hi i have a problem with my search query, im trying to search charges->tasks (main table) , customer->name , user->name (foreigns) the charegs->tasks and user->name filtering data on my search, the customer->name doesnt filtering...
baspax1 replied
Solved
vincent15000 vincent15000
2
Hello, Is it possible that a scope is applied to a relationship ? My tables. users : id, name bicycles : id, name quotations : id, bicycle_id, user_id And the relationship in the Quotation model. public function bicycle() { return $this->belongs...
denisromanenko denisromanenko
1
Im trying to somehow achieve next thing: I want to create system where users can create not-predefined objects with not-predefined fields. For example: users can create Products, Trucks, containers, but also Books, Publishers - anything, in simple wo...
durairaj durairaj
3
Enrollments model: public function schedule_weeks() { return $this->hasMany( Enrollment_weeks::class, 'enrollment_id', 'id' )->where( 'enrollment_weeks.status', 'ACTIVE' ); } Enrollment_weeks Models: public function week_classes()...
iamamirsalehi iamamirsalehi
4
HI there, in the code below when I want to firstOrCreate all the data, it actually gives me an error and does not let me do that but when I pass singly the data it works, What can I do to firstOrCreate all the data? thanks in advance $data = [...
gmanish gmanish
13
Now this, from what I can see, should have been simple. I want to be able to delete multiple records from the database. I have the id's of all the records I wish to delete. I call the resource.destroy route using comma separated list of ids (id is of...
laracoft laracoft
9
I have the following test that intermittently fails. It always passes if I put a breakpoint before asserting, seems to be a race condition, but I can't pinpoint where. Tests are being done on a real MySql database. I also tried both $updated = $d->...
jbolecke jbolecke
3
I use the 'encrypted' eloquent cast to encrypt and decrypt columns in a mysql database: https://laravel-news.com/eloquent-encrypted-casting Is there a way or a general rule to determine how big the size of the mysql column which contents gets encrypt...
i have author table, books table, and pivot table author_book. data saved successfully and displayed successfully. but in edit i want to get all books and if author have spesific book must marked as checked i try this code but not work //eloquent...
Create a New Discussion Button