Cyber Monday! Get 25% off for as long as you keep your subscription. New subscribers only.

laurentm

laurentm

Member Since 2 Years Ago

Experience Points
530
Total
Experience

4,470 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
0
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 1
530 XP
Nov
27
3 days ago
Activity icon

Replied to Laravel + VUE SPA

can you give an example of code to do this?

Nov
26
4 days ago
Activity icon

Replied to Laravel + VUE SPA

Thank you for replying, this is the information i was missing: "As far as passing rights back to the interface, I typically would pass values into meta headers, then to state management in Vue, like VueX."

Nov
25
5 days ago
Activity icon

Started a new Conversation Laravel + VUE SPA

Assuming I am building an app in a spa mode with Vue and Laravel via API rest or grpahql I have the following roles:

  • Super admin
  • Admin
  • Client
  • Company staff

I got a left menu where items in this menu should be visibles based on roles (and obviously related routes accessible depending on those same roles by following those visibility).

What is the best way to implement this? Vue Auth (e.g websanova) + Laravel Auth (Passport ? Sanctum) ? Vue Auth only ? Laravel Auth only ?

I am a bit confused about what is the most secure way to perform this functionality.

Activity icon

Replied to Laravel Guards Vs Gates

thanks, very clear.

Nov
24
6 days ago
Activity icon

Started a new Conversation Laravel Guards Vs Gates

What are the differences between Guards and Gates ?

Nov
03
3 weeks ago
Activity icon

Replied to Path Of A Laravel 4 / 5 App

I am on 5.0 seems like. I think they didn't migrate properly from 4 to 5. I think they have created a new name space named L5 whcih they used in parallel of the L4 architecture...

I see this in the composer.json:

"autoload": {
	"classmap": [
		"database",
		"app/Console/Commands",
		"app/Http/Controllers",
		"app/Models",
		"app/A"
	],

What are classmap ?

Nov
02
4 weeks ago
Activity icon

Replied to Path Of A Laravel 4 / 5 App

This is what I am considering to do. I am just worry that I would need to rework every functions one by one.... What would be the method to verify if this is needed or not?

what I find a complete mess is Laravel framework moving constantly everything without consistency from version to version. Let's put the models in a folder, and on the next version let's move it to another folder and the next version let's move it again... from version 4 to 5 to 6 to 7...

Activity icon

Started a new Conversation Path Of A Laravel 4 / 5 App

Let's explain my problem: I am working on a Laravel app which was started on a Laravel 4 by a developper A. Later a developper B took over and moved the app to Laravel 5 "apparently". But I have impression it was not totally converted properly.

I see that some kind of patching has been done but that the app was not completely converted as it shoudl have. The app was placed in a folder named L5 which was placed directly on public_html folder, with all the app inside including .env !! Now obviously I want to move the app out of the public_html and make a symbolic link only for the public folder. Problem: when I place the app somewhere else than in the path public_html/L5/ then it break my code.

I digged inside some file to try to understand and I found this in the config/app.php:

providers => [

		/*
		 * Laravel Framework Service Providers...
		 */
		'Illuminate\Foundation\Providers\ArtisanServiceProvider',
		'Illuminate\Auth\AuthServiceProvider',
		'Illuminate\Bus\BusServiceProvider',
		'Illuminate\Cache\CacheServiceProvider',
		'Illuminate\Foundation\Providers\ConsoleSupportServiceProvider',
		'Illuminate\Routing\ControllerServiceProvider',
		'Illuminate\Cookie\CookieServiceProvider',
		'Illuminate\Database\DatabaseServiceProvider',
		'Illuminate\Encryption\EncryptionServiceProvider',
		'Illuminate\Filesystem\FilesystemServiceProvider',
		'Illuminate\Foundation\Providers\FoundationServiceProvider',
		'Illuminate\Hashing\HashServiceProvider',
		'Illuminate\Mail\MailServiceProvider',
		'Illuminate\Pagination\PaginationServiceProvider',
		'Illuminate\Pipeline\PipelineServiceProvider',
		'Illuminate\Queue\QueueServiceProvider',
		'Illuminate\Redis\RedisServiceProvider',
		'Illuminate\Auth\Passwords\PasswordResetServiceProvider',
		'Illuminate\Session\SessionServiceProvider',
		'Illuminate\Translation\TranslationServiceProvider',
		'Illuminate\Validation\ValidationServiceProvider',
		'Illuminate\View\ViewServiceProvider',
		'Aloha\Twilio\Support\Laravel\ServiceProvider',
		'LeadThread\Shortener\ShortenerServiceProvider',

		/*
		 * Application Service Providers...
		 */
		'L5\Providers\AppServiceProvider',
		'L5\Providers\BusServiceProvider',
		'L5\Providers\ConfigServiceProvider',
		'L5\Providers\EventServiceProvider',
		'L5\Providers\RouteServiceProvider',


		'L5\Providers\MacroServiceProvider',

		'Collective\Html\HtmlServiceProvider',
		'Cartalyst\Sentry\SentryServiceProvider',
		'DaveJamesMiller\Breadcrumbs\ServiceProvider',
		'Chumper\Datatable\DatatableServiceProvider',
		'GrahamCampbell\Security\SecurityServiceProvider',
		'Former\FormerServiceProvider',
		'Intervention\Image\ImageServiceProvider',
		'Ignited\LaravelOmnipay\LaravelOmnipayServiceProvider',
        'Laravel\Socialite\SocialiteServiceProvider',
        'Maatwebsite\Excel\ExcelServiceProvider',
        'Watson\Autologin\AutologinServiceProvider',
        'Torann\GeoIP\GeoIPServiceProvider'

	],

	/*
	|--------------------------------------------------------------------------
	| Class Aliases
	|--------------------------------------------------------------------------
	|
	| This array of class aliases will be registered when this application
	| is started. However, feel free to register as many as you wish as
	| the aliases are "lazy" loaded so they don't hinder performance.
	|
	*/

	'aliases' => [

		'App'       => 'Illuminate\Support\Facades\App',
		'Artisan'   => 'Illuminate\Support\Facades\Artisan',
		'Auth'      => 'Illuminate\Support\Facades\Auth',
		'Blade'     => 'Illuminate\Support\Facades\Blade',
		'Bus'       => 'Illuminate\Support\Facades\Bus',
		'Cache'     => 'Illuminate\Support\Facades\Cache',
		'Config'    => 'Illuminate\Support\Facades\Config',
		'Cookie'    => 'Illuminate\Support\Facades\Cookie',
		'Crypt'     => 'Illuminate\Support\Facades\Crypt',
		'DB'        => 'Illuminate\Support\Facades\DB',
		'Eloquent'  => 'Illuminate\Database\Eloquent\Model',
		'Event'     => 'Illuminate\Support\Facades\Event',
		'File'      => 'Illuminate\Support\Facades\File',
		'Hash'      => 'Illuminate\Support\Facades\Hash',
		'Input'     => 'Illuminate\Support\Facades\Input',
		'Inspiring' => 'Illuminate\Foundation\Inspiring',
		'Lang'      => 'Illuminate\Support\Facades\Lang',
		'Log'       => 'Illuminate\Support\Facades\Log',
		'Mail'      => 'Illuminate\Support\Facades\Mail',
		'Password'  => 'Illuminate\Support\Facades\Password',
		'Queue'     => 'Illuminate\Support\Facades\Queue',
		'Redirect'  => 'Illuminate\Support\Facades\Redirect',
		'Redis'     => 'Illuminate\Support\Facades\Redis',
		'Request'   => 'Illuminate\Support\Facades\Request',
		'Response'  => 'Illuminate\Support\Facades\Response',
		'Route'     => 'Illuminate\Support\Facades\Route',
		'Schema'    => 'Illuminate\Support\Facades\Schema',
		'Session'   => 'Illuminate\Support\Facades\Session',
		'Storage'   => 'Illuminate\Support\Facades\Storage',
		'URL'       => 'Illuminate\Support\Facades\URL',
		'Validator' => 'Illuminate\Support\Facades\Validator',
		'View'      => 'Illuminate\Support\Facades\View',
		'Str'       => 'Illuminate\Support\Str',
		// Added Package Aliases
		'Form' 		=> 'Collective\Html\FormFacade',
		'HTML' 		=> 'Collective\Html\HtmlFacade',
		'Sentry'    => 'Cartalyst\Sentry\Facades\Laravel\Sentry',
		'Breadcrumbs' => 'DaveJamesMiller\Breadcrumbs\Facade',
		'Datatable' => 'Chumper\Datatable\Facades\DatatableFacade',
		'Security' => 'GrahamCampbell\Security\Facades\Security',
		'Former' => 'Former\Facades\Former',
		'Omnipay' => 'Ignited\LaravelOmnipay\Facades\OmnipayFacade',
		'Image' => 'Intervention\Image\Facades\Image',
		'ZendPdf' => 'ZendPdf\PdfDocument',

		// Libraries Aliases
		'Captcha' => 'L5\A\libraries\Captcha',
		'Currency' => 'L5\A\libraries\Currency',
		'Gmap' => 'L5\A\libraries\Gmap',
		'InspectionVariables' => 'L5\A\libraries\InspectionVariables',
		'Language' => 'L5\A\libraries\Language',
		'PaginatorPresenter' => 'L5\A\libraries\PaginatorPresenter',
		'Currency' => 'L5\A\libraries\Currency',
		'Template' => 'L5\A\libraries\Template',
		'Uploader' => 'L5\A\libraries\Uploader',
        'Socialite' => 'Laravel\Socialite\Facades\Socialite',
        'Excel' => 'Maatwebsite\Excel\Facades\Excel',
        'Autologin' => 'Watson\Autologin\Facades\Autologin',
        'GeoIP' => 'Torann\GeoIP\GeoIPFacade',
        'Twilio' => 'Aloha\Twilio\Support\Laravel\Facade',
        "Shortener" => "LeadThread\Shortener\Facades\Shortener",

	],

and this in the bootstrap/app.php


/*
|--------------------------------------------------------------------------
| Bind Important Interfaces
|--------------------------------------------------------------------------
|
| Next, we need to bind some important interfaces into the container so
| we will be able to resolve them when needed. The kernels serve the
| incoming requests to this application from both the web and CLI.
|
*/

$app->singleton(
	'Illuminate\Contracts\Http\Kernel',
	'L5\Http\Kernel'
);

$app->singleton(
	'Illuminate\Contracts\Console\Kernel',
	'L5\Console\Kernel'
);

$app->singleton(
	'Illuminate\Contracts\Debug\ExceptionHandler',
	'L5\Exceptions\Handler'
);

and this is the composer.json

{
	"name": "laravel/laravel",
	"description": "The Laravel Framework.",
	"keywords": ["framework", "laravel"],
	"license": "MIT",
	"type": "project",
	"repositories": [
        {
            "type": "vcs",
            "url": "https://github.com/bart/ardent.git"
        }
    ],
	"require": {
		"laravel/framework": "5.0.*",
		"cartalyst/sentry": "dev-feature/laravel-5",
		"laravelcollective/html": "~5.0",
		"nesbot/Carbon": "*",
		"davejamesmiller/laravel-breadcrumbs": "^3.0",
		"doctrine/dbal": "~2.3",
		"barryvdh/laravel-debugbar": "[email protected]",
		"logicalgrape/paypal-ipn-laravel": "dev-master",
        "tecnick.com/tcpdf": "6.0.090",
        "anahkiasen/former": "*",
        "intervention/image": "2.*",
        "intervention/imagecache": "2.*",
        "baum/baum": "~1.0",
		"omnipay/paypal": "~2.0",
		"phpoffice/phpword": "dev-master",
		"maatwebsite/excel": "~2.1.0",
		"laravelbook/ardent": "dev-l5 as 2.4.2",
		"chumper/datatable": "dev-develop",
		"graham-campbell/security": "^3.0",
		"ignited/laravel-omnipay": "2.*",
		"laravel/socialite": "2.0.*",
		"watson/autologin": "^0.4.3",
		"torann/geoip": "0.2.*@dev",
		"zendframework/zendpdf": "2.0.*@dev",
		"aloha/twilio": "^3.0",
		"leadthread/laravel-shortener": "^6.0"
	},
	"require-dev": {
		"phpunit/phpunit": "~4.0",
		"phpspec/phpspec": "~2.1"
	},
	"autoload": {
		"classmap": [
			"database",
			"app/Console/Commands",
			"app/Http/Controllers",
			"app/Models",
			"app/A"
		],
		"psr-4": {
			"aqc_L5\": "app/"
		},
		 "files": [
            "app/helpers.php"
        ]
	},
	"autoload-dev": {
		"classmap": [
			"tests/TestCase.php"
		]
	},
	"scripts": {
		"post-install-cmd": [
			"php artisan clear-compiled",
			"php artisan optimize"
		],
		"post-update-cmd": [
			"php artisan clear-compiled",
			"php artisan optimize"
		],
		"post-create-project-cmd": [
			"php -r \"copy('.env.example', '.env');\"",
			"php artisan key:generate"
		]
	},
	"config": {
		"preferred-install": "dist"
	}
}

I have impression they have created a L5 namespace to add up Laravel 5 files.

Question 1: what can I make to move the app out of the public_html/L5 folder withou breaking everything ?

Question 2: Is there anyway I can update all of this to laravel 8 or is it going to break everything ?

Activity icon

Replied to 1/2 ErrorException In 44812f12bcefe0281da2f29a7f94d872 Line 40: Trying To Get Property Of Non-object

I solved this problem by reinstall the the app in a folder named L5 as I suspected and it worked back as it should. so it was the real problem... there was probably something in the path configuration poiting to a subfolder /L5 which make that mess up my query.. not sure why...

Nov
01
4 weeks ago
Activity icon

Replied to 1/2 ErrorException In 44812f12bcefe0281da2f29a7f94d872 Line 40: Trying To Get Property Of Non-object

country is null (not sure why) , but country_id is not. so the question is how to get country name from country_id ?

Activity icon

Replied to 1/2 ErrorException In 44812f12bcefe0281da2f29a7f94d872 Line 40: Trying To Get Property Of Non-object

But this don't work: "When Laravel sees $company->country->name, it automatically knows to use country_id to query country table and get the name." since i have country_id filled and still not showing the country name...

Activity icon

Replied to 1/2 ErrorException In 44812f12bcefe0281da2f29a7f94d872 Line 40: Trying To Get Property Of Non-object

Yes I see it here but I also see this : "country_id":102 and this is from country_id that i should get the name of the country. So how to make this ?

Activity icon

Replied to 1/2 ErrorException In 44812f12bcefe0281da2f29a7f94d872 Line 40: Trying To Get Property Of Non-object

"{"id":179,"name":"Global","address":"Jan Bat","city":"Canggu","zipcode":"80361","country_id":102,"telephone":"+692","fax":"","email":"[email protected]","website":"","sales_turnover":1,"purchase_turnover":1,"linkedin":"","industry_id":0,"bank_name":"","bank_address":"","bank_no":"","bank_beneficiary":"","bank_swift":"","tags":"","priority":"Low","status":"Prospect","logo":null,"profile":null,"facebook":"","twitter":"","state":"","user_id":0,"created_at":"2017-02-28 10:58:31","updated_at":"2017-08-30 14:30:22","registered":1,"remote_addr":"2.58.193.82","http_user_agent":"Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36","short_tag":"GLO0001","rank_id":null,"annual_turnover":"","staffs_count":"","mobile_phone":"","company_personal_note":"","interested_in":"["service_name"]","account_manager_id":115,"provenance":"registered","peoples":[{"id":2,"company_id":179,"title":"","first_name":"Ec","last_name":"Br","position":"","email1":"[email protected]","email2":null,"personal_email":null,"skype":null,"mobile":"","phone":null,"fax":"","linkedin":"","dob":null,"created_at":"2017-02-28 10:58:31","updated_at":"2017-02-28 10:58:31","landline":"","tags":"","facebook":"","twitter":"","personal_note":null}],"country":null,"industries":[]}"

Activity icon

Replied to 1/2 ErrorException In 44812f12bcefe0281da2f29a7f94d872 Line 40: Trying To Get Property Of Non-object

[2020-11-01 14:05:14] local.ERROR: Symfony\Component\Debug\Exception\FatalErrorException: Uncaught TypeError: Argument 1 passed to L5\Exceptions\Handler::report() must be an instance of Exception, instance of Error given, called in /longpath/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php on line 73 and defined in /longpath/app/Exceptions/Handler.php:25 Stack trace: #0 /longpath/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(73): L5\Exceptions\Handler->report(Object(Error)) #1 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions->handleException(Object(Error)) #2 {main} thrown in /longpath/app/Exceptions/Handler.php:25 Stack trace: #0 {main} [2020-11-01 14:05:37] local.ERROR: Symfony\Component\Debug\Exception\FatalErrorException: Uncaught TypeError: Argument 1 passed to L5\Exceptions\Handler::report() must be an instance of Exception, instance of Error given, called in /longpath/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php on line 73 and defined in /longpath/app/Exceptions/Handler.php:25 Stack trace: #0 /longpath/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(73): L5\Exceptions\Handler->report(Object(Error)) #1 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions->handleException(Object(Error)) #2 {main} thrown in /longpath/app/Exceptions/Handler.php:25 Stack trace: #0 {main} [2020-11-01 14:05:55] local.ERROR: Symfony\Component\Debug\Exception\FatalErrorException: Uncaught TypeError: Argument 1 passed to L5\Exceptions\Handler::report() must be an instance of Exception, instance of Error given, called in /longpath/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php on line 73 and defined in /longpath/app/Exceptions/Handler.php:25 Stack trace: #0 /longpath/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(73): L5\Exceptions\Handler->report(Object(Error)) #1 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions->handleException(Object(Error)) #2 {main} thrown in /longpath/app/Exceptions/Handler.php:25 Stack trace: #0 {main}

Activity icon

Replied to 1/2 ErrorException In 44812f12bcefe0281da2f29a7f94d872 Line 40: Trying To Get Property Of Non-object

I get this error when I add up the toJson() in the code:

FatalErrorException in Handler.php line 25: Uncaught TypeError: Argument 1 passed to L5\Exceptions\Handler::report() must be an instance of Exception, instance of Error given, called in /longpath/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php on line 73 and defined in /home4/inspedd3/app/inspectionplatform.com/production/app/Exceptions/Handler.php:25 Stack trace: #0 /longpath/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(73): L5\Exceptions\Handler->report(Object(Error)) #1 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions->handleException(Object(Error)) #2 {main} thrown

Activity icon

Replied to 1/2 ErrorException In 44812f12bcefe0281da2f29a7f94d872 Line 40: Trying To Get Property Of Non-object

Impossible to expand all. I got this:


array:814 [▶]

where the first 83 records looks like this:


  0 => Company {#2287 ▼
    +table: "companies"
    +autoHydrateEntityFromInput: true
    +forceEntityHydrationFromInput: true
    #guarded: []
    #fillable: array:36 [ …36]
    #validator: null
    +validationErrors: MessageBag {#2288 …2}
    +throwOnValidation: false
    +autoPurgeRedundantAttributes: false
    #purgeFilters: array:1 [ …1]
    #purgeFiltersInitialized: false
    +autoHashPasswordAttributes: false
    #connection: null
    #primaryKey: "id"
    #perPage: 15
    +incrementing: true
    +timestamps: true
    #attributes: array:42 [ …42]
    #original: array:42 [ …42]
    #relations: array:3 [ …3]
    #hidden: []
    #visible: []
    #appends: []
    #dates: []
    #casts: []
    #touches: []
    #observables: []
    #with: []
    #morphClass: null
    +exists: true

form record 84 it turns like this and i can not expand it:


84 => Company {#2539 …30}

not sure if it can helps but when i look inside the table Companies in phpmyadmin, I see the highest id is 994....

Activity icon

Replied to 1/2 ErrorException In 44812f12bcefe0281da2f29a7f94d872 Line 40: Trying To Get Property Of Non-object

As said, I have checked all one by one each entry in PHPMYADMIN and in Excel and all Companies got a country_id . I also checked that max country_id value is <= max id of countries.

Also imagine that if one record would miss one country_id then when I place your if statement code snipeet I should get a few empty cell in my table for the only record which miss the country_id, but here all my entry are empty and I don't believe my companies entry all miss country_id..

so logically thinking I suppose the problem is not that one company miss a country_id...

Do you know which file(s) handle/ensure this: "When Laravel sees $company->country->name, it automatically knows to use country_id to query country table and get the name." ?

Activity icon

Replied to 1/2 ErrorException In 44812f12bcefe0281da2f29a7f94d872 Line 40: Trying To Get Property Of Non-object

table Companies got column country_id to associate a country to a company. It doesn't record the country name directly inside the Companies table.

In my understanding, we are calling wrongly what we want.

We want to call country_id, get the value of it , then query table Countries and get the name based on country_id value.

companies table (name, country_id)

countries table (id,name)

PS: my level in php and laravel is beginner/newby

Activity icon

Replied to 1/2 ErrorException In 44812f12bcefe0281da2f29a7f94d872 Line 40: Trying To Get Property Of Non-object

Because as i said above I have exported the whole table Companies in Excel and check that each company in this Excel table got a country_id associated.. I sucess to see those country_id in the dd ($company). The problem come from getting the associated country name from a pivot (table countries (id/name) I suppose.. The question is what makes that $company->country->name doesn't give the value name... ?

Activity icon

Replied to 1/2 ErrorException In 44812f12bcefe0281da2f29a7f94d872 Line 40: Trying To Get Property Of Non-object

this time it doesn't shift the data but the country column is empty

Activity icon

Replied to 1/2 ErrorException In 44812f12bcefe0281da2f29a7f94d872 Line 40: Trying To Get Property Of Non-object

It display the page but not the country name. (column are shifted: company city go to company country column) I also find out that the controller People doesn't get " use Country" at the beginning of the file contrary to Company controller. I added it in People controler but not better.

when I try to {{dd($company) ?}} I get this : #relations: array:3 [▼ "peoples" => Collection {#5559 ▶} "country" => null "industries" => Collection {#5560 ▶}

Also, initially the developper placed the whole App folder in public_html folder of the server. After reading a few of your other posts yesterday I saw you mentionned to another op to use symbolic link and to update some files, which I did.

Activity icon

Replied to 1/2 ErrorException In 44812f12bcefe0281da2f29a7f94d872 Line 40: Trying To Get Property Of Non-object

I get this :

FatalErrorException in Handler.php line 25:
Uncaught TypeError: Argument 1 passed to L5\Exceptions\Handler::report() must be an instance of Exception, instance of Error given, called in /long_path/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php on line 73 and defined in /long_path/app/Exceptions/Handler.php:25
Stack trace:
#0 /long_path/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(73): L5\Exceptions\Handler->report(Object(Error))
#1 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions->handleException(Object(Error))
#2 {main}
thrown

please note L5 in the first path. This app started its development in Laravel 4 and was later pushed to Laravel5 by one of our developper, may be there is a hit somewhere there (I am not sure)...

I see in the config/app.php those lines in the provider :


		 * Application Service Providers...
		 */
		'L5\Providers\AppServiceProvider',
		'L5\Providers\BusServiceProvider',
		'L5\Providers\ConfigServiceProvider',
		'L5\Providers\EventServiceProvider',
		'L5\Providers\RouteServiceProvider',


		'L5\Providers\MacroServiceProvider',

I think initially before taking over the previous developper, the developper stored the application on a server within a subfolder L5. Now we have moved this application on another server which is not anymore in this subfolder L5.

Activity icon

Replied to 1/2 ErrorException In 44812f12bcefe0281da2f29a7f94d872 Line 40: Trying To Get Property Of Non-object

if i remove this line <td><?php echo ($company->country)->name; ?></td> from 2bb7451339b32b54531fced42e9ed396 file then the page display but obviously without the country name

if i replace the line with the optional one you mention in the 2bb7 file then the page display with written {{ optional($company->country)->name }} instead of country

If i remove this line <td><?php echo ($company->country)->name; ?></td> from index_all.blade.php then the page display but without the country value

if in the index_all.blade.php I replace the line with the optional you propose then I get the new error FatalErrorException in Handler.php line 25

If i replace the line by this one: <td>{{ $company->country_id }} then page display and fill with country id but not name obviously

in database we have a table countries with column: id / name so each country got an id and this is this id which is recorded in the table companies

I have exported the table companies in Excel and I didn't see any companies who don't get a value in countries. I have also checked in the table countries that each id got a name.

Oct
31
4 weeks ago
Activity icon

Replied to 1/2 ErrorException In 44812f12bcefe0281da2f29a7f94d872 Line 40: Trying To Get Property Of Non-object

i have replaced the code but now I still get this error:

FatalErrorException in Handler.php line 25:
Uncaught TypeError: Argument 1 passed to path\Exceptions\Handler::report() must be an instance of Exception, instance of Error given, called in /path/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php on line 73 and defined in path/app/Exceptions/Handler.php:25
Stack trace:
#0 /path/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(73): path\Exceptions\Handler->report(Object(Error))
#1 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions->handleException(Object(Error))
#2 {main}
thrown

but i confirm the issue comes from the fact that variable $country is null. I have removed the line and it display the page properly (but I loose the country name value so I don't get the data I need.)

Activity icon

Replied to 1/2 ErrorException In 44812f12bcefe0281da2f29a7f94d872 Line 40: Trying To Get Property Of Non-object

<?php $__env->startSection('title'); ?>
	Clients Management
<?php $__env->stopSection(); ?>
<?php $__env->startSection('header'); ?>
<link href="<?php echo asset('assets/plugins/forms/togglebutton/toggle-buttons.css'); ?>" type="text/css" rel="stylesheet" />
<?php $__env->stopSection(); ?>
<?php $__env->startSection('content'); ?>
<?php echo Company::filterForm(); ?></div>
	<div class="col-lg-12">
		<div class="page-header">
			<h3>All People
			<a href="<?php echo URL::route('clients.companies.peoples.create'); ?>" class="pull-right icon tip" title="Associate a People"><span class="icon16 iconic-icon-plus"></span></a>
			</h3>
		</div>
		<div class="row">
			<div class="col-lg-12">
				<table cellpadding="0" cellspacing="0" border="0" class="dynamicTable display table dataTable">
					<thead>
						<tr>
							<th>Full name</th>
							<th>e-mail</th>
							<th>Phone Number</th>
							<th>Company</th>
							<th>Country</th>
							<th>City</th>
							<th>Industry</th>
							<th>Products</th>
							<th>Status</th>
							<th></th>
						</tr>
					</thead>
					<tbody>
					<?php foreach($companies as $company): ?>
						<?php foreach($company->peoples as $people): ?>
							<tr>
								<td><a href="<?php echo URL::route('clients.companies.peoples.show', array($company->id, $people->id)); ?>"><?php echo $people->fullName; ?></a></td>
								<td><a href="mailto:<?php echo $people->email1; ?>"><?php echo $people->email1; ?></a></td>
								<td><a href="skype:<?php echo $people->landline; ?>"><?php echo $people->landline; ?></a></td>
								<td><a href="<?php echo URL::route('clients.companies.show', $company->id); ?>"><?php echo $company->name; ?></a></td>
								<td><?php echo $company->country->name; ?></td>
								<td><?php echo $company->city; ?></td>
								<td>
									<?php foreach($company->industries as $industry): ?>
	                                    <?php echo $industry->title; ?>

	                                <?php endforeach; ?>
								</td>
								<td><?php echo $company->tags; ?></td>
								<td>
									<div class="left marginR10">
										<div class="iToggle-button"><input type="checkbox" class="nostyle"
											<?php if($people->User): ?>
												<?php if( !$people->User->isActivated() ): ?>
													 onchange="window.location.replace('/admin/users/<?php echo encrypt($people->User->id); ?>/activate');" 
												<?php else: ?>
													checked="checked" 
													<?php if(!$people->User->isCurrent()): ?>
													onchange="window.location.replace('/admin/users/<?php echo encrypt($people->User->id); ?>/deactivate');" 
													<?php else: ?>
														disabled
													<?php endif; ?>
												<?php endif; ?>
											<?php else: ?>
												disabled 
											<?php endif; ?>
											>
										</div>
									</div>
								</td>
								<td>
									<a title="Update" class="tip" href="<?php echo URL::route('clients.companies.peoples.update', array($company->id, $people->id)); ?>"><span class="icon16 typ-icon-pencil"></span></a> 
									<?php if(Sentry::getUser()->hasAccess('contacts')): ?>
										<a title="Delete" href="<?php echo URL::route('clients.companies.peoples.delete', array($company->id, $people->id)); ?>"><span class="icon16 typ-icon-cross"></span></a>
									<?php endif; ?>
								</td>			
							</tr>
						<?php endforeach; ?>
					<?php endforeach; ?>
					</tbody>
				</table>
			</div>
		</div>
	</div>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('footer_script'); ?>
<script type="text/javascript" src="<?php echo asset('assets/plugins/forms/togglebutton/jquery.toggle.buttons.js'); ?>"></script>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('footer'); ?>
<script type="text/javascript">
    $('.iToggle-button').toggleButtons({
        width: 70,
        label: {
            enabled: "<span class='icon16 icomoon-icon-checkmark white'></span>",
            disabled: "<span class='icon16 icomoon-icon-close white marginL10'></span>"
        }
    });

    function toggleButtons () {
    	 $('.iToggle-button').toggleButtons({
	        width: 70,
	        label: {
	            enabled: "<span class='icon16 icomoon-icon-checkmark white'></span>",
	            disabled: "<span class='icon16 icomoon-icon-close white marginL10'></span>"
	        }
	    });
    }
</script>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('backend/base/layouts/default', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>
Activity icon

Replied to 1/2 ErrorException In 44812f12bcefe0281da2f29a7f94d872 Line 40: Trying To Get Property Of Non-object

and this is the beginning of controller :


namespace Controllers\Admin\Clients;

use BackendController;
use People;
use Redirect;
use Company;
use Config;
use Input;
use Activity;
use Todo;
use Sentry;
use Breadcrumbs;
use Email;
use EMailTemplate;
use Token;
use Lang;
use URL;
use Response;
use Validator;
use Session;

class PeoplesController extends BackendController {

	public function __construct(){
		parent::__construct();

		if(Sentry::check() && !(Sentry::getUser()->hasAccess('contacts.peoples') || Sentry::getUser()->hasAccess('contacts'))){
			throw new \PermissionDeniedException();
		}
	}

	/**
	 * Display a listing of the resource.
	 *
	 * @return Response
	 */
	public function getIndex($id = null)
	{
		if($id == null)
		{
			$companies = Company::hasPermission(array('c', 'r', 'u', 'd'), Sentry::getUser()->id, false)->with('peoples', 'country', 'industries')->filter()->get();

			Breadcrumbs::register('clients.peoples', function($b){
				$b->parent('cp');

				$b->push('Clients');
				$b->push('Companies', route('clients.companies'));
				$b->push('Peoples');
			});
			self::$breadcrumbs = Breadcrumbs::render('clients.peoples');

			return self::view('clients/companies/peoples/index_all')
					->with('companies', $companies);
		}
		else
		{
			$company = Company::hasPermission(array('c', 'r', 'u', 'd'), Sentry::getUser()->id, false)->with('peoples', 'country', 'industries')->filter()->find($id);

			Breadcrumbs::register('clients.peoples', function($b, $company){
				$b->parent('cp'); // @ we can actuall inherit this class from CompaniesController to make it easier and more structural.

				$b->push('Clients');
				$b->push('Companies', route('clients.companies'));
				$b->push($company->name, route('clients.companies.show', $company->id));
				$b->push('Peoples');
			});
			self::$breadcrumbs = Breadcrumbs::render('clients.peoples', $company);

			return self::view('clients/companies/peoples/index')
					->with('company', $company);
		}
	}
Activity icon

Replied to 1/2 ErrorException In 44812f12bcefe0281da2f29a7f94d872 Line 40: Trying To Get Property Of Non-object

This is what is inside the view index_all.blade :

@extends('backend/base/layouts/default')

@section('title')
	Clients Management
@stop
@section('header')
<link href="{{ asset('assets/plugins/forms/togglebutton/toggle-buttons.css') }}" type="text/css" rel="stylesheet" />
@stop
@section('content')
{{ Company::filterForm() }}</div>
	<div class="col-lg-12">
		<div class="page-header">
			<h3>All People
			<a href="{{ URL::route('clients.companies.peoples.create') }}" class="pull-right icon tip" title="Associate a People"><span class="icon16 iconic-icon-plus"></span></a>
			</h3>
		</div>
		<div class="row">
			<div class="col-lg-12">
				<table cellpadding="0" cellspacing="0" border="0" class="dynamicTable display table dataTable">
					<thead>
						<tr>
							<th>Full name</th>
							<th>e-mail</th>
							<th>Phone Number</th>
							<th>Company</th>
							<th>Country</th>
							<th>City</th>
							<th>Industry</th>
							<th>Products</th>
							<th>Status</th>
							<th></th>
						</tr>
					</thead>
					<tbody>
					@foreach($companies as $company)
						@foreach($company->peoples as $people)
							<tr>
								<td><a href="{{ URL::route('clients.companies.peoples.show', array($company->id, $people->id)) }}">{{ $people->fullName }}</a></td>
								<td><a href="mailto:{{ $people->email1 }}">{{ $people->email1 }}</a></td>
								<td><a href="skype:{{ $people->landline }}">{{ $people->landline }}</a></td>
								<td><a href="{{ URL::route('clients.companies.show', $company->id) }}">{{ $company->name }}</a></td>
								<td>{{ $company->country->name }}</td>
								<td>{{ $company->city }}</td>
								<td>
									@foreach($company->industries as $industry)
	                                    {{ $industry->title }}
	                                @endforeach
								</td>
								<td>{{ $company->tags }}</td>
								<td>
									<div class="left marginR10">
										<div class="iToggle-button"><input type="checkbox" class="nostyle"
											@if($people->User)
												@if( !$people->User->isActivated() )
													 onchange="window.location.replace('/admin/users/{{encrypt($people->User->id)}}/activate');" 
												@else
													checked="checked" 
													@if(!$people->User->isCurrent())
													onchange="window.location.replace('/admin/users/{{encrypt($people->User->id)}}/deactivate');" 
													@else
														disabled
													@endif
												@endif
											@else
												disabled 
											@endif
											>
										</div>
									</div>
								</td>
								<td>
									<a title="Update" class="tip" href="{{ URL::route('clients.companies.peoples.update', array($company->id, $people->id)) }}"><span class="icon16 typ-icon-pencil"></span></a> 
									@if(Sentry::getUser()->hasAccess('contacts'))
										<a title="Delete" href="{{ URL::route('clients.companies.peoples.delete', array($company->id, $people->id)) }}"><span class="icon16 typ-icon-cross"></span></a>
									@endif
								</td>			
							</tr>
						@endforeach
					@endforeach
					</tbody>
				</table>
			</div>
		</div>
	</div>
@stop

@section('footer_script')
<script type="text/javascript" src="{{ asset('assets/plugins/forms/togglebutton/jquery.toggle.buttons.js') }}"></script>
@stop

@section('footer')
<script type="text/javascript">
    $('.iToggle-button').toggleButtons({
        width: 70,
        label: {
            enabled: "<span class='icon16 icomoon-icon-checkmark white'></span>",
            disabled: "<span class='icon16 icomoon-icon-close white marginL10'></span>"
        }
    });

    function toggleButtons () {
    	 $('.iToggle-button').toggleButtons({
	        width: 70,
	        label: {
	            enabled: "<span class='icon16 icomoon-icon-checkmark white'></span>",
	            disabled: "<span class='icon16 icomoon-icon-close white marginL10'></span>"
	        }
	    });
    }
</script>
@stop

AND THIS IS LINE 40 : {{ $people->landline }}

Activity icon

Started a new Conversation 1/2 ErrorException In 44812f12bcefe0281da2f29a7f94d872 Line 40: Trying To Get Property Of Non-object

I got this error when trying to access one view and I don't understand the error.

2/2 Whoops, looks like something went wrong. ErrorException in /path-to-app/storage/framework/views/44812f12bcefe0281da2f29a7f94d872 line 40: Trying to get property of non-object (View: /path-to-app/resources/views/backend/base/clients/companies/peoples/index_all.blade.php)

1/2 ErrorException in 44812f12bcefe0281da2f29a7f94d872 line 40: Trying to get property of non-object