I am using Laravel 5.4. I have a custom form request class where I have my validation rules and messages and I use it in my controller like following : public function store(CustomFormRequest $…
Tag: php
How to use pagination with alaouy/youtube laravel package?
I’m using alaouy/youtube package for one of my projects, Its working just fine, But with this method I can’t use pagination! Is there any way or I’ve to write my own code? There is a vendor folder in my resources with pagination folder but I can’t get work with it! Answer I’m the…
Laravel 5.4 hasManyTrough ‘Call to undefined method IlluminateDatabaseQueryBuilder::hasManyTrough()’
I am struggling to see, where I went wrong. It seams easy, I followed Laravel instructions https://laravel.com/docs/5.4/eloquent-relationships#has-many-through , but clearly I need someone more familar with this sort of code as whenever I try to fetch $stagingsystem-stagesubtype I get error BadMethodCallExcep…
Sort json array by value using PHP
I am trying to sort the array using usort().But my function does not seem to work. I want to sort it by partners_order of each object i.e, $myJson[0] and then $myJson1 separately The Json array is decoded using $myJson = json_decode($jsonData); PHP function to sort is written below. Due to restrictions in thi…
Laravel Validation Rules If Value Exists in Another Field Array
I am working in Laravel 5.4 and I have a slightly specific validation rules need but I think this should be easily doable without having to extend the class. Just not sure how to make this work.. What I would like to do is to make the ‘music_instrument’ form field mandatory if program array contai…
How to change PHP version on MAMP 4.1
I downloaded MAMP 4.1 on my Mac; by default, the only PHP versions I can use are 7.0.15 and 7.1.1 How can I use PHP 5.6? I tried the solution here Which says I should rename the versions I don’t …
Apply Middleware to all routes except `setup/*` in Laravel 5.4
I’m experimenting with Middleware in my Laravel application. I currently have it set up to run on every route for an authenticated user, however, I want it to ignore any requests that begin with the setup URI. Here is what my CheckOnboarding middleware method looks like: This is being used in my routes …
Pagination MYSQL count vs PHP count and array_slice
I have a search query which looks for matching values from a search table and returns all possible entries matching the keywords. I did not write the search, it’s something that already existed and we’…
Php -MySQL query failing – error Fatal error: Uncaught Error: Call to a member function fetch_assoc() on boolean
I have following php code : I get the generic error but when I run the same code on MySQL then it works without error. Can someone please help me what am I missing . I even tried exception handling but it didn’t help. NOTE : code fails in the while loop condition. Answer The mysqli_multi_query() execute…
Which is faster php date functions or carbon?
Carbon is simple PHP API extension for DateTime. I want to know that we can use datetime functions using by installing carbon via composer. which is faster php datetime functions or carbon ? Answer I did some testing regarding your comment comparing DateTime to Carbon functions: Calling Carbon::now() vs. new …