towhid

Experience

3,650

0 Best Reply Awards

  • Member Since 1 Year Ago
  • 13 Lessons Completed
  • 0 Favorites

26th April, 2018

towhid left a reply on With Out Any Data If I Click My Submit Button Then Show This Error What Kind Ofcondition I Use ? • 5 hours ago

@tykus Hello , are you mind for any reason ? what the reason for your angry ? you know very well better then me , if any kind of wrong information please be clear , i am new that's why more possibility for any wrong . i am not understand what is the best answer meaning of this thing my think : which code is perfect solve the problem any problem . may be i am wrong .

towhid left a reply on Form - Error And Placeholder • 5 hours ago

@siusiak1000

try to use validation rules in store function

$validatedData = $request->validate([
        'title' => 'required|unique:posts|max:255',
        'body' => 'required',
    ]);

follow this link for flash message https://laravel.com/docs/5.6/session#flash-data

towhid left a reply on With Out Any Data If I Click My Submit Button Then Show This Error What Kind Ofcondition I Use ? • 5 hours ago

@tykus

if i use client site validation thsi are ok 

```
<input type="text" name="title" required>
```

 > but when i am trying to server site validation this show error 


// [email protected] $request->validate([ 'title' => 'required', // rules for other fields ]);

And the other things  ---

this is your code 

$request->validate(......); this is mine $this->validate(request(), .......);


towhid left a reply on With Out Any Data If I Click My Submit Button Then Show This Error What Kind Ofcondition I Use ? • 6 hours ago

@rin4ik And @tykus its solve this code

$this->validate(request(),['body' => 'required']);

towhid left a reply on With Out Any Data If I Click My Submit Button Then Show This Error What Kind Ofcondition I Use ? • 6 hours ago

@tykus yes @rin4ik is right if i use this protected $fallible = ['title','body','etc'] then show this error

SQLSTATE[HY000]: General error: 1364 Field 'post_id' doesn't have a default value (SQL: insert into `comments` (`body`, `updated_at`, `created_at`) values (ssss, 2018-04-26 10:52:55, 2018-04-26 10:52:55))
```

towhid left a reply on With Out Any Data If I Click My Submit Button Then Show This Error What Kind Ofcondition I Use ? • 6 hours ago

@rin4ik this is my model eloquest code

protected $guarded = [] ;

nothing else not any fallible code

towhid left a reply on With Out Any Data If I Click My Submit Button Then Show This Error What Kind Ofcondition I Use ? • 6 hours ago

@rin4ik this is learning site :) i am still learning -and one thing i have small basic idea not at all but still i am learning from you and your community ,i am enjoy here as like your and your capabilities , how you are all do this ? with out my all code review ?

please inspire me , and other thing i am still learning , and this is my number 2 month i am doing one project , yes i agree your word " you are all making my project - but one thing ,, you are all give me my solution not my real project just - sample - i am really great full to you all - this is community , i am doing project with you all not single me :)

i know - how to share my problem to you all and solve it properly by all :) you are all generous ! seriously - please guide me more-- i want to learn more :)

towhid started a new conversation With Out Any Data If I Clik My Submit Button Then Show This Error What Kind Ofcondition I Use ? • 6 hours ago

SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'title' cannot be null (SQL: insert into `posts` (`title`, `body`, `category_id`, `updated_at`, `created_at`) values (, , 1, 2018-04-26 10:25:22, 2018-04-26 10:25:22))

towhid left a reply on Cannot Create Comments And Cannot Show Comment My Selected Post - • 7 hours ago

@rin4ik its work buddy :) thank you ---

@tykus thank you brother ...

towhid left a reply on Cannot Create Comments And Cannot Show Comment My Selected Post - • 7 hours ago

i change my code in comment model like this

    public function post(){
    return $this->belongsTo(Post::class);
    }

towhid left a reply on Cannot Create Comments And Cannot Show Comment My Selected Post - • 7 hours ago

@rin4ik after edit my code post to posts -

error show

 BadMethodCallException
Method Illuminate\Database\Query\Builder::addComment does not exist.

towhid left a reply on Cannot Create Comments And Cannot Show Comment My Selected Post - • 7 hours ago

@tykus this my wrong code no need commma

towhid started a new conversation Cannot Create Comments And Cannot Show Comment My Selected Post - • 7 hours ago

This is my route code


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

This is my comment model code

<?php

namespace App;


class Comment extends Model
{
    public function comments(){
    return $this->hasMany(Comment::class);
    }


    public function addComment($body){

            Comment::   create([
            'body'=> $body,
            'post_id'=>$this->id,
            ]);
    }
}

This is my controller code namespace App\Http\Controllers;

use Illuminate\Http\Request; use App\Post; use App\Comment;

class commentsController extends Controller { public function store(Post, $post){

    $post->addComment(request('body'));

    return back();
}

}



25th April, 2018

towhid left a reply on Data Show Category Wise / Data Show Only Popular / Data Show In Select List Input Form Drop Down Element • 23 hours ago

i complete this thing others way -!! thanks ,

towhid left a reply on How To Pass Data To A Layout.blade.php • 1 day ago

@rin4ik this error show

 ErrorException (E_ERROR)
Class 'App\Providers\Category' not found (View: C:18\relation\resources\views\layout\header.blade.php) (View: C:18\relation\resources\views\layout\header.blade.php) (View: C:18\relation\resources\views\layout\header.blade.php)

towhid left a reply on How To Pass Data To A Layout.blade.php • 1 day ago

public function boot()
    {
        view()->composer(
            'viewFileName', -> can i use here my file location ('layout.nav')
            function ($view) {
                $view->with('categories', Category::all());
            }
        );
    }

show this error

Undefined variable: categories (View: C:\2018\relation\resources\views\layout\nav.blade.php) (View: C:\2018\relation\resources\views\layout\nav.blade.php) (View: C:\2018\relation\resources\views\layout\nav.blade.php) (View: C:\2018\relation\resources\views\layout\nav.blade.php)

towhid left a reply on How To Pass Data To A Layout.blade.php • 1 day ago

@rin4ik can i add this code any controller ?

i think i dont understand ! :(

towhid left a reply on How To Pass Data To A Layout.blade.php • 1 day ago

@Vilfago

$categories=App\Category::all()

towhid started a new conversation How To Pass Data To A Layout.blade.php • 1 day ago

like : i want to show my all category in my menu bar but menu bar is a layout not any page i found this code. and its work but i think better sol lotion in laravel for any data pass to layout

in navbar

towhid left a reply on HTML Special Characters Issue • 1 day ago

use this way {!! your variable !!}

towhid left a reply on Need Help Category Wise Post Show • 1 day ago

@rin4ik can i contact you skype :) i need your help and need your guide line .

towhid left a reply on Need Help Category Wise Post Show • 1 day ago

i think need one function where argument "id" pass show id wise category post

towhid left a reply on Need Help Category Wise Post Show • 1 day ago

@rin4ik its already done by me -tinker is ok - i think its show perfect data , but i dont undersatnd what i will do for where i show the all categiry name - then i want if any one click any - category then one page generate and show only selected category post

towhid left a reply on Need Help Category Wise Post Show • 1 day ago

@biishmar yes i have post data with category_id

towhid left a reply on Need Help Category Wise Post Show • 1 day ago

ok - guys . now i am apply my code in my application

in category model

    public function post(){
        return $this->belongsTo(Post::class);
    }

that's why i am checking my tinker

>>> $a=App\Category::find(6)
=> App\Category {#2326
     id: 6,
     name: "man",
     created_at: "2018-04-25 05:46:58",
     updated_at: "2018-04-25 05:46:58",
   }

but when i am trying to this code

>>> $a->post

show null


how i do this ?

towhid left a reply on Need Help Category Wise Post Show • 1 day ago

@biishmar yes i created category_id in my posts table

towhid left a reply on Need Help Category Wise Post Show • 1 day ago

@biishmar Done -

in category

namespace App;

use Illuminate\Database\Eloquent\Model;

class Category extends Model
{
    public function post(){
        return $this->hasMany(Post::class);
    }
}

>class Post extends Model

towhid left a reply on Need Help Category Wise Post Show • 1 day ago

@Snapey one post belong to just one category ..

towhid left a reply on Need Help Category Wise Post Show • 1 day ago

one category has many post @Snapey

towhid left a reply on Need Help Category Wise Post Show • 1 day ago

@biishmar , complete your instruction category_id add my posts table

towhid left a reply on Need Help Category Wise Post Show • 1 day ago

@spekkionu hi, there are no relationship in my models, one category has many post this i want

towhid left a reply on Need Help Category Wise Post Show • 1 day ago

@Snapey Hello !

its mean i want to show my post category wise Example : i have 10 post, and i have 2 category , a) man b) woman but i want to view only which post man category , i want to know the whole procedure thanky ou .

towhid started a new conversation Need Help Category Wise Post Show • 1 day ago

I have posts Table : id, title, body category table : id, name,

now i want to view my page category wise post , so what can i do ? thank you

24th April, 2018

towhid left a reply on Cannot Update My Data From My Edit From • 1 day ago

@jlrdw do you ask me or others one ?

towhid left a reply on Cannot Update My Data From My Edit From • 1 day ago

@Cronix this is your code you suggest me first with id

<form class="col-md-6" method="POST" action="/posts/{{ $post->id }}">

but @rin4ik suggest me

@csrf and my problem is solve 

so both are right :) don't fight , we are a family .... :) thanks

towhid left a reply on Cannot Update My Data From My Edit From • 1 day ago

@Vilfago same eorror

The page has expired due to inactivity.

Please refresh and try again.

towhid left a reply on Cannot Update My Data From My Edit From • 1 day ago

@rin4ik this is message show

@method('PUT')
The page has expired due to inactivity. 

Please refresh and try again.

towhid left a reply on Cannot Update My Data From My Edit From • 1 day ago

@rin4ik shoe this error when iam trying to click edit button

ErrorException (E_ERROR)
Missing required parameters for [Route: posts.update] [URI: posts/{post}]. (View: C:\project\temp\resources\views\post\edit.blade.php)

towhid left a reply on Cannot Update My Data From My Edit From • 1 day ago

@Cronix this is my route link

Route::resource('posts','postController');

towhid left a reply on Cannot Update My Data From My Edit From • 1 day ago

@jlrdw use your suggesion like ,

    protected $fillable = [
        'title', 'body'
    ];

but not work still same error

Symfony \ Component \ HttpKernel \ Exception \ MethodNotAllowedHttpException No message

towhid left a reply on Cannot Update My Data From My Edit From • 1 day ago

HEllo @bashy Not work -- this error show

Symfony \ Component \ HttpKernel \ Exception \ MethodNotAllowedHttpException

No message

towhid started a new conversation Cannot Update My Data From My Edit From • 1 day ago

This is my edit form

<form class="col-md-6" method="PUT" action="/posts">
          <div class="form-group">
            <label for="title">Title</label>
            <input type="text" class="form-control" id="title" name="title" value="{{$post->title}}">
          </div>
          <div class="form-group">
            <label for="body">Body</label>
            <textarea class="form-control" rows="5" name="body">{{$post->body}}</textarea>
          </div>
          
          <button type="submit" class="btn btn-success">Update</button>
        </form>

This is my edit and update controller code

   public function edit($id)
    {
        $post=Post::find($id);
        return view('post.edit',compact('post'));
    }

    public function update(Request $request, $id)
    {
        $post=Post::find($id);
        $post->title = $request->input('title');
        $post->body = $request->input('body');
        $post->save();
        return redirect('/posts')->with('success','Post Updated');
    }

this is my model code

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Post extends Model
{
    //
}

this is my route code


Route::resource('posts','postController');

but not work -- please -- tell me- the - probelm

20th April, 2018

towhid left a reply on BadMethodCallException Method Illuminate\Http\UploadedFile::getClientOrginalName Does Not Exist. • 6 days ago

@Snapey hi , i already use max: 1999 to max : 5000 but still same error

The cover image failed to upload.

18th April, 2018

towhid left a reply on BadMethodCallException Method Illuminate\Http\UploadedFile::getClientOrginalName Does Not Exist. • 1 week ago

o so its depend on - php.ini settings, not any laravel -- end ? @Sergiu17

17th April, 2018

towhid started a new conversation Data Show Category Wise / Data Show Only Popular / Data Show In Select List Input Form Drop Down Element • 1 week ago

i know how to create, delete, update, show and store , index , any data , for my senario : category 4 type , a,b,c,d

  1. if some one want to see all of "a" category post
  2. if some one want to popular post last week in admin panel :

when some one going to create new post then must be select category listed any one , so how to show input box select with drop down value come from my database

in this format {{Form::select('title', ['l' => 'large', 's' => 'small'])}} - but how to use "foreach" here ?

towhid left a reply on BadMethodCallException Method Illuminate\Http\UploadedFile::getClientOrginalName Does Not Exist. • 1 week ago

@snapey hello , when iam trying to upload image size 1999 then show this error . could you please tell me ow to maximize the image size controll ?

16th April, 2018

towhid left a reply on BadMethodCallException Method Illuminate\Http\UploadedFile::getClientOrginalName Does Not Exist. • 1 week ago

@bobbybouma after correction some code -

 $fileNameWithExt = $request->file('cover_image')->getClientOriginalName();

$extention = $request->file('cover_image')->getClientOriginalExtension();

##out put is

The cover image failed to upload.

towhid left a reply on SQLSTATE[42S21]: Column Already Exists: 1060 Duplicate Column Name 'user_id' (SQL: Alter Table `posts` Add `user_id` Int Not Null) • 1 week ago

:) - thanks for your details but we have to find out why this problem occurred - may be- its cache problem @Cronix

Edit Your Profile
Update

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