Jump to content

help needed with laravel

Go to solution Solved by matthewb987,

fix this issue by placing the code in a for each loop

i am using this script https://github.com/laravelista/comments to create comments on my site but i cant seem to get it working

any idea on what i am doing wrong

 

Thanks in advanced 

 

I am getting the following error when i run @comments(['model' => $id])
ErrorException
Attempt to read property "comments" on string (View: /var/www/html/resources/views/vendor/comments/components/comments.blade.php)

my route :
Route::get('/video/{creator}/{video}/{id}', [Videocontroller::class, 'viewvideo'])->middleware('App\Http\Middleware\Subscribed','auth');

my controller:
`public function viewvideo($creator, $video, $id) {

    $videourl = Storage::url($video);
    
    return view("viewvideo", compact(['creator', 'video','id']));
}`

my view:
`<?php

$title = DB::table('videos')
->where('url', '=', $creator.'/'.$video)->get();

DB::table('videos')
->where('url', '=', $creator.'/'.$video)
->increment('views', 1);

$detect = new Mobile_Detect;
if( $detect->isAndroidOS() ){

        echo "android is not yet fully supported";
    }

            ?>
</x-slot>

<div class="py-12">
    <div class="max-w-7xl mx-auto sm:px-6 lg:px-8">
        <div class="bg-white overflow-hidden shadow-sm sm:rounded-lg">
            <div class="p-6 bg-white border-b border-gray-200">
 

@foreach($title as $t)

<div class="video-title"><h2>{{$t->title}}</h2></div>
<p> </p>
<details>
<summary>Description</summary>
<?php echo $t->description; ?>

Views: views; ?>

@Endforeach

@comments(['model' => $id])

            </div>
        </div>
    </div>
</div>

`

Link to comment
https://linustechtips.com/topic/1437526-help-needed-with-laravel/
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×