tenzan

tenzan

Member Since 3 Years Ago

Experience Points 1,110
Experience Level 1

3,890 experience to go until the next level!

In case you were wondering, you earn Laracasts experience when you:

  • Complete a lesson — 100pts
  • Create a forum thread — 50pts
  • Reply to a thread — 10pts
  • Leave a reply that is liked — 50pts
  • Receive a "Best Reply" award — 500pts
Lessons Completed 0
Lessons
Completed
Best Reply Awards 0
Best Reply
Awards
  • start-engines Created with Sketch.

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • first-thousand Created with Sketch.

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • 1-year Created with Sketch.

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • 2-years Created with Sketch.

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • 3-years Created with Sketch.

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • 4-years Created with Sketch.

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • 5-years Created with Sketch.

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • school-session Created with Sketch.

    School In Session

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

  • welcome-newcomer Created with Sketch.

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • full-time-student Created with Sketch.

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • pay-it-forward Created with Sketch.

    Pay It Forward

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

  • subscriber-token Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer-token Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • lara-evanghelist Created with Sketch.

    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 Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

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

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

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

25 May
1 year ago

tenzan started a new conversation Composer Global Require "laravel/installer" Issue

Hello!

I'm getting errors below when I try composer global require "laravel/installer". It seems, there have been alike issues, but I couldn't solution...

➜ ~ composer global require "laravel/installer" Changed current directory to /Users/askar/.composer Using version ^2.0 for laravel/installer ./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 - Conclusion: don't install laravel/installer v2.0.1 - Conclusion: remove guzzlehttp/guzzle 5.3.2 - Installation request for laravel/installer ^2.0 -> satisfiable by laravel/installer[v2.0.0, v2.0.1]. - Conclusion: don't install guzzlehttp/guzzle 5.3.2 - laravel/installer v2.0.0 requires guzzlehttp/guzzle ~6.0 -> satisfiable by guzzlehttp/guzzle[6.0.0, 6.0.1, 6.0.2, 6.1.0, 6.1.1, 6.2.0, 6.2.1, 6.2.2, 6.2.3, 6.3. 0, 6.3.1, 6.3.2, 6.3.3]. - Can only install one of: guzzlehttp/guzzle[6.0.0, 5.3.2]. - Can only install one of: guzzlehttp/guzzle[6.0.1, 5.3.2]. - Can only install one of: guzzlehttp/guzzle[6.0.2, 5.3.2]. - Can only install one of: guzzlehttp/guzzle[6.1.0, 5.3.2]. - Can only install one of: guzzlehttp/guzzle[6.1.1, 5.3.2]. - Can only install one of: guzzlehttp/guzzle[6.2.0, 5.3.2]. - Can only install one of: guzzlehttp/guzzle[6.2.1, 5.3.2]. - Can only install one of: guzzlehttp/guzzle[6.2.2, 5.3.2]. - Can only install one of: guzzlehttp/guzzle[6.2.3, 5.3.2]. - Can only install one of: guzzlehttp/guzzle[6.3.0, 5.3.2]. - Can only install one of: guzzlehttp/guzzle[6.3.1, 5.3.2]. - Can only install one of: guzzlehttp/guzzle[6.3.2, 5.3.2]. - Can only install one of: guzzlehttp/guzzle[6.3.3, 5.3.2]. - Installation request for guzzlehttp/guzzle (locked at 5.3.2) -> satisfiable by guzzlehttp/guzzle[5.3.2].

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

08 Feb
3 years ago

tenzan left a reply on Accessing A Particular Post

@Devmaurice

Make sure /post/{{$post->id}} to match your route url

Should't be /posts/ in plural ?

tenzan left a reply on Accessing A Particular Post

@Reached

return $id gives:

{
id: 1,
user_id: 1,
title: "test",
body: "sdafsdfa asdfa sd",
created_at: "2016-02-08 06:22:42",
updated_at: "2016-02-08 06:22:42"
}

@Devmaurice where should I place that snippet?

tenzan left a reply on Accessing A Particular Post

@Devmaurice $post = Post::findOrFail(1); worked! :)

Post {#187 ▼
  #fillable: array:2 [▼
    0 => "title"
    1 => "body"
  ]
  #connection: null
  #table: null
  #primaryKey: "id"
  #perPage: 15
  +incrementing: true
  +timestamps: true
  #attributes: array:6 [▼
    "id" => 1
    "user_id" => 1
    "title" => "test"
    "body" => "sdafsdfa asdfa sd"
    "created_at" => "2016-02-08 06:22:42"
    "updated_at" => "2016-02-08 06:22:42"
  ]
  #original: array:6 [▶]
  #relations: []
  #hidden: []
  #visible: []
  #appends: []
  #guarded: array:1 [▶]
  #dates: []
  #dateFormat: null
  #casts: []
  #touches: []
  #observables: []
  #with: []
  #morphClass: null
  +exists: true
  +wasRecentlyCreated: false
}

tenzan left a reply on Accessing A Particular Post

@Devmaurice

mysql> select * from posts;
+----+---------+-------+-------------------+---------------------+---------------------+
| id | user_id | title | body              | created_at          | updated_at          |
+----+---------+-------+-------------------+---------------------+---------------------+
|  1 |       1 | test  | sdafsdfa asdfa sd | 2016-02-08 06:22:42 | 2016-02-08 06:22:42 |
+----+---------+-------+-------------------+---------------------+---------------------+
1 row in set (0.00 sec)

@mandravinus I have an _id column, and the migration is:

<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreatePostsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('posts', function (Blueprint $table) {
            $table->increments('id');
            $table->integer('user_id')->index();
            $table->string('title');
            $table->text('body');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::drop('posts');
    }
}

tenzan left a reply on Accessing A Particular Post

@Devmaurice but I have the model Post under the app folder...

And in composer.json I have:

  "autoload": {
    "classmap": [
      "database"
    ],
    "psr-4": {
      "App\\": "app/"
    }
  },

tenzan left a reply on Accessing A Particular Post

@Devmaurice I got this error:

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

2/2
NotFoundHttpException in Handler.php line 46:
No query results for model [App\Post].
in Handler.php line 46
at Handler->render(object(Request), object(ModelNotFoundException)) in Pipeline.php line 80
at Pipeline->handleException(object(Request), object(ModelNotFoundException)) in Pipeline.php line 54
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in Authenticate.php line 45
at Authenticate->handle(object(Request), object(Closure))
at call_user_func_array(array(object(Authenticate), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
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 Pipeline.php line 103
at Pipeline->then(object(Closure)) in ControllerDispatcher.php line 96
at ControllerDispatcher->callWithinStack(object(PostController), object(Route), object(Request), 'show') in ControllerDispatcher.php line 54
at ControllerDispatcher->dispatch(object(Route), object(Request), 'App\Http\Controllers\PostController', 'show') in Route.php line 174
at Route->runController(object(Request)) in Route.php line 140
at Route->run(object(Request)) in Router.php line 703
at Router->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 52
at Pipeline->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103
at Pipeline->then(object(Closure)) in Router.php line 705
at Router->runRouteWithinStack(object(Route), object(Request)) in Router.php line 678
at Router->dispatchToRoute(object(Request)) in Router.php line 654
at Router->dispatch(object(Request)) in Kernel.php line 246
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 VerifyCsrfToken.php line 64
at VerifyCsrfToken->handle(object(Request), object(Closure))
at call_user_func_array(array(object(VerifyCsrfToken), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
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 ShareErrorsFromSession.php line 49
at ShareErrorsFromSession->handle(object(Request), object(Closure))
at call_user_func_array(array(object(ShareErrorsFromSession), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
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 StartSession.php line 62
at StartSession->handle(object(Request), object(Closure))
at call_user_func_array(array(object(StartSession), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
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 AddQueuedCookiesToResponse.php line 37
at AddQueuedCookiesToResponse->handle(object(Request), object(Closure))
at call_user_func_array(array(object(AddQueuedCookiesToResponse), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
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 EncryptCookies.php line 59
at EncryptCookies->handle(object(Request), object(Closure))
at call_user_func_array(array(object(EncryptCookies), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
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 CheckForMaintenanceMode.php line 44
at CheckForMaintenanceMode->handle(object(Request), object(Closure))
at call_user_func_array(array(object(CheckForMaintenanceMode), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
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 Pipeline.php line 103
at Pipeline->then(object(Closure)) in Kernel.php line 132
at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 99
at Kernel->handle(object(Request)) in index.php line 54
at require_once('/Users/askar/IdeaProjects/laravel5-blog/public/index.php') in server.php line 21
1/2
ModelNotFoundException in Builder.php line 196:
No query results for model [App\Post].
in Builder.php line 196
at Builder->findOrFail(object(Post))
at call_user_func_array(array(object(Builder), 'findOrFail'), array(object(Post))) in Model.php line 3551
at Model->__call('findOrFail', array(object(Post)))
at Post->findOrFail(object(Post))
at call_user_func_array(array(object(Post), 'findOrFail'), array(object(Post))) in Model.php line 3565
at Model::__callStatic('findOrFail', array(object(Post))) in PostController.php line 74
at Post::findOrFail(object(Post)) in PostController.php line 74
at PostController->show(object(Post))
at call_user_func_array(array(object(PostController), 'show'), array('post' => object(Post))) in Controller.php line 76
at Controller->callAction('show', array('post' => object(Post))) in ControllerDispatcher.php line 146
at ControllerDispatcher->call(object(PostController), object(Route), 'show') in ControllerDispatcher.php line 94
at ControllerDispatcher->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 52
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in Authenticate.php line 45
at Authenticate->handle(object(Request), object(Closure))
at call_user_func_array(array(object(Authenticate), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
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 Pipeline.php line 103
at Pipeline->then(object(Closure)) in ControllerDispatcher.php line 96
at ControllerDispatcher->callWithinStack(object(PostController), object(Route), object(Request), 'show') in ControllerDispatcher.php line 54
at ControllerDispatcher->dispatch(object(Route), object(Request), 'App\Http\Controllers\PostController', 'show') in Route.php line 174
at Route->runController(object(Request)) in Route.php line 140
at Route->run(object(Request)) in Router.php line 703
at Router->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 52
at Pipeline->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103
at Pipeline->then(object(Closure)) in Router.php line 705
at Router->runRouteWithinStack(object(Route), object(Request)) in Router.php line 678
at Router->dispatchToRoute(object(Request)) in Router.php line 654
at Router->dispatch(object(Request)) in Kernel.php line 246
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 VerifyCsrfToken.php line 64
at VerifyCsrfToken->handle(object(Request), object(Closure))
at call_user_func_array(array(object(VerifyCsrfToken), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
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 ShareErrorsFromSession.php line 49
at ShareErrorsFromSession->handle(object(Request), object(Closure))
at call_user_func_array(array(object(ShareErrorsFromSession), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
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 StartSession.php line 62
at StartSession->handle(object(Request), object(Closure))
at call_user_func_array(array(object(StartSession), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
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 AddQueuedCookiesToResponse.php line 37
at AddQueuedCookiesToResponse->handle(object(Request), object(Closure))
at call_user_func_array(array(object(AddQueuedCookiesToResponse), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
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 EncryptCookies.php line 59
at EncryptCookies->handle(object(Request), object(Closure))
at call_user_func_array(array(object(EncryptCookies), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
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 CheckForMaintenanceMode.php line 44
at CheckForMaintenanceMode->handle(object(Request), object(Closure))
at call_user_func_array(array(object(CheckForMaintenanceMode), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
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 Pipeline.php line 103
at Pipeline->then(object(Closure)) in Kernel.php line 132
at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 99
at Kernel->handle(object(Request)) in index.php line 54
at require_once('/Users/askar/IdeaProjects/laravel5-blog/public/index.php') in server.php line 21

tenzan left a reply on Accessing A Particular Post

@mandravinus Yes. You can see it in my github repo.

tenzan left a reply on Accessing A Particular Post

I'm using IntelliJ, and it's showing me message Method find not found in class App\Post, so it seems find method's not working

tenzan left a reply on Accessing A Particular Post

@Reached Thanks for pointing that out.

I've changed in routes.php as Route::get('/posts/{post}', 'PostController@show');, i.e. in plural.

So, when I did dd($post) as @Devmaurice showed, it gave me null on the browser...

tenzan left a reply on Accessing A Particular Post

@Devmaurice I tried your snippet, but still error.

I have updated my repo, so you can look at what I have at the moment https://github.com/tenzan/laravel5-blog

Errors when I access http://localhost:8888/posts/1/:

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

1/1
NotFoundHttpException in RouteCollection.php line 161:
in RouteCollection.php line 161
at RouteCollection->match(object(Request)) in Router.php line 802
at Router->findRoute(object(Request)) in Router.php line 670
at Router->dispatchToRoute(object(Request)) in Router.php line 654
at Router->dispatch(object(Request)) in Kernel.php line 246
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 VerifyCsrfToken.php line 64
at VerifyCsrfToken->handle(object(Request), object(Closure))
at call_user_func_array(array(object(VerifyCsrfToken), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
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 ShareErrorsFromSession.php line 49
at ShareErrorsFromSession->handle(object(Request), object(Closure))
at call_user_func_array(array(object(ShareErrorsFromSession), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
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 StartSession.php line 62
at StartSession->handle(object(Request), object(Closure))
at call_user_func_array(array(object(StartSession), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
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 AddQueuedCookiesToResponse.php line 37
at AddQueuedCookiesToResponse->handle(object(Request), object(Closure))
at call_user_func_array(array(object(AddQueuedCookiesToResponse), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
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 EncryptCookies.php line 59
at EncryptCookies->handle(object(Request), object(Closure))
at call_user_func_array(array(object(EncryptCookies), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
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 CheckForMaintenanceMode.php line 44
at CheckForMaintenanceMode->handle(object(Request), object(Closure))
at call_user_func_array(array(object(CheckForMaintenanceMode), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
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 Pipeline.php line 103
at Pipeline->then(object(Closure)) in Kernel.php line 132
at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 99
at Kernel->handle(object(Request)) in index.php line 54
at require_once('/Users/askar/IdeaProjects/laravel5-blog/public/index.php') in server.php line 21

I have confirmed, I have a post with id=1

tenzan left a reply on Accessing A Particular Post

@Ruffles Thanks for reply. May I know the reason you used @stop instead of @endsection ?

I'm unable to retrieve a single post, it's giving error.

I guess, something wrong with PostController. Here https://laravel.com/docs/5.2/eloquent#retrieving-single-models it's showing how to retrieve a single model:

// Retrieve a model by its primary key...
$flight = App\Flight::find(1);

I assume, it's ok to omit the App\ part, I already have use App\Post; in the top of the controller.

My modified PostContoller@show looks now as:

    public function show($id)
    {
        $post = Post::find($id);
        return view('post.show')->with('post', $post);
    }

But this didn't solve the issue...

tenzan started a new conversation Accessing A Particular Post

Here's my repo https://github.com/tenzan/laravel5-blog which is a fork of https://laravel.com/docs/5.2/quickstart-intermediate with my own extension and refactoring Task to Post.

  1. All posts posted via login.
  2. All posts shown after login and only posts for that specific user.

Now, to implement a single view for a particular post, I added:

  1. in PostContoller.php (I'm sure I did it wrong):
    public function show($id)
    {
        $post = Post::find($id);
        return view('show')->with('post', $post);
    }
  1. created but not yet filled with the code yet for a single post view/show: show.blade.php

  2. in routes.php added:

Route::get('/post/{post}', 'PostController@show');

Can you please show any good tutorial on this?

07 Feb
3 years ago

tenzan left a reply on Model With 2 Fields

Just figured our adding body field will look protected $fillable = ['title', 'body'];

tenzan started a new conversation Model With 2 Fields

I'm going to add a second field body for the Post model which currently looks like:

<?php namespace App;

use App\User;
use Illuminate\Database\Eloquent\Model;

class Post extends Model
{
    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = ['title'];

    /**
     * Get the user that owns the post.
     */
    public function user()
    {
        return $this->belongsTo(User::class);
    }
}

The 1st field is protected $fillable = ['title'];, but when I add second field will the below look correct?

protected $fillable1 = ['title'];
protected $fillable2 = ['body'];

This basically not giving me error, but when the variable $fillable1 and $fillable2 is used? I don't see it's being invoked somewhere else in the Model...

04 Feb
3 years ago

tenzan left a reply on Routes Not Working

@Hamelraj At home, I've just tried https://github.com/laravel/quickstart-intermediate and it worked. So, this is not about that I have to specify laravel-blog. Tomorrow I will compare my code with the original one.

tenzan left a reply on Routes Not Working

@Hamelraj Hi. I'm away from computer now. I will update as soon as try. Thanks for your time. ;)

tenzan left a reply on Routes Not Working

@Hamelraj either didn't work

Why do you think I should put yourprojectname ? Where in my code is this?

tenzan left a reply on Routes Not Working

For example, when I access http://localhost:8000/register the error:

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

1/1
NotFoundHttpException in RouteCollection.php line 161:
in RouteCollection.php line 161
at RouteCollection->match(object(Request)) in Router.php line 802
at Router->findRoute(object(Request)) in Router.php line 670
at Router->dispatchToRoute(object(Request)) in Router.php line 654
at Router->dispatch(object(Request)) in Kernel.php line 246
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 CheckForMaintenanceMode.php line 44
at CheckForMaintenanceMode->handle(object(Request), object(Closure))
at call_user_func_array(array(object(CheckForMaintenanceMode), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
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 Pipeline.php line 103
at Pipeline->then(object(Closure)) in Kernel.php line 132
at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 99
at Kernel->handle(object(Request)) in index.php line 54
at require_once('/Users/askar/work/laravel/blog/public/index.php') in server.php line 21

tenzan started a new conversation Routes Not Working

Here's my repo https://github.com/tenzan/laravel-blog which was made by reading https://laravel.com/docs/5.2/quickstart-intermediate - the only difference, in my repo Post is Task in the tutorial.

No matter what I click, it's giving me error. Only root page is fine.

01 Feb
3 years ago

tenzan started a new conversation Models Directory

https://laravel.com/docs/5.2/eloquent#eloquent-model-conventions says:

Models typically live in the app directory, but you are free to place them anywhere that can be auto-loaded according to your composer.json

Where exactly is this placed in composer.json?

I have this

  "autoload": {
        "classmap": [
            "database"
        ],
        "psr-4": {
            "App\\": "app/"
        }
    },

but it's not giving me any idea...

tenzan started a new conversation Schema And Controller Auto-generation When Using Existing DB

I was able to generate models using the existing database following http://packalyst.com/packages/package/ignasbernotas/laravel-model-generator

Actually I'm trying to adapt https://github.com/neomerx/limoncello-collins to my app.

Is there a way to auto-generate Schemas and Controllers from the existing DB, or this is what I'll have to make manually?

29 Jan
3 years ago

tenzan left a reply on Easy Way To Check If Laravel App Has Connection With Existing MySQL DB

@TerrePorter

Either way is fine. Just want to see info that shows if connections established or not...

tenzan left a reply on Easy Way To Check If Laravel App Has Connection With Existing MySQL DB

@TerrePorter Hi!

For the option #1, where should I paste this code?

As for the option #2, it has comment in SO, that that solution is for Laravel 4...

28 Jan
3 years ago

tenzan started a new conversation Easy Way To Check If Laravel App Has Connection With Existing MySQL DB

I'm going to use an existing MySQL database and have setup in config/database.php :

  'connections' => [

        'mysql' => [
            'driver'    => 'mysql',
            'host'      => env('DB_HOST', 'localhost'),
            'database'  => env('DB_DATABASE', 'my-existing-db'),
            'username'  => env('DB_USERNAME', 'root'),
            'password'  => env('DB_PASSWORD', 'root'),
            'charset'   => 'utf8',
            'collation' => 'utf8_unicode_ci',
            'prefix'    => '',
            'strict'    => false,
        ],

    ],

Now I need to check if it's able to connect. What's the easiest way?

For example, in Rails it will throw error during server startup if you have any incorrect information on settings.

tenzan started a new conversation ORM To Use An Existing MySQL DB

I'll have to use existing MySQL DB in Laravel.

Is Eloquent ORM ok for that? I did some googling and there was one post stating Eloquent might be not a good fit...

What are the criterions or how can I check what ORM is fit for my existing DB?

tenzan left a reply on Listing Up All Tables From DB

@tykus_ikus Hi,

I'm aware about DB::select('SHOW TABLES');, but I was asking the whole code.

Just placing the above into resources/views/tables.php, won't list me up the tables list, right? ;)

tenzan started a new conversation Listing Up All Tables From DB

In app/Http/routes.php:

Route::get('/tables', function () {
    return view('tables');
});

In resources/views/ I've created tables.phpI added:

<?php

namespace App\Http\Controllers;

use DB;
use App\Http\Controllers\Controller;

class UserController extends Controller
{
    public function index()
    {
        $tables = DB::select('SHOW TABLES');

        foreach ($tables as $table) {
           return view ($table.name);
        }
    }
}

I believe I'm making a trivial mistake here...

tenzan left a reply on How To Change Default MySQL Password In Homestead

Adding the following line in Vagrantfile in the bottom of the

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
   <other stuff 0>
   ...
   <other stuff N>
   config.vm.provision "shell", inline: "mysqladmin -uroot -psecret password root"
end

sets the root password to be root:

tenzan left a reply on How To Change Default MySQL Password In Homestead

Sometimes, when something goes wrong with vagrant, I will need to rebuild.

tenzan left a reply on How To Change Default MySQL Password In Homestead

But doing it every time manually when I re-run vagrant up (after vagrant destroy --force) is cumbersome. Will try to see how to automate it.

tenzan left a reply on How To Change Default MySQL Password In Homestead

@bobbybouwmann Hi!

I'm not changing for the host machine, but for the vagrant VM's mysql. I feel like one solution would be to provide with the provision script that will run after vagrant VM is up, but as mysql password for homestead is secret (at some point), I wondered there would be a way to replace it manually with root. Just can't find where is it...

27 Jan
3 years ago

tenzan started a new conversation How To Change Default MySQL Password In Homestead

I've installed Homestead into existing laravel project by running:

  1. composer require laravel/homestead --dev
  2. php vendor/bin/homestead make

Then I changed MySQL password from secret to root in the .env file.

But after I have run vagrant up and entered the vagrant shell, I noticed it's still secret.

Where can I change the default MySQL password in settings?

tenzan left a reply on How Homestead Was Created

@bobbybouwmann But I don't see the script that installs MySQL, Nginx, etc...

tenzan started a new conversation How Homestead Was Created

Is there any publicly available the details on how homestead was created?

Provision scripts, etc...

26 Jan
3 years ago

tenzan started a new conversation Is Homestead Only For A Dev Env?

Is Homestead convenient only to fire up a development environment?

Or can I use it for deployment in production with production-only related stuff?

tenzan started a new conversation Homestead Per Project Installation

Here https://laravel.com/docs/5.2/homestead it says:

To install Homestead directly into your project, require it using Composer: composer require laravel/homestead --dev

Questions:

  1. By project, is it meant a virtualbox project or not only?
  2. Let's say I have an existing project laravel-project, does it mean I will have to first cd laravel-project before running composer require laravel/homestead --dev?

tenzan left a reply on Adding Laravel Project To Already Existing Virtualbox/vagrant VM

Yes, the current app is not laravel-based. I'll try this and get back once finish.

tenzan started a new conversation Adding Laravel Project To Already Existing Virtualbox/vagrant VM

Hello!

I'm trying to add a laravel project to already existing virtualbox/vagrant VM. Existing app can be accessed at http://10.20.300.100, so I want to add a new laravel based project so that I can access it at http://10.20.300.100/api. As you noticed, I'm going to use laravel as an API backend. Yes, I'm aware that lumen is best for this purpose as it get rids off all necessary code. But for now, I want to see how it works with laravel and move to lumen only once I have laravel based app working. I will also need to use same mysql app within from a virtualbox/vagrant VM. Can you please point out any resources to start from? Homestead is for starting a new laravel app. The main things I will deal with, I guess, are:

  1. Shared folders
  2. Nginx configuration
  3. Running a laravel app within from a VM, rather than out of it?

Thanks.