mercredi 31 août 2022

i want to create directory with the name of the Company and i want to move some files related to that Company in that directory. How can i do it?

I successfully created the directories with this code in controller:

$cpath = public_path().'/files/completed/'.$file['customer_name'];
                if (! File::exists($cpath)) {
                    File::makeDirectory($cpath);
                }

but I am not sure how can i move related files to these directories for that I tried this:

File::move('files/pending/'.$filename,'files/completed/'.$file['customer_name'].$filename);

but the problem is I am not getting any files in their respective directories but the files are moving with the name renamed to (comapanyname filename.850) and that's not what I wanted here is how i am doing all the code in controller for directories and files:

 $cpath = public_path().'/files/completed/'.$file['customer_name'];
                if (! File::exists($cpath)) {
                    File::makeDirectory($cpath);
                }
       File::move('files/pending/'.$filename,'files/completed/'.$file['customer_name'].$filename);

Thank you for your response!



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/CiaYSqK
via IFTTT

i want to schedule one function in my controller every 5 minutes that is inserting files and product data in the DB.. how can i do that?

here is how data is updating in the DB with the page refresh but i want it to update automaticaaly after every 5 minutes so that without refreshing my data becomes visables on welcome page as well as the data is inserted automatically on function call(that should be after every 5 minutes). i am a beginner i tried to learn from laravel documentation but its not exactly displaying what i need.. your help will be appriciated... here is the code of how i am inserting data in the DB:

         foreach($files as $file){
            if (Invoice::where('file_name', '=', $file['file_name'])->exists()) {
            }
            else {
            $store = new Invoice;
            $store->file_name = $file['file_name'];
            $store->name = $file['customer_name'];
            $store->po_no = $file['po'];
            $store->address = $file['city'];
            $store->total_items = count($file['products']);
            $store->save();
            $invid = $store->id;

            for($x = 0; $x < count($file['products']); $x++)
            {
                $pstore = new InvoiceProduct;
                $pstore->product_name = $file['products'][$x];
                $pstore->invoice_id = $invid;
                $pstore->quantity =$file['count'][$x];
                $pstore->barcode=$file['scan'][$x];
                $pstore->vendor_code =$file['vn'][$x];
                $pstore->save();
             }
        }

and the function name is index i want to schedule this function every 5 minutes.. Thank you!



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/ZHCSjB2
via IFTTT

mardi 30 août 2022

Laravel Project not run on http mode but run in https [closed]

Hello my issue is about my project not to be run on http mode.

they show me an error like "419 PAGE EXPIRED"

plz share a perfect solution also describe the reason.



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/xqjNpAG
via IFTTT

General error: 11 database disk image is malformed [closed]

i have a problem. I would like to know why when I upload a csv file in laravel I get this error? General error: 11 database disk image is malformed



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/QLkYgpV
via IFTTT

lundi 29 août 2022

count where they don't have the same ID

i need to count all records in my table, but in the mp_id column there are repetitions

how to count only once where the content of mp_id is repeated?

so that the count is not wrong, i want the mp_id to count only once and not 3 or 4.

  $ingresos = Ingresosmp::All()->count('mp_id');

enter image description here



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/arglXqI
via IFTTT

Laravel response file problem in prevent back button history middleware

I am using Laravel, and I have created a PreventBack middleware to prevent users from returning to the page after logout.

Middleware

namespace App\Http\Middleware;

use Closure;
use Illuminate\Http\Request;

class PreventBack
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @return mixed
     */
    public function handle($request, Closure $next)
    {
        $response = $next($request);

        return $response->header('Cache-Control', 'no-cache, no-store,
                max-age=0, must-revalidate')
            ->header('Pragma', 'no-cache')
            ->header('Expires', 'Sun, 02 Jan 1990 00:00:00 GMT');
    }
}

But I have a route that returns the profile image.

Route::get('/profileimage', function () {

    return response()->file(storage_path('profile_image.jpg'));
});

When I put my profile image route in preventing back middleware, this route stops working, and the route does not return the profile image.

Route::group(['middleware' => ['PreventBack']], function () {
    Route::get('/profileimage', function () {
        return response()->file(storage_path('profile_image.jpg'));
    }); 
});


from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/BcUDqtz
via IFTTT

Laravel: Version of Node

I'm running on a problem. My Laravel project is an old one, and I can't run npm run dev. Let's see some code:

php artisan laravel --version: Laravel Framework 5.8.38

node --version: v16.16.0 This is the actual version of Node installed

And the error when running NPM:

npm WARN npm npm does not support Node.js v16.16.0
npm WARN npm You should probably upgrade to a newer version of node as we
npm WARN npm can't make any promises that npm will work with this version.
npm WARN npm Supported releases of Node.js are the latest release of 6, 8, 9, 10, 11.
npm WARN npm You can find the latest version at https://nodejs.org/

> @ dev /Users/marcellopato/Documents/Sites/webroker
> npm run development

npm WARN npm npm does not support Node.js v16.16.0
npm WARN npm You should probably upgrade to a newer version of node as we
npm WARN npm can't make any promises that npm will work with this version.
npm WARN npm Supported releases of Node.js are the latest release of 6, 8, 9, 10, 11.
npm WARN npm You can find the latest version at https://nodejs.org/

> @ development /Users/marcellopato/Documents/Sites/webroker
> cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js

node:events:505
      throw er; // Unhandled 'error' event
      ^

Error: spawn node_modules/webpack/bin/webpack.js ENOENT
    at Process.ChildProcess._handle.onexit (node:internal/child_process:283:19)
    at onErrorNT (node:internal/child_process:478:16)
    at processTicksAndRejections (node:internal/process/task_queues:83:21)
Emitted 'error' event on ChildProcess instance at:
    at Process.ChildProcess._handle.onexit (node:internal/child_process:289:12)
    at onErrorNT (node:internal/child_process:478:16)
    at processTicksAndRejections (node:internal/process/task_queues:83:21) {
  errno: -2,
  code: 'ENOENT',
  syscall: 'spawn node_modules/webpack/bin/webpack.js',
  path: 'node_modules/webpack/bin/webpack.js',
  spawnargs: [
    '--progress',
    '--hide-modules',
    '--config=node_modules/laravel-mix/setup/webpack.config.js'
  ]
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ development: `cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the @ development script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/marcellopato/.npm/_logs/2022-08-29T14_40_33_577Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ dev: `npm run development`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the @ dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/marcellopato/.npm/_logs/2022-08-29T14_40_33_659Z-debug.log

The package.json:

    "private": true,
    "scripts": {
        "dev": "npm run development",
        "development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
        "watch": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
        "watch-poll": "npm run watch -- --watch-poll",
        "hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js",
        "prod": "npm run production",
        "production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
    },
    "devDependencies": {
        "axios": "^0.18.0",
        "bootstrap": "^4.1.3",
        "cross-env": "^5.2.0",
        "jquery": "^3.2",
        "laravel-mix": "^2.1.14",
        "lodash": "^4.17.11",
        "popper.js": "^1.14.3",
        "vue": "^2.5.16",
        "vuedraggable": "^2.16.0"
    },
    "dependencies": {
        "@tinymce/tinymce-vue": "^1.1.0",
        "@websanova/vue-upload": "^0.2.14-beta",
        "ajv": "^6.5.4",
        "jquery-filepond": "^1.0.0",
        "laravel-echo": "^1.4.0",
        "moment": "^2.22.2",
        "moment-timezone": "^0.5.21",
        "node-sass": "^4.9.4",
        "npm": "^6.4.1",
        "pusher-js": "^4.3.1",
        "tinymce-vue-2": "0.0.5",
        "v-calendar": "^0.9.7",
        "vlightbox": "^2.0.2",
        "vue-chat-scroll": "^1.2.0",
        "vue-google-charts": "^0.3.2",
        "vue-moment": "^4.0.0",
        "vue-scrollto": "^2.13.0",
        "vue-simple-lightbox": "^1.1.0",
        "vue-template-compiler": "^2.5.17",
        "vue-the-mask": "^0.11.1",
        "vue-toasted": "^1.1.25",
        "vue-upload-component": "^2.8.14",
        "vue-wysiwyg": "^1.7.2",
        "vue2-daterange-picker": "^0.1.1",
        "vue2-dropzone": "^3.5.2",
        "vue2-editor": "^2.6.1"
    }
}

I think the issue is relative to the actual version of Node, that is too new. Could be that? And if so, there's a way to know what version I had installed on my machine at the time I was working on the project for the first time?

Or the issue is a new one?



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/haTYb7j
via IFTTT