GodziLaravel

GodziLaravel

Member Since 3 Years Ago

Experience Points
23,740
Total
Experience

1,260 experience to go until the next level!

In case you were wondering, you earn Laracasts experience when you:

  • Complete a lesson — 100pts
  • Create a forum thread — 50pts
  • Reply to a thread — 10pts
  • Leave a reply that is liked — 50pts
  • Receive a "Best Reply" award — 500pts
Lessons Completed
2
Lessons
Completed
Best Reply Awards
0
Best Reply
Awards
  • start your engines Created with Sketch.

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • first-thousand Created with Sketch.

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • 1-year Created with Sketch.

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • 2-years Created with Sketch.

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • 3-years Created with Sketch.

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • 4-years Created with Sketch.

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • 5-years Created with Sketch.

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • school-in-session Created with Sketch.

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • welcome-newcomer Created with Sketch.

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • full-time-student Created with Sketch.

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • pay-it-forward Created with Sketch.

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • subscriber Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • evangelist Created with Sketch.

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.

  • chatty-cathy Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

Level 5
23,740 XP
Aug
07
6 days ago
Activity icon

Started a new Conversation How To Extend Bearer Life Time In A 3rd Party API Restful

Hello ,

I'm working on a project to consume the webex(cisco) API,

In the documentation : https://developer.webex.com/docs/integrations#getting-an-access-token

the Bearer token has a limite expire time:

{
 "access_token":"ZDI3MGEyYzQtNmFlNS00NDNhLWFlNzAtZGVjNjE0MGU1OGZmZWNmZDEwN2ItYTU3",
 "expires_in":1209600, //seconds
 "refresh_token":"MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTIzNDU2Nzg5MDEyMzQ1Njc4OTEyMzQ1Njc4",
 "refresh_token_expires_in":7776000 //seconds
}

My question : how is it possible to make it available forever ?

Thanks .

Activity icon

Started a new Conversation How To Protect Microservices To Get Used Outise Of My App ?

Hello ,

Let's imagine I have a micro-service which could provide me the weather per country.

Okay?

Now , how is it possible to limit access to this API only inside of my web application and if some one try to call it from other application/webiste it will not returns data ?

Thanks

Aug
04
1 week ago
Activity icon

Started a new Conversation Vagrant : Time Out While Waiting For The Machine ...

Hello , I added another laravel app to my current Homestead file (YAML) :

---
ip: "192.168.10.10"
memory: 2048
cpus: 2
provider: virtualbox

authorize: ~/.ssh/id_rsa.pub

keys:
    - ~/.ssh/id_rsa

folders:
    - map: ~/code
      to: /home/vagrant/code
      type: "nfs"

sites:
    - map: myhomestead.com
      to: /home/vagrant/code/coorza/public
    - map: events.test
      to: /home/vagrant/code/events/public

databases:
    - homestead
    - laravel

features:
    - mariadb: false
    - ohmyzsh: false
    - webdriver: false

# ports:
#     - send: 50000
#       to: 5000
#     - send: 7777
#       to: 777
#       protocol: udp

Now when I vagrnat up I got this error :

$ vagrant up
Bringing machine 'homestead' up with 'virtualbox' provider...
==> homestead: Checking if box 'laravel/homestead' version '9.4.0' is up to date...
==> homestead: Clearing any previously set forwarded ports...
==> homestead: Clearing any previously set network interfaces...
==> homestead: Preparing network interfaces based on configuration...
    homestead: Adapter 1: nat
    homestead: Adapter 2: hostonly
==> homestead: Forwarding ports...
    homestead: 80 (guest) => 8000 (host) (adapter 1)
    homestead: 443 (guest) => 44300 (host) (adapter 1)
    homestead: 3306 (guest) => 33060 (host) (adapter 1)
    homestead: 4040 (guest) => 4040 (host) (adapter 1)
    homestead: 5432 (guest) => 54320 (host) (adapter 1)
    homestead: 8025 (guest) => 8025 (host) (adapter 1)
    homestead: 9600 (guest) => 9600 (host) (adapter 1)
    homestead: 27017 (guest) => 27017 (host) (adapter 1)
    homestead: 22 (guest) => 2222 (host) (adapter 1)
==> homestead: Running 'pre-boot' VM customizations...
==> homestead: Booting VM...
==> homestead: Waiting for machine to boot. This may take a few minutes...
    homestead: SSH address: 127.0.0.1:2222
    homestead: SSH username: vagrant
    homestead: SSH auth method: private key
Timed out while waiting for the machine to boot. This means that
Vagrant was unable to communicate with the guest machine within
the configured ("config.vm.boot_timeout" value) time period.

If you look above, you should be able to see the error(s) that
Vagrant had when attempting to connect to the machine. These errors
are usually good hints as to what may be wrong.

If you're using a custom box, make sure that networking is properly
working and you're able to connect to the machine. It is a common
problem that networking isn't setup properly in these boxes.
Verify that authentication configurations are also setup properly,
as well.

If the box appears to be booting properly, you may want to increase
the timeout ("config.vm.boot_timeout") value.

How to solve this ?

Thanks

Aug
03
1 week ago
Activity icon

Started a new Conversation What's The Best Webex Cisco Package

hello ,

I will start working on a Webex API , I would like to integrate it on my Laravel application

First I need to create a room using the single sign-on (SSO)

Do you know what is the best package I could use ? I googled this but I found many results !

Thanks

Jul
23
3 weeks ago
Activity icon

Started a new Conversation How To Get All Insert Requests ?

Hello,

I'm wondering if there is a way in Laravel to listen on all SQL requests sent from my App ?

For example I have a form which I have to store on multiple tables (Relation ships) and when I click on save button I want to get the list of all queries executed after this click ?

Hope my question is clear.

thanks

Jul
18
3 weeks ago
Activity icon

Started a new Conversation How To Connect Laravel App To Google Sheet ?

Hello ,

I want to connect my laravel App to a Google Sheet in a purpose of importing/updating my tablesheet.

1 - Connecting to the Google sheet

2- I want to when this google sheet is updated to update also the sheet table in mysql DB.

Is there any package to do this ? or any other solution ?

Jun
18
1 month ago
Activity icon

Replied to Npm Run Prod ; Returns Error

@bobbybouwmann

this the log file

0 info it worked if it ends with ok
1 verbose cli [ '/usr/bin/node', '/usr/bin/npm', 'run', 'prod' ]
2 info using [email protected]
3 info using [email protected]
4 verbose run-script [ 'preprod', 'prod', 'postprod' ]
5 info lifecycle @~preprod: @
6 info lifecycle @~prod: @
7 verbose lifecycle @~prod: unsafe-perm in lifecycle true
8 verbose lifecycle @~prod: PATH: /usr/share/npm/node_modules/npm-lifecycle/node-gyp-bin:/var/www/coorza/node_modules/.bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
9 verbose lifecycle @~prod: CWD: /var/www/coorza
10 silly lifecycle @~prod: Args: [ '-c', 'npm run production' ]
11 silly lifecycle @~prod: Returned: code: 1  signal: null
12 info lifecycle @~prod: Failed to exec prod script
13 verbose stack Error: @ prod: `npm run production`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter.<anonymous> (/usr/share/npm/node_modules/npm-lifecycle/index.js:332:16)
13 verbose stack     at EventEmitter.emit (events.js:198:13)
13 verbose stack     at ChildProcess.<anonymous> (/usr/share/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack     at ChildProcess.emit (events.js:198:13)
13 verbose stack     at maybeClose (internal/child_process.js:982:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)
14 verbose pkgid @
15 verbose cwd /var/www/coorza
16 verbose Linux 5.4.0-37-generic
17 verbose argv "/usr/bin/node" "/usr/bin/npm" "run" "prod"
18 verbose node v10.19.0
19 verbose npm  v6.14.4
20 error code ELIFECYCLE
21 error errno 1
22 error @ prod: `npm run production`
22 error Exit status 1
23 error Failed at the @ prod script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]

webpack.mix.js

/*
 |--------------------------------------------------------------------------
 | Mix Asset Management
 |--------------------------------------------------------------------------
 |
 | Mix provides a clean, fluent API for defining some Webpack build steps
 | for your Laravel application. By default, we are compiling the Sass
 | file for the application as well as bundling up all the JS files.
 |
 */
mix.options({
    processCssUrls: true,
    purifyCss: false,
    terser: {
        terserOptions: {
            compress: {
                drop_console: true,
            }
        }
    }
});

mix.js('resources/js/app.js', 'public/js')
    .browserSync('localhost');

mix.webpackConfig({
    resolve: {
        alias: {
            '@assets': path.resolve('resources/js/assets'),
        },
    },
})
~                                                                                                        
~       
Jun
17
1 month ago
Activity icon

Started a new Conversation Npm Run Prod ; Returns Error

hello,

I try in production env to run npm run prod but I get this error message :

> npm run production


> @ production /var/www/coorza
> cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js

znpm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ 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`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the @ production script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2020-06-17T23_47_42_259Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ prod: `npm run production`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the @ prod script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2020-06-17T23_47_42_275Z-debug.log
[email protected]:/var/www/coorza# 

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": "npm run development -- --watch",
        "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.19",
        "browser-sync": "^2.26.7",
        "browser-sync-webpack-plugin": "^2.0.1",
        "cross-env": "^7.0.2",
        "deepmerge": "^4.2.2",
        "eslint": "^7.0.0",
        "eslint-plugin-vue": "^6.2.2",
        "fibers": "^5.0.0",
        "laravel-mix": "^5.0.1",
        "lodash": "^4.17.13",
        "resolve-url-loader": "^3.1.0",
        "sass": "^1.26.5",
        "sass-loader": "^8.0.2",
        "vue-template-compiler": "^2.6.11"
    },
    "dependencies": {
        "leaflet": "^1.6.0",
        "leaflet-geometryutil": "^0.9.3",
        "material-design-icons-iconfont": "^5.0.1",
        "vee-validate": "^3.3.0",
        "vue": "^2.6.11",
        "vue-axios": "^2.1.5",
        "vue-i18n": "^8.17.7",
        "vue-router": "^3.2.0",
        "vue2-leaflet": "^2.5.2",
        "vuelidate": "^0.7.5",
        "vuetify": "^2.2.29",
        "vuex": "^3.4.0"
    }

Thanks

Activity icon

Started a new Conversation Nginx: Only The Base Url Works, The Rest Is 404!

Hello ,

I'v just installed my server;

Everything is installed (php, mysql, Nginx...)

and it works, but only for the base URL, if I go to any other route it returns the 404 error !

I added in routes/api.php one simple route to test it :

Route::get('foo', function () {
    return 'Hello World';
});

and when I go to mydomain.example/api/foo it returns me the 404 errors

404 Not Found
nginx/1.17.10 (Ubuntu)

server conf :

server {
    listen 80 default_server;
    listen [::]:80 default_server;

    root /var/www/coorza/public;
    index index.php index.html index.htm index.nginx-debian.html;

    server_name server_domain_or_IP;

    location / {
        try_files $uri $uri/ =404;
    }

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/run/php/php7.4-fpm.sock;
    }

    location ~ /\.ht {
        deny all;
    }
}

api route:


/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/

Route::get('foo', function () {
    return 'Hello World';
});

Route::post('register', 'API\[email protected]');
Route::post('login', 'API\[email protected]');



Route::middleware('auth:api')->group( function () {
    Route::resource('coordinates', 'API\CoordinateController');
    Route::resource('lines', 'API\LineController');
    Route::resource('stops', 'API\StopController');
    Route::resource('trackers', 'API\TrackerController');
});

web.php


/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/


Route::view('/{any}', 'app')->where('any', '.*');

Jun
16
1 month ago
Activity icon

Started a new Conversation Is It Possible To Get The Called Method From Constructor In The Controller ?

hello ;

I need to know which method does the user call (index, show, create ...) from the controller constructor , is it possible ?

thanks

Jun
15
1 month ago
Activity icon

Started a new Conversation GitLab : Switch From Vagrant/ Homestead To Docker

Hello ,

I installed Docker with Laradock

Now the structure of my project is :

$ ll
total 1173
drwxr-xr-x 1 jesui 197609      0 Jun  4 17:14 app/
-rwxr-xr-x 1 jesui 197609   1686 Apr 24 22:31 artisan*
drwxr-xr-x 1 jesui 197609      0 Apr 24 22:31 bootstrap/
-rw-r--r-- 1 jesui 197609   1797 May 29 11:16 composer.json
-rw-r--r-- 1 jesui 197609 249464 May 29 11:16 composer.lock
drwxr-xr-x 1 jesui 197609      0 May 29 11:16 config/
drwxr-xr-x 1 jesui 197609      0 Apr 24 22:31 database/
drwxr-xr-x 1 jesui 197609      0 Jun 11 14:03 laradock/
drwxr-xr-x 1 jesui 197609      0 May 23 14:43 node_modules/
-rw-r--r-- 1 jesui 197609   1735 May 25 15:45 package.json
-rw-r--r-- 1 jesui 197609 600781 May 25 15:45 package-lock.json
-rw-r--r-- 1 jesui 197609   1197 Apr 24 22:31 phpunit.xml
drwxr-xr-x 1 jesui 197609      0 May 12 16:34 public/
-rw-r--r-- 1 jesui 197609   4497 Apr 24 22:31 README.md
drwxr-xr-x 1 jesui 197609      0 Apr 24 22:31 resources/
drwxr-xr-x 1 jesui 197609      0 Jun  2 16:03 routes/
-rw-r--r-- 1 jesui 197609    563 Apr 24 22:31 server.php
drwxr-xr-x 1 jesui 197609      0 Apr 25 00:53 storage/
drwxr-xr-x 1 jesui 197609      0 Apr 24 22:31 tests/
drwxr-xr-x 1 jesui 197609      0 Jun 11 16:46 vendor/
-rw-r--r-- 1 jesui 197609    852 May 28 10:21 webpack.mix.js

git status :

On branch lef-navigation-add-sub-menu-stops
Your branch is up to date with 'origin/lef-navigation-add-sub-menu-stops'.

Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
        new file:   .gitmodules
        new file:   laradock

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
        modified:   .idea/dataSources.xml
        modified:   .idea/vcs.xml

My question is (This is the first time to use Docker) : should I just add everything then commit->push ? or there is something else to do before?

Thanks

Jun
11
2 months ago
Activity icon

Replied to Laradock: Unknown Database 'homestead'

@braunson

Here the content of docker-compose.yml

### MySQL ################################################
    mysql:
      build:
        context: ./mysql
        args:
          - MYSQL_VERSION=${MYSQL_VERSION}
      environment:
        - MYSQL_DATABASE=${MYSQL_DATABASE}
        - MYSQL_USER=${MYSQL_USER}
        - MYSQL_PASSWORD=${MYSQL_PASSWORD}
        - MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}
        - TZ=${WORKSPACE_TIMEZONE}
      volumes:
        - ${DATA_PATH_HOST}/mysql:/var/lib/mysql
        - ${MYSQL_ENTRYPOINT_INITDB}:/docker-entrypoint-initdb.d
      ports:
        - "${MYSQL_PORT}:3306"
      networks:
        - backend

Indeed , the homestead database does not exists !

Activity icon

Started a new Conversation Laradock: Unknown Database 'homestead'

Hello ,

First let me show you .env (laravel) and .env(laradock) :

Laradock env

### MYSQL #################################################

MYSQL_VERSION=latest
MYSQL_DATABASE=homestead
MYSQL_USER=root
MYSQL_PASSWORD=root
MYSQL_PORT=3306
MYSQL_ROOT_PASSWORD=root
MYSQL_ENTRYPOINT_INITDB=./mysql/docker-entrypoint-initdb.d

### REDIS #################################################

Laravel evn

DB_CONNECTION=mysql
DB_HOST=mysql
DB_PORT=3306
DB_DATABASE=homestead
DB_USERNAME=root
DB_PASSWORD=root

when I [email protected]:/var/www# php artisan migrate :

   Illuminate\Database\QueryException

  SQLSTATE[HY000] [1049] Unknown database 'homestead' (SQL: select * from information_schema.tables where table_schema = homestead and table_name = migrations and table_type = 'BASE TABLE')

  at vendor/laravel/framework/src/Illuminate/Database/Connection.php:671
    667|         // If an exception occurs when attempting to run a query, we'll format the error
    668|         // message to include the bindings with SQL, which will make this exception a
    669|         // lot more helpful to the developer instead of just the database's errors.
    670|         catch (Exception $e) {
  > 671|             throw new QueryException(
    672|                 $query, $this->prepareBindings($bindings), $e
    673|             );
    674|         }
    675|

  • Database name seems incorrect: You're using the default database name `homestead`. This database does not exist.

    Edit the `.env` file and use the correct database name in the `DB_DATABASE` key.
    https://laravel.com/docs/master/database#configuration

      +34 vendor frames
  35  artisan:37
      Illuminate\Foundation\Console\Kernel::handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

I restarted docker but I still have the same error !

Jun
05
2 months ago
Activity icon

Replied to Is It Correct To Put A Function Inside A Method Class ?

:) thanks for your answers .

Activity icon

Replied to Is It Correct To Put A Function Inside A Method Class ?

Thanks for your answers ,

My question is more general : is it possible (good or bad habit) to add a function inside a method or better put this function in (public or private ... method) :

class A {
	public function myMethod() {

		function hello($param1, $param2) {
		return $someData
		}

		$var1 = hello('a',$data1);
		$var2 = hello('a',$data2);

	}
}

OR better ?

class A {
	public function myMethod() {
		$var1 = $this->hello('a',$data1);
		$var2 = $this->hello('a',$data2);

	}

	public (or private ..) function hello(param1,param2) {
	return $someData
	}
}
Activity icon

Replied to Is It Correct To Put A Function Inside A Method Class ?

hello method is with two params : hello(param1,param2)

class A {
	public function myMethod() {

		function hello(param1,param2) {
		return $someData
		}

		$var1 = hello('a',$data1);
		$var2 = hello('a',$data2);

	}
}

thanks

Activity icon

Replied to Is It Correct To Put A Function Inside A Method Class ?

@tykus

I review one code and I found something like that ! i'm wondering if it's a bad practice ?

Activity icon

Started a new Conversation Is It Correct To Put A Function Inside A Method Class ?

Hello ,

is it correct to add a function inside a method class ?

like :

class A {
	public function myMethod() {
		function hello() {
		return true
		}
	}
}
Activity icon

Started a new Conversation Migration : String Length

Hello ,

I have a column status which always has 6 digits (001245, 802225, 000001, ....)

the type of this column is string , when I create the migration without specify the length $table->string('name'); will it automatically depends to the entered string length ? or should I specify it : $table->string('name', 6); ?

May
29
2 months ago
Activity icon

Started a new Conversation PhpStorm: After Installing Barryvdh/laravel-ide-helper, I Got : Multiple Definitions Exist For Class

Hello ,

I installed barryvdh/laravel-ide-helper and now I see this message (Multiple definitions exist for class ... ) appears in many places !

when I ctrl+click I see two choices :

.../_ide_helper.php and ...\Illuminate\Support\Facades

Also for models it's not auto complete and when I type model::where(... it shows me : Method 'where' not found in \App

May
28
2 months ago
Activity icon

Replied to How To Use `.env` Variable In VueX ?

@michaloravec

One remark : in deployment server config('app.url') is not working it returns empty value

Activity icon

Started a new Conversation PhpStorm : Undefined Class 'Validator' But It Works Without Problem ?

Hello :

I got some warnings from phpStorm :

the first : use Validator;=> Undefined class 'Validator'

the second : where('company_id', $companyId) =>Method 'where' not found in \App\Line

Should I add something to my IDE?

use App\Line;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;



use Validator; <= HERE




use App\Http\Resources\Line as LineResources;
class LineController extends BaseController
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        $companyId = companyData()->id;
        $lines = Line::



        where('company_id', $companyId) <= HERE



            ->get();
        return $this->sendResponse(LineResources::collection($lines), 'Lines retrieved successfully.');
    }
Activity icon

Replied to How To Use `.env` Variable In VueX ?

I found this solution and it works :

in app.blade.php

<script>
    let APP_URL = "{{ env('APP_URL')}}";
</script>
<script src="{{ mix('js/app.js') }}" type="text/javascript"></script>

But I don't know if it is the best solution or not ???

Activity icon

Started a new Conversation How To Use `.env` Variable In VueX ?

Hello ,

I created a SPA with vueJS and vueX.

in vuex state.js file :

export default {
    baseUrl: 'http://mylocalhomestead.com/api/',
    count: 0,
    status: '',
    token: localStorage.getItem('token') || '',
    user : {}
}

I want to ask if there is a way to use APP_URL=http://mylocalhomestead which exists in .env ?

May
27
2 months ago
Activity icon

Replied to How Add Permission To Storage Directory ?

@tray2

I did both : sudo chmod -R 755 storage and sudo chmod -R 775 storage but always same problem !

Activity icon

Replied to How Add Permission To Storage Directory ?

@drewdan I tried : sudo chown -R username:group directory but it's not changing anything

Activity icon

Replied to How Add Permission To Storage Directory ?

@drewdan thanks for your answer ,

I use command line (ubuntu 20)

Activity icon

Started a new Conversation How Add Permission To Storage Directory ?

Hello ,

After cloning my project and composer install, I had the 500 error message ,

the error log is :

[Wed May 27 19:40:45.218748 2020] [php7:error] [pid 81545] [client ::1:40066] PHP Fatal error:  Uncaught ErrorException: file_put_contents(/var/www/coorza/storage/framework/views/c66f67b88a20240670a501b10fd9bb23cb42ab55.php): failed to open stream: Permission denied in /var/www/coorza/vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php:133\nStack trace:\n#0 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions->handleError()\n#1 /var/www/coorza/vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php(133): file_put_contents()\n#2 /var/www/coorza/vendor/laravel/framework/src/Illuminate/View/Compilers/BladeCompiler.php(150): Illuminate\Filesystem\Filesystem->put()\n#3 /var/www/coorza/vendor/laravel/framework/src/Illuminate/View/Engines/CompilerEngine.php(51): Illuminate\View\Compilers\BladeCompiler->compile()\n#4 /var/www/coorza/vendor/facade/ignition/src/Views/Engines/CompilerEngine.php(37): Illuminate\View\Engines\CompilerEngine->get()\n#5 /var/www/coorza/vendor/laravel/framework/src/Illuminate/View/View.php(139): Facade\Ignition\Views\Engines\CompilerEngine->get()\n#6 /va in /var/www/coorza/vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php on line 133

I thinks it's a permission issue ,

here the files :

total 928
drwxr-xr-x 14 root     root       4096 Mai 27 19:56 ./
drwxrwxrwx  4 root     root       4096 Mai 27 19:11 ../
drwxr-xr-x  6 www-data www-data   4096 Mai 27 19:11 app/
-rw-r--r--  1 www-data www-data   1686 Mai 27 19:11 artisan
drwxr-xr-x  3 www-data www-data   4096 Mai 27 19:11 bootstrap/
-rw-r--r--  1 www-data www-data   1729 Mai 27 19:11 composer.json
-rw-r--r--  1 www-data www-data 242693 Mai 27 19:11 composer.lock
drwxr-xr-x  2 www-data www-data   4096 Mai 27 19:11 config/
drwxr-xr-x  5 www-data www-data   4096 Mai 27 19:11 database/
-rw-r--r--  1 root     root        220 Mai 27 19:11 .editorconfig
-rw-r--r--  1 root     root        778 Mai 27 19:11 .env
-rw-r--r--  1 root     root        275 Mai 27 19:11 .eslintrc.js
drwxr-xr-x  8 root     root       4096 Mai 27 19:11 .git/
-rw-r--r--  1 root     root        111 Mai 27 19:11 .gitattributes
-rw-r--r--  1 root     root        163 Mai 27 19:11 .gitignore
drwxr-xr-x  4 root     root       4096 Mai 27 19:11 .idea/
-rw-r--r--  1 www-data www-data   1693 Mai 27 19:11 package.json
-rw-r--r--  1 www-data www-data 587785 Mai 27 19:11 package-lock.json
-rw-r--r--  1 www-data www-data   1197 Mai 27 19:11 phpunit.xml
drwxr-xr-x  6 www-data www-data   4096 Mai 27 19:33 public/
-rw-r--r--  1 www-data www-data   4497 Mai 27 19:11 README.md
drwxr-xr-x  6 www-data www-data   4096 Mai 27 19:11 resources/
drwxr-xr-x  2 www-data www-data   4096 Mai 27 19:11 routes/
-rw-r--r--  1 www-data www-data    563 Mai 27 19:11 server.php
drwxrwxrwx  5 www-data www-data   4096 Mai 27 19:11 storage/
-rw-r--r--  1 root     root        174 Mai 27 19:11 .styleci.yml
drwxr-xr-x  4 www-data www-data   4096 Mai 27 19:11 tests/
drwxr-xr-x 53 www-data www-data   4096 Mai 27 19:27 vendor/
-rw-r--r--  1 www-data www-data    852 Mai 27 19:11 webpack.mix.js

May
26
2 months ago
Activity icon

Started a new Conversation Should I Add Unique() To One-to-one Relationship Migration ?

Hello ,

here the Migration :

We have phones table and users table one-to-one relationship :

Schema::create('phones', function (Blueprint $table) {

    $table->increments('id');

    $table->integer('user_id')->unsigned();

    $table->string('phone');

    $table->timestamps();

   

    $table->foreign('user_id')->references('id')->on('users')

        ->onDelete('cascade');

});

Is it recommended to add unique() to $table->integer('user_id')->unsigned(); ?

Or just make it as a condition in Validation ?

Thanks

May
25
2 months ago
Activity icon

Started a new Conversation How To Access $store (vueX) From A Validation Constant In Javascript ?

Hello ,

In my code I use vueX and vueLidate

<script>
    import {validationMixin} from 'vuelidate'
    import {required,} from 'vuelidate/lib/validators'

    const officialNameUnique = (value) => {
        return value.indexOf('cool') >= 0
    }

in officialNameUnique I need to access to $store.getters.stops array then to filter it to check if the officialName is unique or not.

the problem is $store is not defined !

Is there a way to access to $store ?

Activity icon

Replied to How To Add Extra Condition To JS Filter ?

@tykus thanks ,

this.stops.filter(stop => stop.action || stop.action.name !== 'add')

not working but I added stop.action===undefined and it works

this.stops.filter(stop => stop.action===undefined || stop.action.name !== 'add')
Activity icon

Started a new Conversation How To Add Extra Condition To JS Filter ?

Hello

the code bellow filter stops array and keeps only elements with stop.action.name !== 'add' :

this.stops.filter(stop => stop.action.name !== 'add')

But some elements are without action attribute, which returns me this error Cannot read property 'name' of undefined"

My question is : how to add another condition to filter (need something like : stop.action !== undefined) to void this error message ?

May
21
2 months ago
Activity icon

Started a new Conversation How To Post And Receive A Javascript Array ?

Hello ,

I have a JS array that I would like to post it to stopController (store method).

[
{"id":317,"long":"-1.9663780","lat":"34.6561680","official_name":"Florence Hill","name":"Jessika Common","terminus":0,"created_at":"2020-05-10T14:11:29.000000Z","updated_at":"2020-05-10T14:11:29.000000Z","line_id":104,"order":null},

{"id":1151,"long":"-1.9669780","lat":"34.6541680","official_name":"Florence Hill - 1","name":"Jessika Common -1","terminus":0,"created_at":"2020-05-10T14:11:29.000000Z","updated_at":"2020-05-10T14:11:29.000000Z","line_id":104,"order":null},

{"id":1152,"long":"-1.9666780","lat":"34.6531680","official_name":"Florence Hill - 2","name":"Jessika Common -2","terminus":0,"created_at":"2020-05-10T14:11:29.000000Z","updated_at":"2020-05-10T14:11:29.000000Z","line_id":104,"order":null}

]

to post this values :

deleteStop(){
                this.$store.dispatch('saveStops',{stops:this.stops}).then(
                    response=>{
                        console.log(response.data)
                    }
                )
            },

I'm wondering , how to save() this array of objects in the store method in stopController ?

May
18
2 months ago
Activity icon

Started a new Conversation Is It Possible To Access To My App From Other Devices (Vagrant Homestead)

Hello

I use virtual machine + homestead + vagrant in windows 10

How can I make my app accessible from other devices (same network or better if from any device) ?

Thanks

Activity icon

Replied to JAVASCRIPT : How To Explode An Array Of Strings ?

@mkshingrakhiya thanks , but it's in JS not PHP

Activity icon

Replied to How To Get Token Key Without User Name And Password ?

@ignisrzeus

Thanks for your answer , In the client side (Raspberry device) from where I send the GPS position to the server (Laravel passport) I use only python script to POST coordinates. so there is no web browser at all.

But I think your answer is enough for me because I will create in Laravel passport one token then add it directly to the Python script.

Activity icon

Started a new Conversation JAVASCRIPT : How To Explode An Array Of Strings ?

Hello ;

I have this array bellow :

["a","b","0","4","XXXX","j","t"]

How to explode all its elements to be like :

["a","b","0","4","X","X","X","X","j","t"]

Thanks

May
17
2 months ago
Activity icon

Started a new Conversation How To Get Token Key Without User Name And Password ?

Hello ,

Let me first explain my case :

I installed Laravel passport and now i'm able to get the token key to POST, GET,DELETE .... without any issues ,

In my project I have to send GPS coordinates to the server (Laravel passport) from a Raspberry pi device.

I installed a cron job in this device to execute a python code every minute to POST coordinates to the server.

My question is : should I login then get the token every time when I POST the coordinates to the server? or there is a way to have a static token which I can store it in the raspberry ?

Thanks

Activity icon

Replied to How To Act When The Deleted Item Does Not Exists ?

@michaloravec Thanks ,

so it's not possible to keep destroy(Line $line) ?

Activity icon

Started a new Conversation How To Act When The Deleted Item Does Not Exists ?

hello ,

here bellow the destroy method

public function destroy(Line $line)
    {

        $data = $line->delete();

    }

The problem is when the record does not exists (DELELTE: http://myhomestead.com/api/lines/9) I receive this error message :

"message": "No query results for model [App\Line] 9",
    "exception": "Symfony\Component\HttpKernel\Exception\NotFoundHttpException",
    "file": "/home/vagrant/code/coorza/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php",
    "line": 222,

Question: How to avoid this error message and instead I send 'this Item does not exists' ?

May
16
2 months ago
Activity icon

Started a new Conversation Need For Explanation : Why This Validation Works ?

According to a previous question , I did some search and I found how to validate two columns :

my table is : Lines it has those fields: (id, number, ... , company_id)

the validation was : make sure that number AND company_id are unique

the code bellow solves this issue :

'number' => 'required|unique:lines,number,NULL,id,company_id,'.companyData()->id,

companyData()->id (helper) is the company_id

My question is: How this works? why need for NULL?

Thanks

May
15
2 months ago
Activity icon

Started a new Conversation How To Get The Position Of Cursor In InputText ?

Hello ,

I try to get the cursor position in the input field but it's not working ! event.target.selectionStart returns always 0

  const handleFocus = (event) => {
    console.log(event.target.selectionStart)
  }


(...)

<TextField
                  className={classes.textField}
                  error={hasError('email')}
                  fullWidth
                  helperText={
                    hasError('email') ? formState.errors.email[0] : null
                  }
                  label="User"
                  name="email"
                  onChange={handleChange}
                  type="text"
                  value={formState.values.email || ''}
                  variant="outlined"


                  onFocus={handleFocus}


                />

May
14
2 months ago
Activity icon

Started a new Conversation Validation On Two Columns

Hello,

the validation bellow works to check if number exists already or not :

$validator = Validator::make($input, [
            'number' => 'required|unique:lines',
            'official_name' => 'required',
            'terminus'
        ]);

but I want it to be like : (number AND company_id) to be unique,

How to do that ?

Activity icon

Started a new Conversation How To Configure Eslint ?

Hello

First I use PHPstorm IDE(2020) + vueJS SPA

I installed EsLint in my Vuejs project but this correct only the empty spaces !

ESLint: Expected indentation of 4 spaces but found 8 spaces.(vue/html-indent)

For example if I create unused variable it says nothing ....

Is it possible to add more validation ?

here my config file :

module.exports = {
    extends: [
        // add more generic rulesets here, such as:
        // 'eslint:recommended',
        'plugin:vue/recommended'
    ],
    rules: {
        // override/add rules settings here, such as:
        // 'vue/no-unused-vars': 'error'
    }
}

May
13
3 months ago
Activity icon

Replied to How To Shortcut The Path To The Assets Directory In Vuejs SPA?

@sidneygijzen Thanks :

my files structure is :

node_modules
---------------------
public
---------
resources|
-------------------|js
                        -----|assets
                               -----------|svg
                                              ------|files(...)

I dont have webpack.config.js but I have webpack.mix.js

I added in webpack.mix.js

const path = require('path')

module.exports = {
    resolve: {
        alias: {
            '@assets': path.resolve(__dirname, 'resources/js/assets')
        }
    }
}

in component :

<img src='@assets/svg/icons8-bus-30.png'/>

and it's not working !

Activity icon

Started a new Conversation How To Shortcut The Path To The Assets Directory In Vuejs SPA?

Hello,

How to change this long path <img src="./../../assets/svg/icons8-bus-30.png" alt=""> to something like : <img src="@assets/svg/icons8-bus-30.png" alt=""> ?

Thanks