ChungusPrime

ChungusPrime

Member Since 2 Years Ago

Experience Points 15,360
Experience Level 4

4,640 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 149
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.

06 Apr
5 months ago

ChungusPrime started a new conversation Issue With CSRF, Sessions And Private Channels

Hi All, I am currently writing an app in Laravel, and it goes like this:

When the user first accesses the app, they enter their username. A new user is then created with the username. The created user is returned and I log them in with that returned ID.

Basically, once a user is logged in I want them to be logged in forever, I do this by storing the returned ID as a localStorage variable, and then log them in using this ID when they access the site.

My app uses a lot of axios requests and uses a few events. I can create a new user and everything is fine. I come back the next day/few hours later to test again with the same user and all of my axios requests return: unknown status 419, message: " ".

I also can't authorise these users on private channels!

What can I do in this situation? I have tried increasing the session length to the max possible, but I still get the same errors.

17 Sep
1 year ago
15 Sep
1 year ago

ChungusPrime started a new conversation Help With Git

Hi all,

I am new to using GitHub and I would like to ask a question on how to use it properly.

I have a server which I currently have a web app on.

I have a GitHub repository with my laravel project in it.

I downloaded my laravel project files from GitHub onto my server using git clone in the ssh terminal.

Now, I want to do some additional work on this project and push those changes to the live server, what is the recommended way of doing this?

Will I have to run npm run production to recompile all of my assets again? Will i have to reinstall all composer dependencies again?

I'm new to this and I'd really appreciate the help with all of the general workings of Git.

Thanks for reading Nathan

10 Sep
1 year ago

ChungusPrime left a reply on Using Components Within Components

Awesome, thanks! :)

ChungusPrime started a new conversation Using Components Within Components

Hi, I am using a basic project template provided by VueCLI.

All I am trying to is create a list of components in another component.

Here is my main App.vue file:

<template>
   <div id="app">
     <BuildingList></BuildingList>
     <UpgradeList></UpgradeList>
   </div>
 </template>

 <script>
     import BuildingList from './components/BuildingList.vue'
     import UpgradeList from './components/UpgradeList.vue'

     export default {
     name: 'app',
     components: { BuildingList, UpgradeList }
   }
 </script>

This is all fine so far, here's my BuildingList component:

<template>
     <div>
        <h1>Building List</h1>
         <Building v-for="building in buildings"> {{ building.name }} - {{ building.price }}cr 
     </Building>
  </div>
 </template>

<script>
    import Building from 'Building.vue'

   export default {

    components: { Building },

   data() {

     return {

    buildings: [
      { name: 'Building 1', price: 15 },
      { name: 'Building 2', price: 120 }
     ]
     };
  }
 }

And heres' the Building.vue template

   <template>
    <div>
       <p><slot></slot></p>
     </div>
     </template>

 <script>
    export default {

    }
     </script>

I get this error when trying to run it:

Module not found: Error: Can't resolve 'Building.vue' in 'C:\Users\natha\credit-clicker\src\components'

This is my first time working with Vue and I am not sure why the template can't be found but the others can?

19 Aug
1 year ago

ChungusPrime left a reply on No Message On AJAX POST Request

Ok it's working now, apparently even though I specified a URL in the jquery post function, it was being ignored and instead was posting to nothing, hence the message

ChungusPrime left a reply on No Message On AJAX POST Request

I used php artisan route:clear, and I tested again in an incognito window, still the same error.

I had a route set up similarly before this one and that one worked fine!

ChungusPrime left a reply on No Message On AJAX POST Request

Even if I dd the request in the controller function that method still appears, so it must be a problem with the route, but there aren't any collisions?

ChungusPrime left a reply on No Message On AJAX POST Request

I've changed the request to a URL that couldn't have any collisions, simply "/buying" and I'm still get the error?

ChungusPrime left a reply on No Message On AJAX POST Request

The route is in web.php, here it is in route:list:

| | POST | items/user/buying | | App\Http\Controllers\[email protected] | web |

ChungusPrime started a new conversation No Message On AJAX POST Request

Hi, I am trying to make an AJAX post request to a url:

$('#UpdateBuying').on('click', function(e){
  e.preventDefault();
  $.post("/items/user/buying", { _token: $('input[name=_token]'), item_id: SelectedItemId, 
quantity: $("#b_quantity").val, price: $("#b_price").val, currency: $("#b_currency").val })
.done(function(response) {
  if(response == "true"){
    toastr.success('Item Buying Information Updated');
  }
});

});

Route:

Route::post('/items/user/buying', '[email protected]');

Controller Function:

 public function UpdateBuying(Request $request)
 {
   $buying = UserBuying::updateOrCreate([
     'item_id' => request('item_id'),
     'user_id' => auth()->user()->id
   ],[
     'price' => request('price'),
     'quantity' => request('quantity'),
     'currency' => request('currency')
   ]);

  if($buying){
    return response()->json("true");
  }else{
    return response()->json("false");
 }

}

When I try to make this request I get:

Symfony \ Component \ HttpKernel \ Exception \ MethodNotAllowedHttpException
No message

This is the request data as it appears on the error page:

_token  "sjQVfDM57MRFy8ITPXuDwMA0bsPt2nTR0WViCNg9"
item_id "24"
quantity    "5"
price   "5000"
currency    "Roubles"

Please can someone explain what the "No message" means?

16 Aug
1 year ago

ChungusPrime left a reply on UpdateOrCreate Will Create But Not Update

Ok I gave up, and just added the AI 'id' column.

15 Aug
1 year ago

ChungusPrime left a reply on UpdateOrCreate Will Create But Not Update

I have set the primary key's as both item_id and user_id, and set public $incrementing = false; in the model, however I still get that error

ChungusPrime left a reply on UpdateOrCreate Will Create But Not Update

Okay I have changed it to a Model instead of a Pivot, I retested and got this:

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'id' in 'where clause' (SQL: update item_user set selling_price = 3000, selling_quantity = 6, updated_at = 2018-08-15 21:00:08 where id is null)

ChungusPrime left a reply on UpdateOrCreate Will Create But Not Update

Not sure if this is helpful but here is my ItemUser Model:

namespace App;

 use Illuminate\Database\Eloquent\Relations\Pivot;

class ItemUser extends Pivot
{
       protected $table = 'item_user';
       protected $fillable = ['item_id', 'user_id', 'selling_currency', 'selling_price', 'selling_quantity', 'buying_currency', 'buying_price', 'buying_quantity'];

   public function user()
    {
      return $this->hasOne('App\User');
     }

      public function item()
     {
         return $this->hasOne('App\Item');
     }

 }

ChungusPrime left a reply on UpdateOrCreate Will Create But Not Update

if I dd the request I get this:

+request: ParameterBag {#64 ▼
#parameters: array:8 [▼
  "_token" => "Y0VwRBo2BE27qVkPdho9In7zjzroiDOGIjbYCThW"
  "item_id" => "1"
  "sellingqty" => "7"
  "sellingprice" => "2500"
  "sellingcurrency" => "Roubles"
  "buyingqty" => "3"
  "buyingprice" => "1500"
  "buyingcurrency" => "Roubles"
]

}

should i also pass the user_id in with the request?

if i echo auth()->user()->id;

it returns 1, so i think they're both there?

ChungusPrime started a new conversation UpdateOrCreate Will Create But Not Update

Hi all,

I have this function in a controller: public function UpdateItem(Request $request) { ItemUser::updateOrCreate( ['user_id' => auth()->user()->id, 'item_id' => request('item_id')], ['selling_currency' => request('sellingcurrency'),'selling_price' => request('sellingprice'),'selling_quantity' => request('sellingqty'),'buying_currency' => request('buyingcurrency'),'buying_price' => request('buyingprice'), 'buying_quantity' => request('buyingqty')] ); }

It works perfectly for creating new rows, however when I try to update I get this message:

Illuminate\Database\QueryException thrown with message "SQLSTATE[42S22]: Column not found: 1054 Unknown column '' in 'where clause' (SQL: update `item_user` set `selling_price` = 2500, `selling_quantity` = 7, `buying_price` = 1500, `buying_quantity` = 3, `updated_at` = 2018-08-15 15:22:09 where `` = 1 and `` = 1)"

It's trying to update where '' =1 and '' = 1, i assume these are the item_id and user_id, so how do I get them into the query?

Thanks!

p.s. how do I format code blocks properly?

13 Aug
1 year ago

ChungusPrime started a new conversation Routes Won't Return Data

Hi, I have a few routes:

Route::get('/items/all', '[email protected]'); Route::get('/items/{sub_category}', '[email protected]'); Route::get('/items/sub/{main_category}', '[email protected]'); Route::get('/items/main', '[email protected]'); Route::get('/items/sub', '[email protected]');

The first 3 work as intended, they all return the expected data, however the last 2 do not return anything.

Here are the controller methods: //Returns all items public function AllItems() { return Item::all(); }

//Returns all items within the specified sub category
public function CategoryItems($sub_category)
{
  return Item::all()->where('sub_category', $sub_category);
}

//Returns all sub categories within the specified main category
public function SubCategoriesByMainCategory($main_category)
{
  return Item::distinct('sub_category')->where('main_category', $main_category)->pluck('sub_category');
}

//Returns all main category names
public function MainCategories()
{
   return Item::distinct('main_category')->pluck('main_category');
}

//Returns all sub category names
public function SubCategories()
{
  return Item::distinct('sub_category')->pluck('sub_category');
}

I can't see what is wrong, and I dont understand why the last 2 work but the first 3 do.

Also, if I type item/* I get a blank page that just says [ ], rather than the expected 'page not found' page.

Please can someone tell me what I have done wrong?