behnampmdg3

behnampmdg3

Member Since 4 Years Ago

Experience Points 15,480
Experience
Level
Lessons Completed 85
Lessons
Completed
Best Reply Awards 0
Best Answer
Awards
  • Start Your Engines Achievement

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • First Thousand Achievement

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • One Year Member Achievement

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • Two Year Member Achievement

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • Three Year Member Achievement

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • Four Year Member Achievement

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • Five Year Member Achievement

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • School In Session Achievement

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • Welcome To The Community Achievement

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • Full Time Learner Achievement

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • Pay It Forward Achievement

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • Subscriber Achievement

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • Lifer Achievement

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • Laracasts Evangelist Achievement

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.

  • Chatty Cathy Achievement

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • Laracasts Veteran Achievement

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • Ten Thousand Strong Achievement

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • Laracasts Master Achievement

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • Laracasts Tutor Achievement

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • Laracasts Sensei Achievement

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • Top 50 Achievement

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

11 Nov
1 day ago

behnampmdg3 started a new conversation Laravel Tags Vs Wordpress Tags (SEO)

Hello;

I have a question about tags I'd appreciate some advice.

I am about to build a blog and post a couple hundred articles and I am a bit unsure about "tags".

I can't find watched Jeff's video on tags (I think it was in 5.4 from scratch) from what I recall, he made a tags table and simply assigned tags to posts in a manyToMany relationship (i might be wrong).

I can build that no issues. What I am not sure about is the purpose of tags and how they speak about it in regards to Wordpress.

For example:

/// https://trafficgenerationcafe.com/blog-tags-seo/

As I previously mentioned, when you use tags, you instantly create new pages for your blog that are fully indexable, searchable, and rankable. In other words, you create additional content that can bring search engine visitors.

" you instantly create new pages for your blog that are fully indexable, searchable, and rankable"?!?!?!?

What is that about? Are tags used for SEO? What is the purpose of adding tags to posts the way Jeff does?

Thanks

09 Nov
3 days ago

behnampmdg3 left a reply on Where Would You Move This Code?

@snapey

How is it possible that 'PostRequest ' can access $this->user()?

07 Nov
5 days ago

behnampmdg3 started a new conversation PLEASE BRING BACK THE OLDER LARACAST DESIGN

Jeff, I love you for everything you've done so far but this site update...

The other one was so much more classy and easier to follow.

06 Nov
6 days ago

behnampmdg3 started a new conversation Issue Installing Cashier

Anyone knows what's going on here?

composer require laravel/cashier
Using version ^8.0 for laravel/cashier
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - laravel/cashier v8.0.0 requires stripe/stripe-php ~5.0 -> satisfiable by stripe/stripe-php[v5.0.0, v5.1.0, v5.1.1, v5.1.2, v5.1.3, v5.2.0, v5.2.1, v5.2.2, v5.2.3, v5.3.0, v5.4.0, v5.5.0, v5.5.1, v5.6.0, v5.7.0, v5.8.0, v5.9.0, v5.9.1, v5.9.2] but these conflict with your requirements or minimum-stability.
    - laravel/cashier 8.0.x-dev requires stripe/stripe-php ~5.0 -> satisfiable by stripe/stripe-php[v5.0.0, v5.1.0, v5.1.1, v5.1.2, v5.1.3, v5.2.0, v5.2.1, v5.2.2, v5.2.3, v5.3.0, v5.4.0, v5.5.0, v5.5.1, v5.6.0, v5.7.0, v5.8.0, v5.9.0, v5.9.1, v5.9.2] but these conflict with your requirements or minimum-stability.
    - Installation request for laravel/cashier ^8.0 -> satisfiable by laravel/cashier[8.0.x-dev, v8.0.0].


Installation failed, reverting ./composer.json to its original content.

behnampmdg3 started a new conversation How Would You Clean This Up?

It's basic stuff. Please show me how you clean this up.

Thanks

 <?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Stripe\{Stripe, Charge, Customer};

class PaymentController extends Controller
{
    public function index()
        {
            return view('payment');
        }
    public function pay(Request $request)
        {
        
      //If not stripe customer, create customer in stripe and update stripe_customer_id field in the database
      if(!auth()->user()->stripe_customer_id)
        {
          \Stripe\Stripe::setApiKey(config('services.stripe.secret'));
            $customer = Customer::create(
               ['email' => $request['stripeEmail']
               , 'source'=>$request['stripeToken']]
            );
            $stripe_customer_id = $customer->id;
            $user = auth()->user();
            $user->stripe_customer_id = $stripe_customer_id;
            $user->save();
        }  
        else 
        {
            $stripe_customer_id = auth()->user()->stripe_customer_id;
        }
        Charge::create([
            'amount'=>2500,
            'customer' => $stripe_customer_id,
            'currency' => 'usd'
        ]);
        
            return redirect('users/'.\Auth::id());
        }   
}

behnampmdg3 left a reply on Where Would You Move This Code?

Hi, @SapporoGuy

Thanks, it makes sense. I get the same feeling

This guy @Snapey seems to be one of the best in the forum.

I am going with his approach even though it doesn't make 100% sense to do CRUD in FOrRequest thingy.

behnampmdg3 started a new conversation How Do Tags Work With Search Engine?

Hey

Not much Laravel related but tags Jeff makes per post, how do they work with search engines?

04 Nov
1 week ago

behnampmdg3 started a new conversation What Is A Good Solution For One Time Payments?

Hi;

Cashier seems like a great solution for recurring billing.

What is a good solution for one time payments?

I see Jeff has archived the Stripe series.

Thanks

behnampmdg3 started a new conversation How Come Jeff Archived Stripe Series?

Hi;

How come Jeff archived Stripe series? The first video seems to work pretty smoothly.

Is there specific things that are dated now?

https://laracasts.com/series/billing-with-stripe

Thanks

31 Oct
1 week ago

behnampmdg3 left a reply on Are There Videos On Laracast To Set User Roles?

These videos seem outdated.

There is no such thing as this anymore.

php artisan  generate

behnampmdg3 left a reply on Where Would You Move This Code?

@Snapey

Hey man. I read your method and I get it.

I know you're an expert forum member. No doubt you have a point.

However, I don't understand why you're doing the "database business" in FormRequest.

I was under the impression that FormRequest is for form validation and we use model, controller or repository for database-business.

What's the deal man?

Thanks

behnampmdg3 started a new conversation Are There Videos On Laracast To Set User Roles?

If so, link, please.

Otherwise, where is a good resource (for 5.7)?

Thanks

behnampmdg3 left a reply on Where Would You Move This Code?

@cronix how do you add user_id?

$post->user_id = \Auth::user()->id;

behnampmdg3 left a reply on Where Would You Move This Code?

Cronix's idea seems like the cleanest one.

@Spporoguy why would you add a repository when you could just go like Cronix mentioned?

I don't understand why it's a good practice to add repositories.

Thanks

29 Oct
2 weeks ago

behnampmdg3 left a reply on Where Would You Move This Code?

Hi;

I know how to do it. Several ways. I am asking different user's opinions.

Jeff Teaches several ways but he doesn't make it clear which one is prefered and why.

That's why I wanna hear other's opinions.

Tanx

behnampmdg3 started a new conversation Where Would You Move This Code?

Hello;

Where would be a good place to keep this code?

A) PostController B) Post Model C) A Repository D) Somewhere else

If your answer is not A, please explain why and how.

Thank you.

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

        $post = new Post;
        $post->title = $request->title;
        $post->body = $request->body;
        $post->user_id = \Auth::user()->id;
        $post->save();
        
        return redirect('/posts');
    }

behnampmdg3 left a reply on BelongsTo Not Working!

Hi. This works

{{ $comment->post['title'] }}

Can someone explain why?

behnampmdg3 started a new conversation BelongsTo Not Working!

Very strange, I get this. What am I doing wrong?

Not getting "$comment->post->title".

Trying to get property 'title' of non-object (View: /Users/bj/codes/blog/resources/views/users/show.blade.php)
<ol>
    @forelse($user->comments as $comment)
    dd($comment);
        <li>{{ $comment->body }} <br />
            On Post {{ $comment->post->title }} On {{ $comment->created_at->diffForHumans() }}</li>
    @empty
        <p>This user has no comments</p>
    @endforelse
</ol>
<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Comment extends Model
{
    protected $fillable = ['body','user_id'];

    public function user()
        {
            return $this->belongsTo(User::class);
        }
    public function post()
        {
            return $this->belongsTo(Post::class);
        }   
}
<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

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

   public function user()
        {
            return $this->belongsTo(User::class);
        }       

public function scopeFilter($query, $request)
    {
        if($request['month'])
            {
                $query->whereMonth('created_at', date('m',strtotime($request['month'])));
            }   
        if($request['year'])
            {
                $query->whereYear('created_at', $request['year']);
            }       
    }
}
<?php

namespace App;

use Illuminate\Notifications\Notifiable;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Foundation\Auth\User as Authenticatable;

class User extends Authenticatable
{
    use Notifiable;
    protected $fillable = ['name','email','password'];

    public function posts()
        {
            return $this->hasMany('App\Post');
        }
     public function comments()
        {
            return $this->hasMany('App\Comment');
        }    
}
24 Oct
2 weeks ago

behnampmdg3 left a reply on Where Is A Beginners Tutorial For Scopes?

Hey @D9705996

No, I am a bit confused because he says

we briefly spoke about scopes in the previous episode But it's not in the serious so far.

That's why I asked, I haven't missed any of these so far but not sure what he's referring to.

There has to be a video about scopes before this.

23 Oct
3 weeks ago

behnampmdg3 started a new conversation Where Is A Beginners Tutorial For Scopes?

Hi;

In this one, Jeff starts talking about scopes with no intro it's a bit confusing.

https://laracasts.com/series/laravel-from-scratch-2017/episodes/20?autoplay=true

Can someone please link me to beginners tutorial for Scopes?

Thanks

behnampmdg3 started a new conversation How Can I Write This Query?

Hi;

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'monthname(created_at)' in 'field list' (SQL: select `monthname(created_at)` as `month`, `year(created_at)` as `year`, `COUNT(*)` as `total` from `posts`)
 DB::table('posts')->get(['monthname(created_at) AS month', 'year(created_at) AS year','COUNT(*) AS total'])->groupBy('month', 'year')->orderBy('min(created_at) DESC');
22 Oct
3 weeks ago

behnampmdg3 left a reply on Da PhUck? Weird Issue With Database Access. Ignoring .env?

@bobbybouwmann

You did! I missed it.

Thank you your replies in most threads are very helpful. Awesome work.

behnampmdg3 left a reply on Da PhUck? Weird Issue With Database Access. Ignoring .env?

OK! fount it!

In the terminal: Ctr + C, then "php artisan serve" again. Works now!

Damn, that was weird.

behnampmdg3 left a reply on Da PhUck? Weird Issue With Database Access. Ignoring .env?

I tried in a new browser, the same thing!

behnampmdg3 left a reply on Why Doesn't Jeff (Way, Not Bridges) Use UserController In Auth Tutorial?

What do you mean? Is his method bad practice? Doesn't make sense.

behnampmdg3 left a reply on Da PhUck? Weird Issue With Database Access. Ignoring .env?

Yes. Because in .env I change the DB_DATABASE to aaaaaa. Start Tinker again and

>>> App\User::all()
Illuminate/Database/QueryException with message 'SQLSTATE[HY000] [1049] Unknown database 'aaaaaa' (SQL: select * from `users`)'

I change it back to auth_project, exit and start Tinker again and I get this:

>>> App\User::all()
=> Illuminate\Database\Eloquent\Collection {#2937
     all: [
       App\User {#2938
         id: 1,
         name: "Viola Deckow",
         email: "[email protected]",
         email_verified_at: "2018-10-22 03:41:42",
         created_at: "2018-10-22 03:41:42",
         updated_at: "2018-10-22 03:41:42",
       },
       App\User {#2939
         id: 2,
         name: "Esta Schmitt",
         email: "[email protected]",
         email_verified_at: "2018-10-22 03:41:42",
         created_at: "2018-10-22 03:41:42",
         updated_at: "2018-10-22 03:41:42",
       },

These are settings for .env

APP_NAME=Laravel
APP_ENV=local
APP_KEY=base64:qy+LgqHkDP4JJxFQ307iqMLoeiDU7wPTk6nlGH0hQpE=
APP_DEBUG=true
APP_URL=http://localhost

LOG_CHANNEL=stack

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=auth_project
DB_USERNAME=root
DB_PASSWORD=

BROADCAST_DRIVER=log
CACHE_DRIVER=file
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null

PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=mt1

MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"

These are the settings for .env.example

APP_NAME=Laravel
APP_ENV=local
APP_KEY=
APP_DEBUG=true
APP_URL=http://localhost

LOG_CHANNEL=stack

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=auth_project
DB_USERNAME=root
DB_PASSWORD=

BROADCAST_DRIVER=log
CACHE_DRIVER=file
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null

PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=mt1

MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"

behnampmdg3 started a new conversation Why Doesn't Jeff (Way, Not Bridges) Use UserController In Auth Tutorial?

In this one:

https://laracasts.com/series/laravel-from-scratch-2017/episodes/19?autoplay=true

Why does ha make a new controller?

What is UserController's create and store method for?

behnampmdg3 left a reply on Da PhUck? Weird Issue With Database Access. Ignoring .env?

Never had this issue before. This is Laravel out of the box new project.

behnampmdg3 left a reply on Da PhUck? Weird Issue With Database Access. Ignoring .env?

Route::get('/test', function () {
    return env('DB_USERNAME', 'Cannot find value');
});

homestead

behnampmdg3 left a reply on Da PhUck? Weird Issue With Database Access. Ignoring .env?

"Check that your web server is pointing to the right directory"

How?

behnampmdg3 started a new conversation Weird Issue With Database Access

Tinker works fine.

In browser I get

lluminate \ Database \ QueryException (1045)
SQLSTATE[HY000] [1045] Access denied for user 'homestead'@'localhost' (using password: YES) (SQL: select * from `posts`)

routes

<?php

Auth::routes();
Route::get('/home', '[email protected]')->name('home');
Route::resource('posts', 'PostController');
Route::resource('users', 'UserController');

.env

APP_NAME=Laravel
APP_ENV=local
APP_KEY=base64:qy+LgqHkDP4JJxFQ307iqMLoeiDU7wPTk6nlGH0hQpE=
APP_DEBUG=true
APP_URL=http://localhost

LOG_CHANNEL=stack

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=auth_project
DB_USERNAME=root
DB_PASSWORD=

BROADCAST_DRIVER=log
CACHE_DRIVER=file
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null

PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=mt1

MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"

<?php

namespace App\Http\Controllers;

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

class PostController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        $posts = Post::all();
    }

    /**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function create()
    {
        //
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function store(Request $request)
    {
        //
    }

    /**
     * Display the specified resource.
     *
     * @param  \App\Post  $post
     * @return \Illuminate\Http\Response
     */
    public function show(Post $post)
    {
        //
    }

    /**
     * Show the form for editing the specified resource.
     *
     * @param  \App\Post  $post
     * @return \Illuminate\Http\Response
     */
    public function edit(Post $post)
    {
        //
    }

    /**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \App\Post  $post
     * @return \Illuminate\Http\Response
     */
    public function update(Request $request, Post $post)
    {
        //
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param  \App\Post  $post
     * @return \Illuminate\Http\Response
     */
    public function destroy(Post $post)
    {
        //
    }
}

21 Oct
3 weeks ago

behnampmdg3 left a reply on What Is This Technique Called?

@globals

What you said is gonna run X queries right? Isn;t it a bad thing to run let's say xxx queries like that?

"If you do something like this it's not gonna loop through your existing threads, it's just gonna create a new one (so you just need to create a Thread factory for it to work)."

$factory->define(App\Comment::class, function (Faker $faker) {
    return [
        'body' => $faker->sentence,
        'thread_id' => factory('App\Thread')->create()
        }
    ];
}); 

behnampmdg3 started a new conversation Is It Necessary To Make All Insert Columns Fillable?

If I want to use this style of insert

return User::create([
            'name' => $data['name'],
            'email' => $data['email'],
            'password' => Hash::make($data['password']),
        ]);

Do I have to

protected $fillable = ['name','email','password'];

In User Model?

behnampmdg3 left a reply on What Is This Technique Called?

Smart "There is a quicker way if you know the id's of the threads, and they are sequential, just generate a random number in the same range"!

behnampmdg3 started a new conversation Out Of The Box: FAILURES! Tests: 1, Assertions: 1, Failures: 1.

Hi;

phpunit tests/Feature/ExampleTest.php 
PHPUnit 7.4.1 by Sebastian Bergmann and contributors.

F                                                                   1 / 1 (100%)

Time: 161 ms, Memory: 18.00MB

There was 1 failure:

1) Tests\Feature\ExampleTest::testBasicTest
Expected status code 200 but received 404.
Failed asserting that false is true.

/Users/behnamjazayeri/codes/blog/vendor/laravel/framework/src/Illuminate/Foundation/Testing/TestResponse.php:133
/Users/bj/codes/blog/tests/Feature/ExampleTest.php:19

FAILURES!
Tests: 1, Assertions: 1, Failures: 1.

I changed APP_URL=http://127.0.0.1:8000 but didnt fix it.

20 Oct
3 weeks ago

behnampmdg3 left a reply on Is This A Correct Approach To Add Reply For Thread? It's Not In Route Resource Docs.

After going through the docs and some more OOP videos, I can't help but wonder why no one suggested using ReplyController? I am like Jesus what's up yo!

behnampmdg3 started a new conversation What Is The Current Sublime These And Color Setting?

Hi;

In Sublime 3 how can I see the currently active theme's (and color) name?

Thanks

behnampmdg3 started a new conversation What Is This Technique Called?

Hi;

1 - Is this the correct way of generating thread_id? 2 - Is this called closure? 3 - When using factories, is this gonna loop inside the query? If so isn't it bad practice?

$factory->define(App\Comment::class, function (Faker $faker) {
    return [
        'body' => $faker->sentence,
        'thread_id' => function(){
        return App\Thread::inRandomOrder()->first()->id;
        }
    ];
});

behnampmdg3 left a reply on Is This A Correct Approach To Add Reply For Thread? It's Not In Route Resource Docs.

It wasn't. Only 'body' was.

I added it this way... Is it correct?

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Reply extends Model
{
     protected $fillable = ['body','user_id'];
     
     public function Thread()
        {
            return $this->belongsTo('App\Thread');
            //return $this->hasOne('App\Thread');
        }
}
19 Oct
3 weeks ago

behnampmdg3 left a reply on Is This A Correct Approach To Add Reply For Thread? It's Not In Route Resource Docs.

Ok nice!

Now one more thing:

I am passing user_id but why do I get this?

$this->replies()->create(['body'=>$request->body,'user_id'=>1]);
SQLSTATE[HY000]: General error: 1364 Field 'user_id' doesn't have a default value (SQL: insert into `replies` (`body`, `thread_id`, `updated_at`, `created_at`) values (dfgbdf, 1, 2018-10-19 15:11:53, 2018-10-19 15:11:53))

behnampmdg3 left a reply on How Much Is A Mid-level Laravel Coder Worth Per Year?

shez

Java sounds good but I know nothing about Java. I have been with Codeigniter and PHP for years and Laravel recently.

The Laravel resources are insane I think learning it is much easier with Laracast.

Probably Java has it's own Laracast as well since it's way older than Laravel.

behnampmdg3 left a reply on Is This A Correct Approach To Add Reply For Thread? It's Not In Route Resource Docs.

tykus

What do you want to reference --parent=Thread ?

behnampmdg3 started a new conversation Is This A Correct Approach To Add Reply For Thread? It's Not In Route Resource Docs.

Hi;

Is this a correct approach to add reply for a thread? It's not in route resource docs.

Route::post('/threads/{thread}/replies', '[email protected]');
<form action="/threads/{{ $thread->id }}/replies" method="post">
            @csrf
          <div class="form-group">
            <p>Write A Reply:</p>
            <textarea class="form-control" name="body"></textarea>
          </div>
          <button type="submit" class="btn btn-primary">Submit</button>
        </form>
namespace App\Http\Controllers;

use App\Thread;
use Illuminate\Http\Request;

class ThreadController extends Controller
{
      public function addReply(Request $request, Thread $thread)
    {
        $reply = new \App\Reply;
        $reply->body = $request->body;
        $reply->thread_id = $thread->id;
        $reply->save();
        return back();
    }
}

behnampmdg3 left a reply on What Am I Doing Wrong? Arrrgggh Trying To Get Property Of Non-object

Yes thanks, everything's sweet.

The way Laravel is going by version 9 there won't be a need to code at all.

18 Oct
3 weeks ago

behnampmdg3 left a reply on Brew Update, Now Nothing Works

We are back to business. Thank you. I was not in the right directory.

What do you think is the best way I learn things like this? How did you know what to do?

With Laravel series I am making good progress with Laravel app itself. For example Queries, Models, Tinker, Validations, Artisan, OO, Eloquent, etc.

However, fixing things like what just happened, I don't feel like I m learning at all.

So what do you recommend I watch or read as a resource for terminal related subjects?

Thanks again

behnampmdg3 left a reply on Brew Update, Now Nothing Works

Php is there, but still no artisan, or Laravel command

Behnams-MacBook-Pro-2:codes bj$ php -v
PHP 7.2.11 (cli) (built: Oct 19 2018 00:27:43) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.2.11, Copyright (c) 1999-2018, by Zend Technologies
Behnams-MacBook-Pro-2:codes bj$ php artisan 
Could not open input file: artisan
Behnams-MacBook-Pro-2:codes bj$  brew services start php
==> Successfully started `php` (label: homebrew.mxcl.php)
Behnams-MacBook-Pro-2:codes bj$ php artisan 
Could not open input file: artisan
Behnams-MacBook-Pro-2:codes bj$ 

behnampmdg3 left a reply on Brew Update, Now Nothing Works

brew doctor 
Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry or file an issue; just ignore this. Thanks!

Warning: You are using macOS 10.10.
We (and Apple) do not provide support for this old version.
You will encounter build failures and other breakages.
Please create pull-requests instead of asking for help on Homebrew's
GitHub, Discourse, Twitter or IRC. As you are running this old version,
you are responsible for resolving any issues you experience.

Warning: Broken symlinks were found. Remove them with `brew prune`:
  /usr/local/etc/bash_completion.d/_brew_services


Behnams-MacBook-Pro-2:codes bj$ brew prune

Pruned 1 symbolic links and 3 directories from /usr/local

Behnams-MacBook-Pro-2:codes bj$ brew doctor 
Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry or file an issue; just ignore this. Thanks!

Warning: You are using macOS 10.10.
We (and Apple) do not provide support for this old version.
You will encounter build failures and other breakages.
Please create pull-requests instead of asking for help on Homebrew's
GitHub, Discourse, Twitter or IRC. As you are running this old version,
you are responsible for resolving any issues you experience.
Behnams-MacBook-Pro-2:codes bj$ 

I'm gonna do php now.