0 Best Reply Awards

  • Member Since 1 Month Ago
  • 0 Lessons Completed
  • 0 Favorites

16th February, 2018

absolute left a reply on Scope Method Not Found • 1 month ago

Just checking this isn't a simple typo - did you copy the scopeFiscal definition from you code to post it here? If so, there is an opening bracket missing from the function definition.

public function scopeFiscal$query, $model_table) {

should be

public function scopeFiscal($query, $model_table) {

Obviously this may just be a typo on this site only. In which case, forgive me asking.

absolute left a reply on Validation Error Using Datepicker • 1 month ago

Change your JS formatting to be the 4 digit year:

$( ".input-group.date" ).datepicker({
    format: 'dd/mm/yyyy'

absolute left a reply on Validation Error Using Datepicker • 1 month ago

Can I just check the date you are entering into the input field through the datepicker? Is it in the format 16/02/2018?

absolute left a reply on Validation Error Using Datepicker • 1 month ago

Update your validation rule to reflect the format of the date you want to receive.

$this->validate($request, [
    'date' => 'required|date_format:d/m/Y',

You should use either the date or date_format methods, so be sure to remove the original date method.

absolute started a new conversation Pagination Of GROUPED Query Results Within Laravel 4.2 • 1 month ago

I have a query which currently returns in the region of 25k records, with this likely to exceed 100k by the end of year. Obviously this is paginated for readability.....

Having delved into the code for pagination, it appears that the standard Laravel 4.2 code returns the entire dataset in order to get the TOTAL count, and then slices the resulting collection in order to return the paginated result.

My question is, can anyone highlight any reasons or circumstances under which the following would not be more efficient or indeed cause issues?

\Illuminate\Database\Eloquent\Builder.php Lines 259 -

protected function groupedPaginate($paginator, $perPage, $columns)
    $total_records = \DB::select('select count(*) as total from ('.$this->toSql().') as records', $this->getBindings())[0];
    $total = $total_records->total;

    $page = $paginator->getCurrentPage($total);

    $this->query->forPage($page, $perPage);

    return $paginator->make($this->get($columns)->all(), $total, $perPage);

The purpose here is to nest the original GROUPED SQL query within a single select, and retrieve a single row with the total record count. Once you have this total, then retrieve a limited set of results, as you would with the standard pagination process.

Like I said, any advice as to why this wouldn't be more efficient or indeed fail, would be great!

And again for clarity, this is running on Laravel 4.2.

absolute left a reply on Route Has Only One Parameter • 1 month ago

You just need to update your Route definition so that both variables are defined within the Route structure.

Route::get('files/{files}/{filename}', ['uses' => '[email protected]', 'as' => 'files.show'])

This definition would need to go before the Route Resource defined above, or I believe it would be ignored.

You can nest this query within other Route Groups which handle the "files" and "{files}" prefixes if you wish, but update the Route definition as appropriate.

Edit Your Profile

Want to change your profile photo? We pull from gravatar.com.