#### Category : laravel

I have a date string and start time as a string too, im first combining the dates with PHP date() object, then im parsing to a Carbon object, when I return the carbon object I get a different dateTime than the expected result, for example $combinedDt = 2021-09-28 19:33 when I return$parsed I got ..

I not sure on what is my next step here or the formating i need to do to insert these values to the database. currently I am calling functions that return data in array. $rfvFieldID =$this->function1(); // array $rfvIDs =$this->fucntion2(); // array And I am passing these value to a new table and ..

Due to application versions, I have 3 laravel Homestead boxes. I’m using MacOS. Laravel Homestead 9.7.2 Laravel Homestead 12.2 Laravel Homestead 12.6 For each of them I do: v10.17 laravel/homestead 9.7.2 Welcome to Ubuntu 18.04.5 LTS (GNU/Linux 4.15.0-124-generic x86_64) $vagrant ssh then$ mailhog 2021/09/28 23:10:17 Using in-memory storage 2021/09/28 23:10:17 [SMTP] Binding to ..

I’m trying login the correct way using Laravel Passport by following the docs regarding how to do this but I’m just a little stuck on something. For now, for my user – I’m copy & pasting the client_id and client_secret values. I’m grabbing the client_id from the oauth_access_tokens table via the client_id column. and I’m ..

I would like you can help me with this issue I have. I have this method in my controller: public function comments(Post $post) {$comments = $post->load(‘user’)->comments()->paginate(10); return (CommentResource::collection($comments))->response(); } This return a response like this: { "data": [ { "id": 43, "content": "fffffffff", "image_path": null, "created_at": "2021-09-28T20:53:43.000000Z", "user": { "id": 1, "name": "Demo", "verified": ..

I have one to many relationship between Warehouse and Sale models warehouse.php public function sales () { return $this->hasMany(Sale::class); } The sales table has product_price, quantity and status columns. I want to calculate product_price * quantity based on the status column. If status is equal to 1 then sum += product_price * quantity and if .. Read more I’m very new to Redis and fairly new to Laravel so could use some pointers on this. We have a legacy PHP application that stores sessions to Redis and I’m able to see it in Redis with the default naming convention, ie.: PHPREDIS_SESSION:1bd9ca87f5b606a35891c807857c2fde We’re moving towards a Laravel API framework and as a short-term hybrid .. Read more how to make the encryption shorter in characters? Crypt::encrypt($event->id)) Result: http://myurl/id/eyJpdiI6Im5ub0hyaWJwVE1iendYbHNaSzJsSXc9PSIsInZhbHVlIjoiVHhpNmF4b3NlQjk2NFluRXhCOFZuQT09IiwibWFjIjoiZDkxNzk2OTlmZGRmZWJjYjFlNjExYjcyNWU4Y2Y4NWYwMjYxMTkxN2ZmNzU3NGM4Nzg0OWJkNjk1NmExNjVkZiIsInRhZyI6IiJ9 generates a very large link, I need to shorten it, is it possible? Sourc..

i created an array of string in jquery in blade.php file and wanted to pass that array to controller but unable to do it neither know to acces from controller. I tried many methods but all in vain. I don’t know exact method to do it. I created button with id="order", when i click button ..

I have set up a project using Laravel Breeze and am using some of the default components in it. One of these is the dropdown component, used in the nav bar. By default, you need to click on the dropdown in order for the menu to appear below. However, I want to modify this component ..

How can I make so it searches for either projects.title or items.title and still returns the result if it only matches one of them? Right now if it matches an item, it will not show up unless it matches a project title as well and the other way around. I understand why, but I probably ..

$validator = Validator::make($request->all(), [ ’email’ => ‘required|min:9|max:50|email’, ‘password’ => ‘required|min:8|max:255|password’ ]); if ($validator->fails()) { echo "Failed! Sorry :("; Session::flash(‘error’,$validator->messages()->first()); //return Redirect::back()->withErrors($validator); } else {… But if I write ‘password’ => ‘required|min:8|max:255’ the validation is passed, but when I write ‘password’ => ‘required|min:8|max:255|password’ it doesn’t pass and the result is "Failed! Sorry :(". I mean .. Read more I have two models, Menu and User with many to many relationship. So, at this moment I have lot of records with the same user_id and menu_id in the pivot table, and the user must to can detach only one of them and not all of them. So, I made a AJAX request to "remove" .. Read more I installed Laravel Passport and migrated the new tables just fine in my database. But when I try to run migrations for the testing database, ie. artisan migrate –database=testing I get: SQLSTATE[42S01]: Base table or view already exists: 1050 Table ‘oauth_auth_codes’ already exists The only table that exists in the testing database is the migrations .. Read more ** I am using backpack laravel. I created two custom buttons "approve" and "disapprove".** <script src="https://code.jquery.com/jquery-2.2.4.js"></script> <button class="btn btn-xs btn-default" id="a{{$entry->getKey()}}" name="approved"> <i class="fa fa-check"> </i> Approve </button> <script type = ‘text/javascript’> $(document).ready(function(){$("#a{{$entry->getKey()}}").on("click", function(){ var name = document.getElementById("a{{$entry->getKey()}}").attributes[2].value; var num = document.getElementById("a{{$entry->getKey()}}").attributes[1].value;$.ajax({ url : ‘{{url(‘getMessage/{num1}’)}}’, type:’POST’, data: { "num1": num, _token: ‘{{csrf_token()}}’, "name": ..
I have this Warehouse → many to many → Product → has many → Sale My relationships warehouse.php public function products () { return $this->belongsToMany(Product::class)->withPivot(‘quantity’); } product.php public function sales () { return$this->hasMany(Sale::class); } I want to get sales for each warehouse What I have tried return Warehouse::with(‘products.sales’)->get(); Unexpected restult { "id": 1, "warehouse": ..
I have zero php experience, but need to fire up an existing application that I have cloned (which is supposed to be functional), to test it quickly. I think I’m pretty close to have it working. If I run php artisan serve: [[email protected] appliweb]$php artisan serve Starting Laravel development server: http://127.0.0.1:8000 [Tue Sep 28 .. Read more I am currently following Laracasts and learning Laravel. I fully understand seeding and factories, but was wondering if there is a way to limit the amount of items a factory called within another factory can create? Maybe an arrow function? This is primarily because I don’t want 30 users with my 30 posts, etc. I .. Read more Im using a jquery repeater to repeat input fields and i need to find the name of the last input field added (with the a specific id). How im doing it :$(‘#addElements’).on(‘click’, function() { var nameOfLastInput = $("#inputID:last").attr("name"); console.log(nameOfLastInput); }); What i get is the name of the first field every time: Full working .. Read more In my laravel based application, when updating user accounts I’m trying to validate the birthday field. I have the following in my controller’s update method ‘date_of_birth’=>[‘required’,’date’, ‘date_format:Y-m-d’, function ($attribute, $value,$fail) { $age=Carbon::createFromFormat(‘Y-m-d’,$value)->diff(Carbon::now())->y; if($age<18||$age>70){ $fail(‘Âge invalide. l’âge devrait être 18-70’); } },] So the date format has to be Y-m-d and the age range .. Read more I have implemented this relationship where a warehouse belongsToMany products that has Many sales. My models be like warehouse.php public function products () { return$this->belongsToMany(Product::class)->withPivot(‘quantity’); } product.php public function sales () { return $this->hasMany(Sale::class); } I want to access sales directly from my Warehouse model to sum a column in the sales table. I .. Read more Anyone can help to put this into a Laravel Eloquent statement ? where timestamp = unix timestamp SELECT max(timestamp) ,value FROM forex group by FROM_UNIXTIME(timestamp,’%Y%m%d’ ) Sourc.. Read more Route::get("test", function (){$result = IlluminateSupportFacadesSession::get("filter_values"); IlluminateSupportFacadesSession::forget("filter_values"); IlluminateSupportFacadesSession::put(‘filter_values’, "abcdef"); dd("result: ", $result); }); Why the session return null when the page is refreshed ? Sourc.. Read more I have a very strange bug affecting a small portion of my userbase in my Laravel framework based PHP website. I am using Microsoft’s OAuth 2.0 authorization to log in users. Basically the normal OAuth2 authorization flow: User navigates to /login Generate random state variable and save it to session Build OAuth2 /authorize endpoint auth .. Read more Inside a controller in Laravel I have this: public function index() {$users = User::orderBy(‘name’, ‘asc’)->paginate(13); $users2 = User::all(); return view(‘contatos.index’)->with(‘users’,$users); return view(‘auth.register’)->with(‘users’, \$users2); } I know isn’t right, it’s just to demonstrate my logic. Is there a way to unite these two returns in a single return? Or even a much shorter form ..