![]() Now, we’ll explore how to set up the Routes, Controllers, and Models to meet our goals. Rather than go into the details on how to set that up, check out the prior link, or just google around, there are a ton of examples of how to set up your application. ![]() If you would like to follow along, you’ll need to configure an application in the developer tools at Twitter to do so. If we’re going to model the relationship between Users and Tweets, then we’re going to need some to work with! For this, we will use the most excellent package provided by thujohn. } create_tweet_urls_table.php source bigInteger('tweet_id')->unsigned()->index('tweet_id') } create_tweet_tags_table.php source bigInteger('tweet_id')->unsigned()->index('tweet_id') $table->bigInteger('target_user_id')->unsigned()->index('target_user_id') Ĭreate_tweet_retweets_table.php source bigInteger('tweet_id')->unsigned()->index('tweet_id') $table->bigInteger('source_user_id')->unsigned()->index('source_user_id') $table->integer('retweet_count')->index('retweet_count') Ĭreate_tweet_mentions_table.php source bigInteger('tweet_id')->unsigned()->index('tweet_id') $table->bigInteger('twitter_id')->unsigned()->index('twitter_id') $table->dateTime('twitter_created_at')->index('twitter_created_at') } create_tweets_table.php source bigInteger('tweet_id')->unsigned()->primary() $table->string('oauth_token_secret', 150)->nullable() $table->enum('user_status', array('Active', 'Deactive'))->default('Active') $table->string('twitter_created_at', 10) $table->integer('friends_count')->nullable() $table->integer('followers_count')->nullable() $table->string('expanded_url')->nullable() $table->string('description')->nullable() $table->bigInteger('twitter_id')->unique('twitter_id') create_users_table.php source increments('id') Of course we are creating this on the most excellent Laravel Homestead which we covered in this episode. Here are the migrations to make it happen. We’ll have 6 tables in total which include users, tweet_urls, tweet_tags, tweet_retweets, tweet_mentions, and tweets. Dealing with users is quite easy, as it is just a single table. It should be a fun example.įirst off, we need a database to hold our users and tweets. In addition, we’ll have a Tweet model where we can see that an individual tweet belongsTo a User. As you can imagine, we’ll explore the concept of a User that hasMany tweets. ![]() For this example, we’ll explore the concept of a User and his or her Tweets. There are a ton of different ways to explore these relationships. In this episode, we’re going to show some love to the hasMany and belongsTo relationships that Eloquent provides. The many to many relationships tutorial here at Vegibit is always the number one or two most popular post as you can see on the right hand side of this page. Relationships, and specifically Eloquent Relationships, are a really popular feature of Laravel. The Laravel hasMany and belongsTo relationships are a fantastic feature of the framework.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |