Laravel 5.7 checking code in tinker, but i have a problem while getting values from model class? [duplicate] - laravel-5.7

This question already has answers here:
Laravel parse error: syntax error, unexpected T_CLASS, expecting T_STRING or T_VARIABLE
(5 answers)
Closed 4 years ago.
my question is totaly different from that question, in that question they are telling about php versions and all, that question didn't solved my issue, thats why I haved asked my own question. #Álvaro González
I have created 4 models with this command
php artisan make:model class
php artisan make:model student
php artisan make:model subject
php artisan make:model user
I have created migrations and everything, but the problem is when I test my models in php artisan tinker with this command App\student::all(); then subject user and student models are working and shows me data but App\class::all(); is not working and showing me this error
PHP Parse error, Unexpected T_CLASS, Expecting T_STRING
I have also migration for class and also data is present in class table in database, but I don't know why it's not working, Any help would be appreciated Thanks

This model is invalid:
class class extends Model
{
//
}

Related

GlideApp symbol not found in Android Studio 4.1

I have been using Glide 4.11.0 and Realm 6.0.2 for some time now, and recently upgraded Android Studio 4.0.x to 4.1. All has been going fine. Today I ran the lint checker, and started doing some "clean up", nothing out of the ordinary (it would seem). One of the things I did a lot of was to replace switch statements that were testing against R.id. with if-else statements per the lint warning about what's gonna happen in Gradle 5.0.
When I did this, I did use a number of int variables I named 'id' that were to replace the value to compare - i.e. instead of a switch statement that would be:
switch (menuOpt.getId()) {
case R.id.xxx:
...
}
I would do:
int id = menuOpt.getId();
if ( id == R.id.XXX) {
} else if....
per the new guidelines.
Suddenly, on a full build AS complains that it no longer recognizes GlideApp, and I am also getting a very weird message about Realm not being able to process correctly:
C:\BLD\AndroidStudioProjects\InTouch\app\src\main\java\com\reddragon\intouch\ui\MediaPlayerActivity.java:61: error: cannot find symbol
import com.reddragon.intouch.utils.GlideApp;
^
symbol: class GlideApp
location: package com.reddragon.intouch.utils
C:\BLD\AndroidStudioProjects\InTouch\app\src\main\java\com\reddragon\intouch\ui\MediaDialogActivity.java:92: error: cannot find symbol
import com.reddragon.intouch.utils.GlideApp;
^
symbol: class GlideApp
location: package com.reddragon.intouch.utils
C:\BLD\AndroidStudioProjects\InTouch\app\src\main\java\com\reddragon\intouch\ui\MediaListActivity.java:48: error: cannot find symbol
import com.reddragon.intouch.utils.GlideApp;
^
symbol: class GlideApp
location: package com.reddragon.intouch.utils
Note: Version 10.0.0 of Realm is now available: https://static.realm.io/downloads/java/latest
Note: Processing class Album
error: Class "Album" contains illegal final field "id".
Note: [1] Wrote GeneratedAppGlideModule with: []
Class "Album" contains illegal final field "id".
4 errors
I have had the field 'id' in my Album class for about 2 years with no issues!
No manner of rebuild, invalidating cache and restarting, syncing gradle files or "reload all from disk" seems to help.
Actually, if I invalidate and restart, I don't get the red squiggle in the offending classes that are referencing GlideApp, but as soon as I start to run the app and it goes through a build process it errors out.
I Googled a bit and found one post where there seemed to be some conflict between Realm and Glide (RequestOptions), but the strange thing to me is why would this suddenly start occurring?
I have validated that the GlideAppjava class is in fact getting built - I am using the debug build variant, and I can see in the file system GlideApp.java that is in the ap_generated_sources/debug directory in the proper package where I have my class that extends AppGlideModule with the #GlideModule annotation.
So GlideApp is getting generated. It just isn't getting recognized.
One of the other new things is that I've recently created a Dynamic Feature module. This module does depend on a class that is in the base module (where GlideApp is referenced). Not sure if this is relevant (I had many, many successful builds before I started doing lint clean-up).
So frustrating! Any help appreciated.
It turns out that the answer was staring right at me, although somewhat hidden: part of the lint check that I did was accept some suggestions about making variables 'final' - including those that are used in Realm classes to define Realm objects. Realm doesn't like that - above build error output includes as a last line the statement 'Class "Album" contains illegal final field "id".'
"Album" extends RealmObject, and the "auto accept" of the lint's suggestion to make some of the fields final was the culprit.
I think this issue with Realm caused a ripple effect somehow with the other annotation processing - when I went back to all the RealmObject classes and removed the "final" declaration, build now completes smoothly.

Entity of type 'App\Entity\Slider' for IDs id(45) was not found

Hello everybody I need some help for a exception who is appeared on my project (symfony mvc)
The console return a http 500 when I have wanted to add a slider in a actuality post.
Slider and Actuality are two differents entities.
I have tried to understand the problem but i don't found. :/in the ActualityController
The error

Phpunit cannot find test, No test executed(Laravel)

I am using phpunit in laravel 5.5.
When I run test using
vendor/bin/phpunit .
it shows the error
no tests excucted.
In phpunit.xml file I set suffix of test directories.
But I don't know what is the problem.
Can u share more details of your work ? If you are new in laravel can follow: https://www.youtube.com/watch?v=3uYXAcit_Sg&list=PL3VM-unCzF8iPERY07XRw0JXG_c50CapR . there is step by step guideline
I solved the problem.
The solution is here:
https://phpunit.readthedocs.io/en/7.1/installation.html#windows
I write this in case someone from Laravel 8 come and found the similar error.
Today I learn about TDD and follow a tutorial in Youtube. in one phase I create a test function with similar name as the tutorial explained,
.
But then come the error "No Test Executed!" appear.
Similar to this question.
I already check and make sure that the file name is suffix-ed with 'Test' word.
.
I don't know whats wrong. But then After digging around, it turns out that in Laravel 8 (or maybe prior version also), the test FUNCTION NAME have to be prefixed with Test.
e.g.
public function check_family() => won't work
public function test_check_family() => work

Compiler Error Message: CS0103: The name 'Database' does not exist in the current context [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Razor-based view doesn't see referenced assemblies
I am a Newbie in ASP.net
I am trying to connect to a database and I keep getting this error
**Compilation Error
Description: An error occurred during the compilation of a resource
required to service this request. Please review the following specific
error details and modify your source code appropriately.
Compiler Error Message: CS0103: The name 'Database' does not exist in
the current context
Source Error:
Line 1: #{
Line 2: var db = Database.Open("demo"); '
Line 3:
Line 4:
Source File: c:\Users\Ayoya\Documents\My Web Sites\demo\Page.cshtml
Line: 2
**
Can anyone tell me whats wrong?
Thank you
The compiler's already telling you what's wrong - it doesn't know what you mean by Database. Is that mean to be a property of the page, or is it the name of a type with a static Open method? It's not clear from the code itself, and obviously the compiler can't find the name either.
Work out what name you mean, then work out why the compiler can't see it, then fix that. If you need more help on any of these steps, you'll need to provide more information.
(As an aside, I completely agree with dbaseman: putting database calls in your view is a bad idea.)
If you're opening a database in your Razor view, that is completely the wrong approach. Your logic should go in the Controller, not the View. Consider creating a "view model" class that contains all the data needed for your view, and populate that class from the Controller.
Probably the reason this piece of code isn't working is that you will need to specify the full namespace of Database. I'm not sure what that class is, though; if it's in a separate DLL, you'll have more problems. Again, though, you should circumvent this problem by putting your database logic in the controller.

Get types in assembly: ReflectionTypeLoad Exception [duplicate]

This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
How to reproducably cause / provoke a ReflectionTypeLoadException?
I wanted to get all types in a loaded assembly.code snippet is as follows
Assembly assemblyObj = Assembly.LoadFile(#"D:\abc\abc.dll");
IList<Type> types = assemblyObj.GetTypes();
when i run im getting ReflectionTypeLoadException.What is the mistake in the code.
As you can see in my answer to the question linked as duplicate, the problem most likely is, that "abc.dll" contains a class that derives from a class in a referenced assembly and that referenced assembly doesn't contain that base class, because it has the wrong version.

Resources