mercredi 1 avril 2020

Laravel Chunk Upload skipping one chunk

I am using laravel-chuck-upload in combination with dropzone.js. Everything works fine, the chunks are uploading and when they are uploaded the final file will be saved in S3. The problem is that 1 chunk is always missing. Sometimes .8.part is missing, sometimes .7.part is missing (they remain in the chunks directory after uploading). When I upload a video that has a total size of 9.7MB the file in S3 is 8.7MB. That is 1mb missing, the same size as the missing part. All the chunks are 1MB in size.

What could be the problem and how can I fix this?



via Chebli Mohamed

How to get the last record using Eloquent scope?

I have a Posts table structured like this:

enter image description here

Now I'm trying to get the latest post which is obviously the record with id = 2.

I have this in my theme page posts.htm:

[builderList postLatest]
modelClass = "Me\Articles\Models\Posts"
scope = "scopeLatest"
scopeValue = ""
displayColumn = "title"
noRecordsMessage = "No records found"
detailsPage = "-"
detailsUrlParameter = "slug"
pageNumber = ""

in my model Posts I have:

public function scopeLatest($query)
{
  return $query->orderBy('created_at','desc')->first();
}

But this one is returning both records. I also tried using latest()

return $query->latest();

And this one gives me the error:

Maximum function nesting level of '1000' reached, aborting!

Even tried passing parameter like latest('created_at') but got the same error.

Tried dumping dd($query->orderBy('created_at','desc')->first()->toSql()) and got select * from posts where posts.deleted_at is null

  1. Why first() is not limiting to 1 record?
  2. Why latest() is throwing me Maximum error? Is this version specific bug? It seems I cant find documentation related to it. I have Laravel 5.5.48.

I'm not sure now what can I use. Maybe I'm doing something wrong here. I just need to get the latest post.



via Chebli Mohamed

How to stop laravel error(at-rule or selector expected)

Error on public/app/app.css

While i was just working on other stuff i found the error on this page.



via Chebli Mohamed

why my database does not update ? (LARAVEL)

my database does not update while when i do

 dd(request()->has('validated'));

this is what my web.php looks like:

Route::patch('prof/theme/{id}/validated', 'Theme\ThemeController@valide')->name('prof.theme.validated');

this is what my ThemeController.php looks like:

public function valide(Theme $theme) {
        $theme->update([
            'validated' => request()->has('validated')
        ]);
       return back();

    }

this is what my show.blade.php looks like:

<form action="" method="POST">
                        @csrf
                        @method('PATCH')
                             @if ($theme->validated)
                                <button type="submit" class="btn btn-danger text-center" style="width: 350px">
                                            INVALIDER LE THEME
                                </button>
                             @else
                                 <button type="submit" class="btn btn-success text-center" name="validated" id="validated" style="width: 350px">
                                                VALIDER LE THEME
                                 </button>
                             @endif
                         </form> 

this code does not show me any error but it does not produce the expected action. my variable "validated" is a boolean



via Chebli Mohamed

SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'activity_log' already exists

In Connection.php line 664:

SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'activity_log' already exists (SQL: create table activity_log (id int
unsigned not null auto_increment primary key, log_name varchar(255) null, description text not null, subject_id int null, subject_
type
varchar(255) null, causer_id int null, causer_type varchar(255) null, properties text null, created_at timestamp null, upd
ated_at
timestamp null) default character set utf8 collate utf8_unicode_ci)

In PDOStatement.php line 123:

SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'activity_log' already exists

In PDOStatement.php line 121:

SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'activity_log' already exists



via Chebli Mohamed

Getting # query parameters in laravel

I am developing a CRM for one of my client and he needs VoIP integration into his CRM. I've almost achieved what he wanted but there is a small issue left. The API I am using for VoIP integration sends me access_token to my redirect_uri but the issue is it send me that access token in # instead of ? can any one help me to get this # parameter from the uri as I've searched the internet a lot but couldn't find the answer any help would be great. Here is the url I am getting after authorization.

http://localhost:8000/handleresponse#access_token={Authorization_Token}&token_type=Bearer&expires_in=86400&principal={PRINCIPAL}&loa=2

I can get any parameter from the URI but this #access_token is what I need but I can't get that.

I've tried using $request->access_token but it gives me null. The other logic I've thinking was to get the complete url and convert it into an array and then get the access token but when I get the URL it returns only URL

http://localhost:8000/handleresponse

Anyone knows how to handle this thing.



via Chebli Mohamed

mardi 31 mars 2020

How to use select function and with function together in laravel

I want to select some column from the main table with laravel with function but when I use select it gives null in with for example

table1::select('column1','column2')->with(['table2'])->paginate($request->query('per_page', 10));

If I use select then it gives null in table2 but if I remove the select then it gives values in table2.

Can anyone please let me know what I am doing wrong or what can be done here



via Chebli Mohamed