towhid

Experience

1,480

0 Best Reply Awards

  • Member Since 10 Months Ago
  • 11 Lessons Completed
  • 0 Favorites

13th December, 2016

towhid left a reply on MY Validate Code Does Not Work -- And Also Dont Show Any Error • 10 months ago

where i will write this code count($errors > 0) please tell me accurately. @ejdelmonico

8th December, 2016

towhid left a reply on MY Validate Code Does Not Work -- And Also Dont Show Any Error • 10 months ago

@ejdelmonico

 public function update(Request $request, Note $show_card_note){


            $this->validate($request, [

                    'body' => 'required|min:10'

                ]);


            $show_card_note->update($request->all());



            return back();
        }

7th December, 2016

towhid started a new conversation MY Validate Code Does Not Work -- And Also Dont Show Any Error • 10 months ago

this is my code controller

$this->validate($request, [

                    'body' => 'required|min:10'

                ]);

my template code


                @if(count($errors))
                <ul>
                    @foreach($errors->all() as $error)
                    <li>{{$error}}</li>
                    @endforeach
                </ul>
                @endif

when use only this code then show this code

object(Illuminate\Support\ViewErrorBag)#171 (1) { ["bags":protected]=> array(0) { } }

towhid left a reply on TokenMismatchException In Compiled.php Line 3227 • 10 months ago

@GDim ok I will try ! Thank you !

30th November, 2016

towhid left a reply on TokenMismatchException In Compiled.php Line 3227 • 10 months ago

YES - ITS Work ! you are great .

27th November, 2016

towhid left a reply on Call To Undefined Method Illuminate\Database\Query\Builder::user() • 10 months ago

yes its work / problem occurs this relationship missing on my note model


public function user(){

        return $this->belongsTo(User::class);
    }



Thank you ! @jekinney

towhid left a reply on Call To Undefined Method Illuminate\Database\Query\Builder::user() • 10 months ago

>>> App\Note::all();
=> Illuminate\Database\Eloquent\Collection {#634
     all: [
       App\Note {#635
         id: 1,
         user_id: 1,
         card_id: 1,
         body: "The body of the Note",
         created_at: "2016-11-27 17:05:49",
         updated_at: "2016-11-27 17:05:49",
       },
       App\Note {#636
         id: 2,
         user_id: 2,
         card_id: 1,
         body: "please chage it second note",
         created_at: "2016-11-27 17:13:38",
         updated_at: "2016-11-27 17:29:24",
       },
     ],
   }
>>> App\User::all();
=> Illuminate\Database\Eloquent\Collection {#639
     all: [
       App\User {#640
         id: 1,
         username: "tanvir",
         email: "[email protected]",
         created_at: "2016-11-27 17:07:24",
         updated_at: "2016-11-27 17:07:24",
       },
       App\User {#641
         id: 2,
         username: "tanjil",
         email: "[email protected]",
         created_at: "2016-11-27 17:12:12",
         updated_at: "2016-11-27 17:12:12",
       },
     ],
   }






towhid started a new conversation Call To Undefined Method Illuminate\Database\Query\Builder::user() • 10 months ago

step by step i check --card show all

$show_cards_details=Card::all();
return $show_cards_details;

step by step i check note show all with card

$show_cards_details=Card::with('notes')->get();

step by step i check selected note show with card

$show_cards_details=Card::with('notes')->find(1);

step by step when i check user don't show any thing on my browser

return $show_cards_details->notes[0]; work  but 


return $show_cards_details->notes[0]->user; notwork 


when i use this code the error occur why this thing ?

 public function show( Card $show_cards_details){  


            $show_cards_details->load('notes.user');

            return view('card.show', compact('show_cards_details'));
    }

the error is

BadMethodCallException in Builder.php line 2405:
Call to undefined method Illuminate\Database\Query\Builder::user()
in Builder.php line 2405
at Builder->__call('user', array())
at Builder->user()
at call_user_func_array(array(object(Builder), 'user'), array()) in Builder.php line 1426
at Builder->__call('user', array())
at Builder->user()
at call_user_func_array(array(object(Builder), 'user'), array()) in compiled.php line 11663
at Model->__call('user', array()) in Builder.php line 693
at Note->user() in Builder.php line 693
at Builder->Illuminate\Database\Eloquent{closure}()
at call_user_func(object(Closure)) in Relation.php line 184
at Relation::noConstraints(object(Closure)) in Builder.php line 694
at Builder->getRelation('user') in Builder.php line 665
at Builder->loadRelation(array(object(Note), object(Note)), 'user', object(Closure)) in Builder.php line 645
at Builder->eagerLoadRelations(array(object(Note), object(Note))) in Builder.php line 322
at Builder->get()  ..........

towhid left a reply on TokenMismatchException In Compiled.php Line 3227 • 10 months ago

but when i use method_fuield on this route get error

<form method="POST" action="/note/{{$show_card_note->id}}">
                    {{ method_field('PATCH') }}

but when i use this one with this route its work and update if i use csrf_field

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

towhid left a reply on TokenMismatchException In Compiled.php Line 3227 • 10 months ago

form method="POST" action="/note/{{$show_card_note->id}}">
                    {{ csrf_field('PATCH') }}
                    <div class="form-group">
            <textarea name="body" class="form-control">{{$show_card_note->body}}</textarea>
                        
                    </div>
                    <div class="form-group">
                        <button type="submit" class="btn btn-success">Update Note</button>
                        
                    </div>

                </form>

Error show when i use your code ...

MethodNotAllowedHttpException in compiled.php line 8936:
in compiled.php line 8936
at RouteCollection->methodNotAllowed(array('PATCH')) in compiled.php line 8932
at RouteCollection->getRouteForMethods(object(Request), array('PATCH')) in compiled.php line 8910
at RouteCollection->match(object(Request)) in compiled.php line 8264
at Router->findRoute(object(Request)) in compiled.php line 8212
at Router->dispatchToRoute(object(Request)) in compiled.php line 8207
at Router->dispatch(object(Request)) in compiled.php line 2419
at Kernel->Illuminate\Foundation\Http\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 52
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in compiled.php line 3286
at CheckForMaintenanceMode->handle(object(Request), object(Closure))
at call_user_func_array(array(object(CheckForMaintenanceMode), 'handle'), array(object(Request), object(Closure))) in compiled.php line 9963
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in compiled.php line 9948
at Pipeline->then(object(Closure)) in compiled.php line 2366
at Kernel->sendRequestThroughRouter(object(Request)) in compiled.php line 2350
at Kernel->handle(object(Request)) in index.php line 54
at require_once('C:\dynamic\htdocs\shop\public\index.php') in server.php line 21

26th November, 2016

towhid started a new conversation TokenMismatchException In Compiled.php Line 3227 • 10 months ago

use this code on my edit page

<form method="POST" action="/note/{{$show_card_note->id}}">
                    {{ method_field('PATCH') }}
                    <div class="form-group">
            <textarea name="body" class="form-control">{{$show_card_note->body}}</textarea>
                        
                    </div>
                    <div class="form-group">
                        <button type="submit" class="btn btn-success">Update Note</button>
                        
                    </div>

                </form>

this code use my route

Route::patch('note/{show_card_note}', '[email protected]');

use this code Note controller

public function edit(Note $show_card_note){

            return view ('note.edit', compact('show_card_note'));
    }

    public function update(Request $request, Note $show_card_note){


            $show_card_note->update($request->all());

            return back();
        }

please tell me what my wrong i am follow this video link

https://laracasts.com/series/laravel-5-from-scratch/episodes/10

towhid left a reply on TokenMismatchException In Compiled.php Line 3227: Why This Show On My Error Page ? • 10 months ago

yes its work thank you :)

towhid left a reply on TokenMismatchException In Compiled.php Line 3227: Why This Show On My Error Page ? • 10 months ago

yes i add this syntax but its show

{"_token":"t73XfCVKxrqcKC9KEymwzkOCrX1Fw9dvyVM1x4t3","body":"dsdsds"}

but -- next step when i want use this code for show card details then show error again


use App\Card;
use App\Note;
use Illuminate\Http\Request;

// use App\Http\Requests;

class NoteController extends Controller
{
    public function store(Request $request Card $show_card){

            // return $request->all();

            return $show_card;

            $note = new Note;
            $note -> body = $request->body;


 



    }
}

FatalErrorException in NoteController.php line 13: syntax error, unexpected 'Card' (T_STRING), expecting ')' in NoteController.php line 13

towhid started a new conversation TokenMismatchException In Compiled.php Line 3227: Why This Show On My Error Page ? • 10 months ago

#what happens here ?

                </div>
                <div class="form-group">
                    <button type="submit" class="btn btn-success">Add Note</button>
                    
                </div>

            </form>

#when i want to add new note with input box then show this error like video

Sorry, the page you are looking for could not be found.

1/1 NotFoundHttpException in compiled.php line 8912: in compiled.php line 8912 at RouteCollection->match(object(Request)) in compiled.php line 8264 at Router->findRoute(object(Request)) in compiled.php line 8212 at Router->dispatchToRoute(object(Request)) in compiled.php line 8207 at Router->dispatch(object(Request)) in compiled.php line 2419 at Kernel->Illuminate\Foundation\Http{closure}(object(Request)) at call_user_func(object(Closure), object(Request)) in Pipeline.php line 52 at Pipeline->Illuminate\Routing{closure}(object(Request)) in compiled.php line 3286 at CheckForMaintenanceMode->handle(object(Request), object(Closure)) at call_user_func_array(array(object(CheckForMaintenanceMode), 'handle'), array(object(Request), object(Closure))) in compiled.php line 9963 at Pipeline->Illuminate\Pipeline{closure}(object(Request)) at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32.........

#when i create route

Route::post('card/{show_cards_details}/notes', '[email protected]');

& use this Note controller function

public function store(Request $request){

        return $request->all();
}

#When i m trying to input and add then -> this is my explorer link show

http://localhost:8000/card/1/notes

#and the page error is

Whoops, looks like something went wrong.

1/1 TokenMismatchException in compiled.php line 3227: in compiled.php line 3227 at VerifyCsrfToken->handle(object(Request), object(Closure)) at call_user_func_array(array(object(VerifyCsrfToken), 'handle'), array(object(Request), object(Closure))) in compiled.php line 9963 at Pipeline->Illuminate\Pipeline{closure}(object(Request)) at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32 at Pipeline->Illuminate\Routing{closure}(object(Request)) in compiled.php line 13474 at ShareErrorsFromSession->handle(object(Request), object(Closure)) at call_user_func_array(array(object(ShareErrorsFromSession), 'handle'), array(.......

#I just followed this video link --

https://laracasts.com/series/laravel-5-from-scratch/episodes/9

same as like video i am using but the output not show what the wrong my code - i don't understand

25th November, 2016

towhid left a reply on Illuminate\Database\Eloquent\Collection All: [], But Need To Show With All Data • 10 months ago

=> App\Note {#619}
``` $note->body="here is another note";
=> "here is another note"

``` $card=App\Card::first();
=> App\Card {#638
     id: 1,
     title: "my new card",
     created_at: "2016-11-24 17:27:44",
     updated_at: "2016-11-24 17:27:44",
   }


``` $card->notes->save($note);
BadMethodCallException with message 'Method save does not exist.'

Why this error and whats the mean --- 


for this reason i using old way  
============================
```$note=new App\Note;
=> App\Note {#622}

```$note->body="Some Note For the card"; 
=> "Some Note For the card" 
```$note->card_id=2; 
=> 2 
```$note->save();
=> true

```$card = App\Card::findOrFail(1);

```$card->notes;



towhid left a reply on Illuminate\Database\Eloquent\Collection All: [], But Need To Show With All Data • 10 months ago

yes its work - this code step by step -

  1. add protected $fillable = ['body']; on my model =======================================

class Note extends Model { protected $fillable = ['body']; }

2.then use one bye one

$note=new App\Note; => App\Note {#622} $note->body="some note for the card"; => "some note for the card" $note->card_id= 2; => 2 $note->save(); => true

  1. then i use your suggested code for find selected id ============================

$card = App\Card::findOrFail(2);

  1. then use this line =====================

$card->notes;

and its work ! Thank you very much ! but i will check your another way also ,

still i don't understand what did wrong , i just follow this https://laracasts.com/index.php/series/laravel-5-from-scratch/episodes/8 video and i am guarantee all are did same to same .. ..

towhid left a reply on Illuminate\Database\Eloquent\Collection All: [], But Need To Show With All Data • 10 months ago

Thanks but i was try your instruction the output show here

when i am command this >>> $card = App\Card::findOrFail(2);

=> App\Card {#635 id: 2, title: "my second new card", created_at: "2016-11-24 17:30:01", updated_at: "2016-11-24 17:30:01", }

but when iam use this line

$note=App\Note::create(['body'=>'some note for the second card']); then show this Illuminate\Database\Eloquent\MassAssignmentException with message 'body'

and when i am using this line

$card->notes()->save($note);

then show - PHP error: Undefined variable: note on line 1

/* and the other sance i will follow */ before your instruction

https://laracasts.com/index.php/series/laravel-5-from-scratch/episodes/8

this video so whats my fault == i don't understand -

thank you !

towhid started a new conversation Illuminate\Database\Eloquent\Collection All: [], But Need To Show With All Data • 10 months ago

when iam trying to add notes on my card - then nothing show on array - ia m trying 4 to 5 times but nothing change its just -- all:[]

on card model

use Illuminate\Database\Eloquent\Model;

class Card extends Model { public function notes(){

    return $this->hasMany(Note::class);
}

}

on tinker

$note=new App\Note; => App\Note {#622}

$note->body="Some Note For the card"; => "Some Note For the card" $note->card_id=2; => 2 note->save(); PHP Parse error: Syntax error, unexpected T_OBJECT_OPERATOR on line 1 $note->save(); => true

when iam trying to note on my card with this code

$card=App\Card::first(); => App\Card {#633 id: 1, title: "my new card", created_at: "2016-11-24 17:27:44", updated_at: "2016-11-24 17:27:44", }

$card->notes; => Illuminate\Database\Eloquent\Collection {#623 all: [], }

Edit Your Profile
Update

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