COACHTHEM

COACHTHEM

Member Since 2 Years Ago

Experience Points
8,690
Total
Experience

1,310 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
62
Lessons
Completed
Best Reply Awards
0
Best Reply
Awards
  • start-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-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-token Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer-token Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • lara-evanghelist 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 2
8,690 XP
Oct
07
1 week ago
Activity icon

Started a new conversation Paginate() With Custom Data.

Here is my use case.

  1. I have to fetch blog data by writing sql query and the data needs to be paginated.
  2. The data fetched from above query needs to be looped to create image url for each blog.
  3. After looping each blog record I create a new dimensional array which has all the blog details along with image url

below is the code sample with which I want to fetch all blog data with process image url and I also expect it has pagination details like the total no of pages, current page etc.

public function getBlogs(Request $request) {

   $rawBlogs = DB::table('blogs')
   ->select(['id', 'title', 'content', 'status', 'blog_image'])
   ->where([
       ['status', '=',  'A']
   ])
   ->orderBy('id', 'DESC')
   ->paginate();

   $Blogs = [];
   foreach($rawBlogs-items() as $rawBlog){

       $blog_path = config('app.BLOG_IMAGE_PATH'); 
       $imgPath = $blog_path . $rawBlog->blog_image; 
       $Url = \Storage::url($imgPath); 

       $Blogs[] = [
           'id' => $rawBlog->id,
           'title' => $rawBlog->title,
           'content' => $rawBlog->content,
           'status' => $rawBlog->status,
           'blog_image' => $Url
       ];       

   }

   return [
    'data' => $Blogs,

    current_page => ?,
    first_page_url => ?,
    from => ?,
    next_page_url => ?,
    first_page_url => ?,
    path => ?,
    per_page => ?,
    prev_page_url => ?,
    total => ?  
];

}

Sep
24
2 weeks ago
Activity icon

Replied to In Vue How To Get The Child Data Into Parent Component

Thanks @mariohbrino for the Solution.. that worked like a charm.

Thank you @willvincent for explaining more in details about two way binding aspect of props between parent and child components.

also thanks to @rouge847

cheers !

Sep
23
3 weeks ago
Activity icon

Started a new conversation In Vue How To Get The Child Data Into Parent Component

I have a listing of child components, each component is passed with props data(default values), The child component receives that props data and updates it.

Now after modifying all the prop data from each child component I want to get it in the Parent component.

What would be the best way to handle this case. Should I be using this.$emit('update-parent-props', process_data) custom event for this or is there a better way?

Sep
22
3 weeks ago
Activity icon

Replied to In Vue How To Update Style Attribute Based On Multiple Conditions

Thanks for the solution @bobbybouwmann . Both solutions works fine. but I think using computed properties makes more sense in terms of performance.

Sep
21
3 weeks ago
Activity icon

Started a new conversation In Vue How To Update Style Attribute Based On Multiple Conditions

I am trying to create a inline css property based on certain multiple conditions. I am not sure if the below thing is right way of doing it

:style=" (mode=='edit' && displayTcInputType==true) ? 'visiblity: visible;' : 'visiblity: hidden;' "

Activity icon

Replied to Session Getting Destroyed After Payment Gateway Redirecting To Success Callback Url.

OK I figured out the problem for myself.

In the config/session.php file I changed the configuration from 'same_site' => "strict", to 'same_site' => "lax",

Aug
06
2 months ago
Activity icon

Replied to Virtual Host Set Up

Here is my conf file on ubuntu /etc/apache2/sites-available/test.sip.ch.conf

<VirtualHost *:80>
    ServerName test.sip.ch
    
    DocumentRoot /var/www/vhost/testsipch/public
    
    ErrorLog /var/log/apache2/testsipch.log
    CustomLog /var/log/apache2/testsipch.log combined
    
    <Directory /var/www/vhost/testsipch/public>
        Options Indexes FollowSymLinks Includes ExecCGI
        AllowOverride All
        Require all granted
    </Directory>

</VirtualHost>

after adding the file execute sudo a2ensite test.sip.ch.conf and then execute sudo systemctl reload apache2

Activity icon

Replied to Session Getting Destroyed After Payment Gateway Redirecting To Success Callback Url.

Yeah I can do that but the problem is that it destroys the session and also logs the user out which is not normal.

Activity icon

Replied to Session Getting Destroyed After Payment Gateway Redirecting To Success Callback Url.

I did that too. but still the same.

I think it migh be this case as mentioed on Stackoverflow

When you use sessions, a SESSION_ID (or similar) cookie is sent to the browser to know what session is associated with each request.

Your processPayment method is called after a request from a user (it's certainly your js script that issues the request but it's the same), and you store data in the session linked to this particular user.

After PayPal finished its job, it does a request to a callback URL. This request is done by PayPal but not by your user you stored the data for. PayPal has no idea of the session cookie, so Laravel start a new empty session.

here is the link https://stackoverflow.com/questions/55027854/laravel-5-session-disappearing-after-redirection

but really dont know how to fix it

Activity icon

Replied to Session Getting Destroyed After Payment Gateway Redirecting To Success Callback Url.

@ajithlal here is my configurations

    'driver' => env('SESSION_DRIVER', 'file'),

    /*
    |--------------------------------------------------------------------------
    | Session Lifetime
    |--------------------------------------------------------------------------
    |
    | Here you may specify the number of minutes that you wish the session
    | to be allowed to remain idle before it expires. If you want them
    | to immediately expire on the browser closing, set that option.
    |
    */

    'lifetime' => env('SESSION_LIFETIME', 30),

    'expire_on_close' => true,

    /*
    |--------------------------------------------------------------------------
    | Session Encryption
    |--------------------------------------------------------------------------
    |
    | This option allows you to easily specify that all of your session data
    | should be encrypted before it is stored. All encryption will be run
    | automatically by Laravel and you can use the Session like normal.
    |
    */

    'encrypt' => false,

the problem is only when the payment gateway redirects back to the success callback url the session is destroyed automatically.

Activity icon

Started a new conversation Session Getting Destroyed After Payment Gateway Redirecting To Success Callback Url.

Laravel Session getting destroyed after Payment gateway redirecting to success callback url.

Any Idea of resolving this issue.

Jul
17
2 months ago
Activity icon

Replied to ES6 Features Like Arrow Function, Array.from() Not Working After Compiling Js Files With LaravelMix.

@mvd I am looking for pollyfillying solution with babel.. Also I Think it should be possible to implement useing laravel mix out of the box.

Activity icon

Started a new conversation How To Make Es6 Code Work On Internet Explorer 11 With Laravel Mix()

I tried compiling my js / vue code usiing laravel mix .. below is my code for reference.

mix.js('resources/assets/js/app-customer.js', 'public/js/bundle-customer.js')
    .polyfill({
        enabled: true,
        useBuiltIns: "usage",
        targets: {"firefox": "50", "ie": 11}
    });
mix.babel(['public/js/bundle-customer.js'], 'public/js/bundle-customer.js');

if I use mix.js() and then chain polyfill() method it does not work on IE 11.. Some of the es6 features does not work on IE but works well on Chrome, Firefox etc..

then I thought of caling a babel() method on the compiled code by mix.js() after doing that it gives me below error in the terminal and also errors on the browser.

[BABEL] Note: The code generator has deoptimised the styling of undefined as it exceeds the max of 500KB.

Can you please guide me how to make the js code work on IE browser using laravel mix

Jul
16
2 months ago
Activity icon

Started a new conversation Mix Compiled Js Code Not Working On With Pollyfill

I used this https://laravel-mix.com/extensions/polyfill Laravel Mix pollyfill to support js code on IE11

unforfunately some ES6 features not working.

below is my webpack.mix.js file looks like

let mix = require('laravel-mix');

require('laravel-mix-polyfill');

mix.js('resources/assets/js/signalq/signalq-base.js', 'public/js/signalQ-base.js')
    .polyfill({
        enabled: true,
        useBuiltIns: "usage",
        targets: {"firefox": "50", "ie": "11"}
    });
Jul
15
2 months ago
Activity icon

Started a new conversation ES6 Features Like Arrow Function, Array.from() Not Working After Compiling Js Files With LaravelMix.

ES6 features like arrow function, Array.from() not working after compiling js files.

I get this error in IE browser SCRIPT438: Object doesn't support property or method 'from' for Array.from()

And getting this error in IE SCRIPT1003: Expected ':' for the below compiled code.

data () {
    return {name: 'manny'}
}

Below is my package.json file

{
    "private": true,
    "name": "test.me",
    "version": "2.0.0",
    "description": "test app",
    "license": "UNLICENSED",
    "repository": {
        "type": "git",
        "url": ""
    },
    "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.19.0",
        "cross-env": "^5.1",
        "laravel-mix": "^4.0.0",
        "lodash": "^4.17.10",
        "sass": "^1.15.2",
        "sass-loader": "^7.0.3",
        "vue": "^2.5.17",
        "vue-template-compiler": "^2.5.21"
    },
    "dependencies": {
        "accounting": "^0.4.1",
        "acorn": "^6.2.0",
        "acorn-dynamic-import": "^4.0.0",
        "ajv": "^6.5.2",
        "braintree-web": "^3.35.0",
        "composer": "^4.1.0",
        "crypto-js": "^3.1.6",
        "friendly-errors-webpack-plugin": "^1.7.0",
        "js-cookie": "^2.2.0",
        "jspdf": "^1.4.1",
        "minimatch": "^3.0.4",
        "moment": "^2.22.2",
        "moment-timezone": "^0.5.21",
        "node-sass": "^4.12.0",
        "npm": "^6.10.0",
        "open": "^6.4.0",
        "optimize-css-assets-webpack-plugin": "^5.0.3",
        "pikaday": "^1.7.0",
        "rollbar-browser": "^1.9.5",
        "rsvp": "^3.6.2",
        "save": "^2.4.0",
        "string.prototype.startswith": "^0.2.0",
        "twobirds-core": "^7.3.146",
        "update": "^0.7.4",
        "vue-i18n": "^7.8.1",
        "vue-router": "^2.0.0",
        "vue2-filters": "^0.3.0",
        "vue2-timepicker": "^0.1.4"
    },
    "browserify": {
        "transform": [
            "partialify"
        ]
    }
}

I am using Laravel 5.5 and it uses LaravelMix 4 with Babel 7

Any help is appriciated. thnaks.

Mar
27
6 months ago
Activity icon

Replied to How Can I Create A Link To Download / Open The Laravel.log File In My App

Thanks @aurawindsurfing for the solution. I also found a library to monitor my logs within the app. here is the link https://github.com/rap2hpoutre/laravel-log-viewer

Activity icon

Started a new conversation How Can I Create A Link To Download / Open The Laravel.log File In My App

How can I create a link to download / open the laravel.log file in my laravel app.

I have created a separate log file for a specific task and want to track things to specific task. I achieved this by using below code.

Log::useDailyFiles(storage_path( '/logs/statistics_jobs_'.$StatisticJob->id.'.log' ));
Log::info($data);

the above code creates the log file in storage/logs directory.

Now I want to download the file within my application. so how can I create a link to open that log file

Mar
07
7 months ago
Activity icon

Started a new conversation 504 Gateway Time-out Nginx/1.15.6

I am using Aws Server and using Nginx as the web server. While trying to executed a php script I am getting 504 Gateway Time-out Nginx/1.15.6 error response. The php script has too many processing / calculations

Any Idea what should I be doing here.

Thanks.

Sep
20
1 year ago
Activity icon

Started a new conversation How To Add Logo For Email Notification Template

I published the email template by executing php artisan vendor:publish --tag=laravel-notifications

now I see the template file here resources/views/vendor/notifications How can I put the log on top of the header where app name is present.

Also how can I change the background color of the header.

Aug
17
1 year ago
Activity icon

Replied to Is It Possible To Track The Users Info In The Report Method Of Handler Class

Hey @crnkovic , Sorry I did not understand what you mean by "move middleware to start session up to the global middleware (not only web)" can explain in details what I need to do. I am using laravel 5.5

Activity icon

Started a new conversation Is It Possible To Track The Users Info In The Report Method Of Handler Class

I am handling all my exceptions in report() method of App/Exceptions/Handler class. I want to track which user is getting exceptions into my app.

So I tried using Auth::id(); to get the users ID inside the report() method, but unfortunately it returns nothing. While doing this I had made sure that I was logged in but still it did not return any value.

Is the a way that I track which user is getting exceptions.

Aug
03
1 year ago
Activity icon

Replied to How Can I Have Homestead As Well As Local PHP Environment Working Together At The Same Time On My Mac.

I deleted the old copy of magento2 and tried reinstalling but while doing that I get Mcrypt error.

Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Installation request for magento/product-community-edition 2.2.5 -> satisfiable by magento/product-community-edition[2.2.5].
    - magento/product-community-edition 2.2.5 requires ext-mcrypt * -> the requested PHP extension mcrypt is missing from your system.

  To enable extensions, verify that they are enabled in your .ini files:
    - /usr/local/etc/php/7.1/php.ini
    - /usr/local/etc/php/7.1/conf.d/php-memory-limits.ini
  You can also run `php --ini` inside terminal to see which files are used by PHP in CLI mode.
Manjunaths-MacBook-Pro:magento2 manjunathpadolkar$ composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition
Aug
02
1 year ago
Activity icon

Replied to How Can I Have Homestead As Well As Local PHP Environment Working Together At The Same Time On My Mac.

@skoobi I am now running my magento2 project on php7.2 by specifying it in .yaml file

sites:
    - map: me.magento2
      to: /home/vagrant/Code/magento2
      php: "7.2"

but still no luck. Magento is still struggling to load.. I doubt it might be the problem with memory allocation for the virtual box.. I have set memory to 2048

ip: "192.168.10.10"
memory: 2048
cpus: 1
provider: virtualbox

Your thought

Activity icon

Replied to How Can I Have Homestead As Well As Local PHP Environment Working Together At The Same Time On My Mac.

I use PHP 7.1.4

so if I upgrade to 7.2 you think Magento will work for me

Activity icon

Replied to How Can I Have Homestead As Well As Local PHP Environment Working Together At The Same Time On My Mac.

@skoobi I tried installing magento2 inside homestead but its not loading well. it just redirects to /setup and becomes blank.. so that is the reason I want have have a separate ENV

here is the screenshot https://prnt.sc/kdsy2x

Activity icon

Replied to How Can I Have Homestead As Well As Local PHP Environment Working Together At The Same Time On My Mac.

@tykus I have installed homestead which is working fine.. I am just worried If I install one more local server then that might screw my homestead.. I am worried if ports might conflict with each others.

Activity icon

Started a new conversation How Can I Have Homestead As Well As Local PHP Environment Working Together At The Same Time On My Mac.

I am currently using homestead for laravel applications.. I want to have a separate local PHP ENV on my mac so that I can work on non laravel projects.

I would like to have both the EVN active at the same time..

I am currently using MacOS High Sierra..

I am looking for links that will guide me through the process. Thanks in advance.

Activity icon

Started a new conversation In Homestead How To Change All Default Ports.

I am using laravel Homestead environment for my development. which is using default ports like 80 for HTTP, 3306 for MySQL, 443 for HTTPS..

How can I change them to something else.

Jun
27
1 year ago
Activity icon

Replied to How To Use "IN" Mysql Clause Using PDO Statement.

Thank you guys for the help.

Activity icon

Replied to How To Use "IN" Mysql Clause Using PDO Statement.

@Yorki @ccarver @click I normally write my query using eloquent.. but in this case I am using PDO style named binding because I have to execute a query which uses derived tables (https://www.wiseowl.co.uk/blog/s360/sql-derived-tables.htm) I am not sure if Laravel's ORM supports derived table queries. Just because of this I am writing the query in PDO style.

@click I am going to try your solution and also want to know how we can do it with Named Bindings

Activity icon

Started a new conversation Error : Array To String Conversion (SQL: Select * From User Where Status In (:status) )

Getting an error while executing query with in statement.

below is my code

DB::select(" select * from user where status in ( :status ) ", [
    'status' => ['A','X']
]);

and I get below error.

 Illuminate \ Database \ QueryException
Array to string conversion (SQL: select * from user where status in (:status) )

Thanks in advance.

Activity icon

Replied to How Can I Implement "LIKE" Clause In My Sql Statement In PDO Style Named Bindings.

if I use this

DB::select(" select * from user where status in (:status) ", [
    'status' => ['A','X']
]);

it throws an error

Array to string conversion (SQL: select * from user where status in (:status) )
Activity icon

Replied to How Can I Implement "LIKE" Clause In My Sql Statement In PDO Style Named Bindings.

Seems like I found what I was looking for.. Here is how I can implement it using laravel's DB class and with PDO statement

\DB::select(" select * from user where email like (:email) ", [
            'email'=>'katie%' 
]);

Now similarly can anyone help how to implement IN clause

Activity icon

Started a new conversation How Can I Implement "LIKE" Clause In My Sql Statement In PDO Style Named Bindings.

How can I implement "LIKE" clause in my sql statement when using PDO style query in laravel with named bindings.

Basically i want to achieve below using PDO named bindings

select name from user where name like "%Manny%"
Activity icon

Replied to How To Use "IN" Mysql Clause Using PDO Statement.

Thanks @Yorki But I am looking for a solution with PDO style syntax.. I am trying to Bind values using Named Bindings as shown in the above e.g

Activity icon

Started a new conversation How To Use "IN" Mysql Clause Using PDO Statement.

I am trying to use "IN" clause in my sql statement using PDO way. Below is the e.g of what I want to achieve.

select name from user where status in ('A', 'I')

I tried below code using DB::select() method but did not work as expected.

DB::select(" select name from user where status in ( :status ) ", [
    'status'=>['A', 'I']
]);

Any Idea how to implement "IN" clause. Thanks in advance.

Activity icon

Replied to Will A Magento Site Work On Laravel Homestead

@Cronix @amirhazz Thank you guys for the references.

Jun
25
1 year ago
Activity icon

Started a new conversation Will A Magento Site Work On Laravel Homestead

I have installed Laravel Homestead on my mac and have hosted laravel project. Just wan to know if I can use the same environment to host Magento 2 Projects.

Thanks.

Jun
18
1 year ago
Activity icon

Replied to SQLSTATE[HY093]: Invalid Parameter Number: Parameter Was Not Defined

For me too its not working

            $result = \DB::select(
                " select * from user where id = :id ",
                [
                    'id' => $id
                ]
            );

I get below error

SQLSTATE[HY093]: Invalid parameter number: parameter was not defined (SQL: select * from user where id = :id )

I am doing this on my homestead machine.. is it something to do with mysql configuration?

May
23
1 year ago
Activity icon

Replied to Best Practice For Passing Data To View.

Thanks @lostdreamer_nl for the suggestion. Can I know the reason why not to use toArray() method.

Activity icon

Started a new conversation Best Practice For Passing Data To View.

Here is an example of displaying profile pics of list of users done in two different ways. I want to know what would be the good practice in terms of passing data to view. should I be looping the raw data in the controller method to fetch the image or do it while looping with in the view.

Way 1

public function controllerMethodHere(){
    
    $RawUsers = User::select([
        'id',
        'pic'
    ])
    ->where([
        ['status', 'A']
    ])
    ->get()
    ->toArray();

   $Users = [];
   foreach($RawUsers as $RawUser){

       $profile_pic = config('app.USER_DEFAULT_PIC');
       if(
           strlen(trim($RawUser['pic']))
           && \Storage::exists( config('app.USER_CDN_PATH').$RawUser['pic'] )
       ){
           $profile_pic = \Storage::url( config('app.USER_CDN_PATH').$RawUser['pic'] );
       }

       $RawUser['profile_pic'] = $profile_pic;
       $Users[] = $RawUser;

   }

   return view('user.list',[
       'Users'=>$Users
   ]);    

}


user/view.blade.php
<div>
@foreach ($Users as $User)
    <img src="'{{ $User['profile_pic'] }}'">
@endforeach
</div>

Way 2.

public function controllerMethodHere(){
    
    $Users = User::select([
        'id',
        'pic'
    ])
    ->where([
        ['status', 'A']
    ])
    ->get()
    ->toArray();

   return view('user.list',[
       'Users'=>$Users
   ]);    

}


user/list.blade.php
<div>

<div>
@foreach ($Users as $User)
    @php 
           $profile_pic = config('app.USER_DEFAULT_PIC');
           if(
               strlen(trim($User['pic']))
               && \Storage::exists( config('app.USER_CDN_PATH').$User['pic'] )
           ){
               $profile_pic = \Storage::url( config('app.USER_CDN_PATH').$User['pic'] );
           }            
    @endphp
    <img src="'{{ $profile_pic }}'">
@endforeach
May
15
1 year ago
Activity icon

Replied to Is It Good Practice To Include Classes Using Use Statement Or Specify The Class Only In The Method Required.

Thanks @xxRockOnxx @lostdreamer_nl for your suggestions. I am looking this in terms of code optimisation.. what if I want to use the class only in one method and I am sure about it that it will be used only in one method. so accessing it within the function, code execution will be faster ?

Activity icon

Started a new conversation Is It Good Practice To Include Classes Using Use Statement Or Specify The Class Only In The Method Required.

Is it good practice to include classes using use statement or specify the class only in the method required.

For example I want to use User class in one of my controllers methods for which I normally include it using use statement. Below is the code

namespace App\Http\Controllers;
use App\User;

I might require User class only in one method of my controller so is it good practice to specify User in the method required like mentioned below

public function userprofile(){

    $User = \App\User::first();

}

or include it on top of the controller class.

Your Thoughts please. Thanks.

May
07
1 year ago
Activity icon

Replied to Not Able To Access Custom Env() Values After Executing Php Artisan Config:cache

@36864 I am able to access the config values after after caching.. Just because I executed config:cache command I thought config values are not accessed. It is actually the env() values that are not accessible after caching config.

So in this case I will have to access all .env values in config file and from config I can access it anywhere in the project.

Activity icon

Replied to Not Able To Access Custom Env() Values After Executing Php Artisan Config:cache

Hey actually after executing php artisan config:cache my calls to env() method does not work.. for e.genv('APP_NAME') call return null value.

Activity icon

Replied to Not Able To Access Custom Env() Values After Executing Php Artisan Config:cache

Thanks @rin4ik for the suggestion. But why cant config('app.PROFILE_CDN_URL') work. I have implemented the whole project using above code as mentioned in the laravel docs https://laravel.com/docs/5.5/configuration#accessing-configuration-values

Activity icon

Started a new conversation Not Able To Access Custom Env() Values After Executing Php Artisan Config:cache

In laravel 5.5 app I have created custom config variables in my config/app.php for example

return [
    'PROFILE_CDN_URL' => env('CDN_URL').'uploads/profileimages/'
];

and then I am able to access the value by calling config('app.PROFILE_CDN_URL') but when in production after executing php artisan config:cache the value is printed as null.

Can anyone help please. Thanks in advance.