lundi 28 novembre 2016

Get a cookie in Laravel 5 middleware

I'm trying to retrieve a cookie from a middleware in Laravel 5.3 but it seems like $request->cookie('language') is empty. I'm guessing that it is only set after the middleware runs.

I read somewhere that I should use \Cookie::queued('language'), but it's still empty.

Is my only option using the $_COOKIE variable?



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2fWK0vw
via IFTTT

PHP cant access newly created zip file

Im using Laravel 5.2 and Zipper to create ZIP archive in a fly and download it by user. I think this problem is generall not strictly related to Laravel or Zipper. Steps:

  1. User click link download_all.
  2. First php script create archive.
  3. Next the same script push created file to force user download.

Everything sounds normal but I have strange behaviour that after zip archive is created (point 2) php/server cant see this newly created file. Both filesize and file_exists on $filePath return false but file exist. I cant read file why?

When I redirect user to $filePath (instead of reading it and pushing to download) everything is okay and user get file. But why I cant access newly creatd file during "script lifetime"? $paths are correct. Tested on Windows 7 and Unix.

Any idea?

code:

public function downloadAll($id)
    {
        $sourceFilesDir   = 'upload/source/' . $id;
        $zipPath          = 'upload/source-zip/' . date('Y-m-d-H-i-s') . '.zip';

        Zipper::make($zipPath)->add($sourceFilesDir);

        $fullPath = public_path($zipPath);

        // works
        // return response()->redirectTo($zipPath);

        $headers = [
            'Content-Type: application/zip',
            'Content-Transfer-Encoding: Binary',
            'Content-Length: ' . filesize($fullPath),
        ];

        // dont works, cant see file
        return response()->download($fullPath, basename($zipPath), $headers);
    }



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2gaxWtx
via IFTTT

how to get started with laravel 5's mvc structure

i have newly installed laravel 5 and now i want to know how to make it work like a "model view controller" structure. Basically where to put models, controllers and view in the file structure.



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2fEjQN4
via IFTTT

Submit form after certain time interval through laravel 5.3

I am developing a time based mock test web application. I need to securely submit form after lets say 5 mins. if i do it with jquery wouldn't it be less secure?? or doing it with php/ laravel functions will make it more secure?? and if there is a way of doing it with php/laravel please guide how to do it. Thanku



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2fEee5l
via IFTTT

Laravel Model tries inserting to wrong DB Table

So, my Model is trying to insert my data to a different table than I told it to.

My Model code is as follows:

class Workplacereserve extends Model
{
    protected $table = 'workplacereserves';
    protected $fillable = ['spot', 'date', 'timefrom', 'timeto', 'client', 'cmail', 'created_at', 'updated_at'];
}

The application shows that it's trying to insert into hallreserves table, which is not to right one



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2gnA8eG
via IFTTT

how can I update My values using Laravel 5.2

this is My addpermission function in My Controller, I need update function here to update values. how can I put update codes here. (I need update function in same addpermission function)

public function addPermission(Request $request, $id,  Permission $permission)
    {
         $this->validate($request, [
            'status'   => 'required'


        ]);

        $permission = new Permission;

        $permission->status = $request->input('status');
        $permission->project_id       = $id;
        $permission->collaborator_id =  $request->input('cid');
        $permission->save();
        return redirect()->back()->with('info','Permission has been added to your Collaborator successfully');
}



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2fWlGd1
via IFTTT

Vue js and Laravel site development

I would like to know . our team thinking to have frontend and backend with two separate location. both frontend and backend will be connected through RESTful API. Is it a good practice ? suggestions are welcome.

Would like to know more advises. Thank you.



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2frVXxc
via IFTTT