deepu07

Experience

8,180

0 Best Reply Awards

  • Member Since 3 Months Ago
  • 73 Lessons Completed
  • 0 Favorites

16th January, 2018

deepu07 started a new conversation PHP Fatal Error: Uncaught Error: Call To A Member Function Connection() On Null In C:\xampp7\htdocs\Lara\vendor\laravel\framework\src\Illuminate\Database\Eloquent\Model.php:1116 • 1 day ago

Hi all, I'm trying to test my article controller [ArticleController] with the help phpunit. I had a simple testcase and related files. But still I'm getting an error. Can anyone help me out.

#ArticleTest.php#

14th January, 2018

deepu07 left a reply on How To Paginate The Records In A View. Below Are My Controller Index Method And View File. By Doing That I'm Getting Only One Record. Can Anyone Helpme Out. How To Display Last Three Records In A View?? • 3 days ago

#Indexblade.php#


@section('content')
<!-- Example row of columns -->

<div class="container">
  
    @foreach ($posts as $post)

      @include('posts.post')

    @endforeach

</div>

@endsection

deepu07 started a new conversation How To Paginate The Records In A View. Below Are My Controller Index Method And View File. By Doing That I'm Getting Only One Record. Can Anyone Helpme Out. How To Display Last Three Records In A View?? • 3 days ago

#[email protected]#

{
    public function index()
    {
        $posts = post::paginate(3);
        
        return view('posts.index',compact('posts'));

    }```

#postblade.php#

```@extends('master')

@section('content')

<!-- Post Content Column -->
<div class="col-lg-8">

    <div class="col-lg-11">

          <!-- Title -->
          <h2>{{$post->title}}</h2>

       on {{ $post->created_at->toFormattedDateString() }}  by <a href="#">Sandeep Choudary</a>

       <hr>

       <p>{{ str_limit($post->body, 50) }}</p>

       <p><a class="btn btn-primary" href="{{ action('[email protected]', $post) }}" role="button">Read More &raquo;</a></p>

    </div>

    <div class="col-lg-11">

              <!-- Title -->
              <h2>{{$post->title}}</h2>

           on {{ $post->created_at->toFormattedDateString() }}  by <a href="#">Sandeep Choudary</a>

           <hr>

           <p>{{ str_limit($post->body, 50) }}</p>

           <p><a class="btn btn-primary" href="{{ action('[email protected]', $post) }}" role="button">Read More &raquo;</a></p>

        </div>

</div>
  @endsection

deepu07 left a reply on InvalidArgumentException: Unable To Locate Factory With Name [default] [App\Article]. • 3 days ago

yayy I got it! Thanks for everyone.

deepu07 left a reply on InvalidArgumentException: Unable To Locate Factory With Name [default] [App\Article]. • 3 days ago

When I run with TestCase i.e class ArticleTest extends TestCase I' m getting error like this


PHP Fatal error:  Class 'TestCase' not found in C:\xampp7\htdocs\UnitTest\tests\Unit\ArticleTest.php on line 6

Fatal error: Class 'TestCase' not found in C:\xampp7\htdocs\UnitTest\tests\Unit\ArticleTest.php on line 6```

deepu07 left a reply on InvalidArgumentException: Unable To Locate Factory With Name [default] [App\Article]. • 3 days ago

`<?php

use App\Article;

class ArticleTest extends PHPUnit_Framework_TestCase {

/** @test */

function it_fetches_trending_articles()
{

     factory(Article::class, 3)->create();

     factory(Article::class)->create(['read' => 10]);

     $mostpopular = factory(Article::class)->create(['read' => 20]);


     $articles = Article::trending();

     $this->AsserEquals($mostpopular->id, $articles->first()->id);
}

} `

deepu07 left a reply on InvalidArgumentException: Unable To Locate Factory With Name [default] [App\Article]. • 3 days ago

It looks like same. I'm using Laravel 5.5 Version.

deepu07 left a reply on InvalidArgumentException: Unable To Locate Factory With Name [default] [App\Article]. • 3 days ago

#getting like this#

C:\xampp7\htdocs\UnitTest>phpunit

PHPUnit 3.7.21 by Sebastian Bergmann.

Configuration read from C:\xampp7\htdocs\UnitTest\phpunit.xml

E.......

Time: 172 ms, Memory: 6.00MB

There was 1 error:

  1. ArticleTest::it_fetches_trending_articles InvalidArgumentException: Unable to locate factory with name [default] [App\Article].

C:\xampp7\htdocs\UnitTest\vendor\laravel\framework\src\Illuminate\Database\Eloquent\FactoryBuilder.php:248 C:\xampp7\htdocs\UnitTest\vendor\laravel\framework\src\Illuminate\Database\Eloquent\Concerns\GuardsAttributes.php:122 C:\xampp7\htdocs\UnitTest\vendor\laravel\framework\src\Illuminate\Database\Eloquent\FactoryBuilder.php:260 C:\xampp7\htdocs\UnitTest\vendor\laravel\framework\src\Illuminate\Database\Eloquent\FactoryBuilder.php:193 C:\xampp7\htdocs\UnitTest\vendor\laravel\framework\src\Illuminate\Database\Eloquent\FactoryBuilder.php:194 C:\xampp7\htdocs\UnitTest\vendor\laravel\framework\src\Illuminate\Database\Eloquent\FactoryBuilder.php:148 C:\xampp7\htdocs\UnitTest\tests\Unit\ArticleTest.php:15

FAILURES! Tests: 8, Assertions: 7, Errors: 1. 

13th January, 2018

deepu07 started a new conversation InvalidArgumentException: Unable To Locate Factory With Name [default] [App\Article]. • 4 days ago

I'm trying to test an Article model with laravel-factory. When I hit phpunit I'm getting an error like this

`PHPUnit 3.7.21 by Sebastian Bergmann.

Configuration read from C:\xampp7\htdocs\UnitTest\phpunit.xml

E.......

Time: 148 ms, Memory: 6.00MB

There was 1 error:

  1. ArticleTest::test_it_fetches_trending_articles InvalidArgumentException: Unable to locate factory with name [default] [App\Article].

C:\xampp7\htdocs\UnitTest\vendor\laravel\framework\src\Illuminate\Database\Eloquent\FactoryBuilder.php:248 C:\xampp7\htdocs\UnitTest\vendor\laravel\framework\src\Illuminate\Database\Eloquent\Concerns\GuardsAttributes.php:122 C:\xampp7\htdocs\UnitTest\vendor\laravel\framework\src\Illuminate\Database\Eloquent\FactoryBuilder.php:260 C:\xampp7\htdocs\UnitTest\vendor\laravel\framework\src\Illuminate\Database\Eloquent\FactoryBuilder.php:193 C:\xampp7\htdocs\UnitTest\vendor\laravel\framework\src\Illuminate\Database\Eloquent\FactoryBuilder.php:194 C:\xampp7\htdocs\UnitTest\vendor\laravel\framework\src\Illuminate\Database\Eloquent\FactoryBuilder.php:148 C:\xampp7\htdocs\UnitTest\tests\Unit\ArticleTest.php:15

FAILURES! Tests: 8, Assertions: 7, Errors: 1. `

ArticleFactory.php#

3rd January, 2018

deepu07 left a reply on Laravel UnitTesting • 1 week ago

deepu07 left a reply on Laravel UnitTesting • 1 week ago

@bobbybouwmann Still I'm getting same. No luck at all. When I run phpunit in cmd im getting like this

PHPUnit 3.7.21 by Sebastian Bergmann.

Configuration read from C:\xampp7\htdocs\UnitTest\phpunit.xml

Time: 97 ms, Memory: 4.00MB

No tests executed!

C:\xampp7\htdocs\UnitTest>```

2nd January, 2018

deepu07 started a new conversation Laravel UnitTesting • 2 weeks ago

I'm new to testing.

ProductTest.php

31st December, 2017

deepu07 left a reply on How To Display Articles In An Order Without Duplications • 2 weeks ago

I want to display posts like

article-1 article-2 article-3 article-4

deepu07 left a reply on How To Display Articles In An Order Without Duplications • 2 weeks ago

@Snapey see post.blade file. I'm not getting a view what I'm expecting

deepu07 left a reply on How To Display Articles In An Order Without Duplications • 2 weeks ago

sorry I updated jus now. Can you take a look..

deepu07 left a reply on How To Display Articles In An Order Without Duplications • 2 weeks ago

@snapey If you saw above link I'm getting same posts two times. how can I prevent that duplication. I have changed ($articles as $article) in my foreach

30th December, 2017

deepu07 left a reply on How To Display Articles In An Order Without Duplications • 2 weeks ago

@snapey did you saw above link?

deepu07 started a new conversation How To Display Articles In An Order Without Duplications • 2 weeks ago

I want to display latest posts on my homepage.Here I'm using Laravel and JavaScript. but I'm getting the layout in different format. here is the link of view #https://i.stack.imgur.com/QCmXI.png#

#post.blade.php#

<h2>{{$article->title}}</h2>

{{ $article->created_at->toFormattedDateString() }}

<p>{{$article->body}} </p>

<p><a class="btn btn-primary" href="#" role="button">View details &raquo;</a></p>
<h2>{{$article->title}}</h2>

{{ $article->created_at->toFormattedDateString() }}

<p>{{$article->body}} </p>

<p><a class="btn btn-primary" href="#" role="button">View details &raquo;</a></p>
<h2>{{$article->title}}</h2>

{{ $article->created_at->toFormattedDateString() }}

<p>{{$article->body}}</p>

<p><a class="btn btn-primary" href="#" role="button">View details &raquo;</a></p>

##index.blade.php##

@extends('master')

@section('content')

@foreach ($article as $article)

  @include('article.post')

@endforeach

@endsection

Thanks in Advance.

28th December, 2017

deepu07 left a reply on How To Register A Model Dir In App • 2 weeks ago

Yes I'll follow php artisan make:model Model/SampleModel this one. Thanks @bobbybouwmann

deepu07 left a reply on How To Register A Model Dir In App • 2 weeks ago

@bobbybouwmann every time do I need to run that, Is it possible to save by default?

deepu07 started a new conversation How To Register A Model Dir In App • 2 weeks ago

Hi all, Greetings of the day! I was created a model dir in my laravel 5.5 to save all the models in an one place. When I'm hitting php artisan make:model SampleModel in my cmd it is by default creating a model file in app dir but not in model dir. How can I register that dir to save all my models in an one place.

Thanks in advance

23rd December, 2017

deepu07 left a reply on SQLSTATE[23000]: Integrity Constraint Violation: 1048 Column 'article_id' Cannot Be Null (SQL: Insert Into `comments` (`body`, `article_id`, `updated_at`, `created_at`) Values (adding New Comment, , 2017-12-22 03:21:15, 2017-12-22 03:21:15)) • 3 weeks ago

Yes. You are right. For that I added form tag with respective URL able to comment on particular article. When I'm trying to access http://localhost/Lara/public/article/1 [article that is associated with id one] I'm getting an error like this Property [title] does not exist on this collection instance. (View: C:\xampp7\htdocs\Lara\resources\views\article\show.blade.php)

deepu07 left a reply on SQLSTATE[23000]: Integrity Constraint Violation: 1048 Column 'article_id' Cannot Be Null (SQL: Insert Into `comments` (`body`, `article_id`, `updated_at`, `created_at`) Values (adding New Comment, , 2017-12-22 03:21:15, 2017-12-22 03:21:15)) • 3 weeks ago

What I'm trying to do is adding a comment on article. but by adding your code it is just displaying comment form but there is article content. How can we achieve that thing. My goal is I'm should able to comment on article based on article id. Does it make sense?

deepu07 left a reply on SQLSTATE[23000]: Integrity Constraint Violation: 1048 Column 'article_id' Cannot Be Null (SQL: Insert Into `comments` (`body`, `article_id`, `updated_at`, `created_at`) Values (adding New Comment, , 2017-12-22 03:21:15, 2017-12-22 03:21:15)) • 3 weeks ago

How can we call title and body of article based on articleId? //[email protected] public function show(Article $articleId) { return view('article.show',compact('articleId')); }

deepu07 left a reply on SQLSTATE[23000]: Integrity Constraint Violation: 1048 Column 'article_id' Cannot Be Null (SQL: Insert Into `comments` (`body`, `article_id`, `updated_at`, `created_at`) Values (adding New Comment, , 2017-12-22 03:21:15, 2017-12-22 03:21:15)) • 3 weeks ago

That's fine but why I'm getting this thing ""Property [title] does not exist on this collection instance. (View: C:\xampp7\htdocs\Lara\resources\views\article\show.blade.php)""

deepu07 left a reply on SQLSTATE[23000]: Integrity Constraint Violation: 1048 Column 'article_id' Cannot Be Null (SQL: Insert Into `comments` (`body`, `article_id`, `updated_at`, `created_at`) Values (adding New Comment, , 2017-12-22 03:21:15, 2017-12-22 03:21:15)) • 3 weeks ago

@snapey I'm totally messup! Can you forward your github gmail. I'll add contributor to my repo. So that you can take a look. That's easy. Is it fine for you?

deepu07 left a reply on SQLSTATE[23000]: Integrity Constraint Violation: 1048 Column 'article_id' Cannot Be Null (SQL: Insert Into `comments` (`body`, `article_id`, `updated_at`, `created_at`) Values (adding New Comment, , 2017-12-22 03:21:15, 2017-12-22 03:21:15)) • 3 weeks ago

//form tag

<div class="card">
    <div class="card-block">
        <form method="POST" action="{{ url('/post/{$article->id}/comment') }}"> 
            {{ csrf_field() }}
            <div class="form-group">
                <textarea name="body" placeholder="your comment here." class="form-control">  </textarea>
            </div>
            <div class="form-group">
                <button type="submit" class="btn btn-primary">Add Comment</button>
            </div>
        </form>
    </div>

22nd December, 2017

21st December, 2017

deepu07 started a new conversation SQLSTATE[23000]: Integrity Constraint Violation: 1048 Column 'article_id' Cannot Be Null (SQL: Insert Into `comments` (`body`, `article_id`, `updated_at`, `created_at`) Values (adding New Comment, , 2017-12-22 03:21:15, 2017-12-22 03:21:15)) • 3 weeks ago

i have articles table and comments table. article_id is foriegn key in comments table. i cant save the article_id in reply comments table and im i getting this error. how to solve it? CommentController: public function store(Article $article) { $this->validate(request(),['body' => 'required|min:2']);

        $article = Comment::create([
        'body' => request('body'),
        'article_id' => $article->id,
    ]);

    return back();
}

views.blade:

{{ csrf_field() }} Add Comment

Comment model: class Comment extends Model { public $timestamps = TRUE;

protected $table = 'comments';

/**
 * The attributes that are mass assignable.
 *
 * @var array
 */
protected $fillable = [

    'body',
    'article_id'
];

public function article()
{
    return $this->belongsTo(Article::class);
}

}

Route: Route::post('/post/{post}/comment', '[email protected]');

Where I'm missing. Thanks in Advance

19th December, 2017

deepu07 left a reply on Events Vs Observers • 4 weeks ago

Awesome. Thanks guys @cmdobueno @Cronix

deepu07 left a reply on Events Vs Observers • 4 weeks ago

@Cronix but they will do same kind of jobs. Am i right?

deepu07 started a new conversation Events Vs Observers • 4 weeks ago

I'm really confused with events and observers. because both are doing same things. what are the differences b/w events and observers? Thanks in advance.

14th December, 2017

deepu07 left a reply on Blank Page Is Displaying @yield Is Not Working.Any Help..... • 1 month ago

@tisuchi

I just changed from @extend('index') to @extends('index') but No output at all. My path is I have master.blade.php file in article dir which is in view folder. So in my view folder I do have two things one article file and index.blade.php

deepu07 started a new conversation Blank Page Is Displaying @yield Is Not Working.Any Help..... • 1 month ago

//Controller

Edit Your Profile
Update

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