rajcoder

Experience

9,490

0 Best Reply Awards

  • Member Since 6 Months Ago
  • 91 Lessons Completed
  • 0 Favorites

12th July, 2018

rajcoder left a reply on Dusk Test Not Working As Expected • 1 week ago

@shez1983 Thanks for mentioning the tearDown() method. But it does not seem right to logout a user as there may be cases where I am testing that on wrong credentials assertPathIs('/login') and then the tearDown() method tries to find logout link eg. clickLink('logout') and since I am at the login page itself there might be an error.

So can you suggest me what code should I have in my tearDown() method to destroy the current session of the user ?

Or somehow each test method runs as if it is a separate test

11th July, 2018

rajcoder started a new conversation Dusk Test Not Working As Expected • 1 week ago

I am using dusk for testing and have encountered a problem.

I have a test functions in ExampleTest file.

In the test, I am creating a factory user and logging him through login form and asserting that user should see home. But this gives me error:

Actual path [/login] does not equal expected path [/home].

And in the screenshot I can see the login page with error:

These credentials do not match our records.

What is the problem ?

25th March, 2018

rajcoder started a new conversation 403 Forbidden Error When Visiting Website • 3 months ago

I am getting 403 Forbidden error when visiting website.

When I checked the server directory structure through SSH, I found that my public directory is empty.

The site was working before but after I did the following things its not working now

  1. Created linked folder public <---> storage/app/public
  2. Manually created link through SSH by running php artisan storage:link

Thats it and now my public folder is empty.

How do I get it back ? I tried to redeploy to older deployments but still public folder is empty.

23rd March, 2018

rajcoder left a reply on Class Not Found Error • 3 months ago

I found the solution.

I had simply forgotten to include the word php after <?

rajcoder started a new conversation Class Not Found Error • 3 months ago

Im using maatwebsite/excel package so according to its doc i created a class eg. PostsExport.php in app/Exports folder.

namespace Demo\Exports;

`use Demo\Post;

class PostsExport implements FromCollection { public function collection() { return Post::all(); } }`

And in my PostController i have the method

` use Demo\Exports\PostsExport; use Maatwebsite\Excel\Facades\Excel;

... ...

public function export() { return Excel::download(new PostsExport, 'posts.xlsx'); }`

But when i click download button the export method runs but gives error that Demo\Exports\PostsExport not found

2nd March, 2018

rajcoder left a reply on Many To Many Relationship: Method Latest Does Not Exists Error • 4 months ago

ok i changed it to $posts = $tag->posts()->where('user.name', 'ABC')->latest()->paginate(5);

still it gives method latest does not exists error.

without latest() it returns collection but it latest gives error

rajcoder started a new conversation Many To Many Relationship: Method Latest Does Not Exists Error • 4 months ago

Latest and Paginate method does not work on the collection.

$tag = Tag::where('name', 'php')->first(); $posts = $tag->posts->where('user.name', 'ABC')->latest()->paginate(5);

Here it gives error: Method latest does not exists.

How to solve this problem ?

8th January, 2018

rajcoder left a reply on How To Use Class Variables Across Methods Of A Class ? • 6 months ago

But update function does not have access to those variables in $request but i want to use them. Is there a way by which i can store the $request variable that i receive in store method and use it in update method ?

rajcoder started a new conversation How To Use Class Variables Across Methods Of A Class ? • 6 months ago

Lets say i have a controller with two methods. create() which stores a value in the class variable update() that makes use of the modified class variable

class DemoControlller extends Controller { public name;

public function create(Request $request)
    {
    $this->name = $request->name;
}

public function update(Request $request)
    {
    dd($this->name);
}

}

When create is called the value gets stored in name variable properly, But when update() is called i get null value.

How to use the name class variable across all methods ?

6th January, 2018

rajcoder started a new conversation Ajax Post Request In Laravel • 6 months ago

Im sending a ajax request from demo/create page to /ajaxdemo page with calls a controller method ajaxpost where im inserting data which i have sent.

But the data is not inserted and the current page simply reloads and displays token in the URL.

What can be the reason for this ?

31st December, 2017

rajcoder started a new conversation How To Use Where Clause On Data Which Is Eager Loaded ? • 6 months ago

This is my code

$users = User::with('admin')->where('role', 'super_admin') ->where(function ($query) use($keyword){ $query->where('id', 'LIKE', "%$keyword%") ->orWhere('email', 'LIKE', "%$keyword%") ->orWhere('name', 'LIKE', "%$keyword%")

                    ->orWhere($this->admin->status, 'LIKE', "%$keyword%");

        })->paginate($perPage);

This throws an error undefined property admin

Due to this line ->orWhere($this->admin->status, 'LIKE', "%$keyword%");

So how can i use admin's status column in filtering data ?

Edit Your Profile
Update

Want to change your profile photo? We pull from gravatar.com.