mware

mware

Web Applications Analyst at Topeka Public Schools

Member Since 2 Years Ago

Topeka, KS

Experience Points
42,000
Total
Experience

3,000 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
353
Lessons
Completed
Best Reply Awards
11
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.

Level 9
42,000 XP
Nov
11
1 week ago
Activity icon

Replied to Store Image

@ain If the specific user is the person filling out the form, then you should be able to get the user's id from the auth method.


Restock::create([
    'image' => $new_name,
    'restock_user_id' => auth()->id() //or auth()->user()->id
]);

That should accomplish what you're looking for.

Activity icon

Replied to When It's Too Much

I like what @tray2 posted. This is something I will try to adapt myself in the future.

Nov
07
1 week ago
Activity icon

Replied to Displaying Only Certain Data From Database Table.

@caligirl If I understand this correctly you want something like this:

$number_delivery = Order::where('buyer_id',$user->id)->where('food_status','Delivered')->count();
                    $view->with('number_delivery',$number_delivery);

$number_delivery will now only contain the count of Orders where the buyer id matches the given user id and the food_status is 'Delivered'.

Activity icon

Replied to PHPUnit Tests Fail Sometimes

I've ran into this sometimes as well. What fixed it for me was wrapping the text you expect to see in your assertions in the e() function. This is what Blade uses to parse text in its templates.

Edit: @talinon beat me to it.

Nov
05
2 weeks ago
Activity icon

Replied to PHP Book

@talinon Thanks for the share!

Oct
28
3 weeks ago
Activity icon

Replied to Saving Different Models From Array In Controller

@kdiaz489 Give the dot notation a try. For instance if you have an array of items in $request->case_name, you could try something like this:


//$request->case_name = ['name1' => 'value1', 'name2' => 'value2']


if($request->has('case_name.name1')){

    //do some stuff

}

if($request->has('case_name.name2')){

    //do some stuff
}

Like @sinnbeck said, you don't have to use the 'elseif' conditional if you don't want. Just make sure you return something in your if statement that evaluates to true if you don't want the other if statements to run.

Activity icon

Replied to Saving Different Models From Array In Controller

Is there any logic in the Controller to detect what type of model should be created and saved? You mentioned model types Case, Kit, and Unit. Perhaps you could use the 'has' method to check the request for that model name, then create the appropriate model.


if($request->has('case_name')) {

    //create Case

}elseif($request->has('kit_name')) {

    //create Kit    

}else{

    //create unit

}

Something like that. Good luck!

Activity icon

Replied to [L5] Create 3 Columns For Cards Using Bootstrap Row Class

Try this:

@extends('layout.app')

@section('content')

<div class="row">

  <div class="col-12 text-center">
      <h2> Page caption</h2>

      <div class="row">

              <div class="col-sm-6 col-md-4">
                  <div class="card border-white">
                      <div class="card-header">Heading 1</div>
                          <div class="card-body">
                              <p class="card-text">Some quick example text to build on the card 
                              title and make up the bulk of the card's content.</p>
                          </div>
                      </div>
                  </div>
              </div>

              <div class="col-sm-6 col-md-4">
                  <div class="card border-white">
                      <div class="card-header">Heading 2</div>
                          <div class="card-body">
                              <p class="card-text">Some quick example text to build on the card 
                              title and make up the bulk of the card's content.</p>
                          </div>
                      </div>
                  </div>
              </div>

              <div class="col-sm-6 col-md-4">
                  <div class="card border-white">
                      <div class="card-header">Heading 3</div>
                          <div class="card-body">
                              <p class="card-text">Some quick example text to build on the card 
                              title and make up the bulk of the card's content.</p>
                          </div>
                      </div>
                  </div>
              </div>

    <!-- end row containing cards -->

      </div>

  <!-- end first col-12 --->
  </div>

  
<!-- end main row -->
</div>

@endsection

Oct
22
4 weeks ago
Activity icon

Replied to WYSIWYG

Trix is also an option. This is the same WYSIWYG used in this laracasts series:

https://laracasts.com/series/lets-build-a-forum-with-laravel

It also has a CDN so you don't have to download anything.

https://cdnjs.com/libraries/trix

Oct
18
1 month ago
Activity icon

Replied to Best Way To Add Messages To A Request?

@danimohamadnejad I use this package for toast messages: https://github.com/yoeunes/toastr

I has worked very well for me and is super easy to setup. Once you install the package all you have to do is add these directives in you main layout file(s): @toastr_css @toast_js @toast_render. The css directive goes in the header, the js and render should be place right before the closing body tag.

To add a message you simply use:


toastr('Whatever your success message is')

In your controller and you will get a toast message rendered when the view is loaded. You can read the docs for other styles. Good luck!

Oct
17
1 month ago
Activity icon

Replied to Storage Fake Not Asserting File Is Created

If this is the way you want to test file storage, then you will need to add some logic in your artisan command to see if your app environment is testing.


config('app.env') == 'testing' ? storage_path('framework/testing/disks/local') : 'the actual file path for your application'

Something like that.

Oct
14
1 month ago
Activity icon

Replied to Shorting The Data

Try


Account::orderBy('document_number','desc')->paginate(8);

'document_number' would be the column name in your table.

Activity icon

Replied to Get Foreign Key Details

In reverse, you can get all the university's programs like this: $university->programs.

If you want a specific program by its id, you can reference the program method on university to chain query constraints:

$university->programs()->where('id', $programId)->first()

Activity icon

Replied to Get Foreign Key Details

Assuming this is your setup:

University.php


public function programs()
{
    return $this->hasMany(Program::class);
}

Program.php


public function university()
{

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

So now lets assume you have a program stored in variable $program. You can get the university and all its details by referencing $program->university->name, $program->university->address, etc...

Oct
13
1 month ago
Activity icon

Replied to How You Would Setup A Database With Events And Their Dates?

@chrisgrim You can also use 'greater than' and 'lesser than' operators for events within a certain range

Date::where('start','>=', $startDate)
    ->where('end', '<=',$endDate)
    ->get();
Oct
12
1 month ago
Activity icon

Replied to How You Would Setup A Database With Events And Their Dates?

If you're going for one event can have many dates, this is your relationship setup:

event.php

public function dates()
    {
        return $this->hasMany(Date::class);
    }

date.php

public function event()
    {
        return $this->belongsTo(Event::class);
    }

You can then remove the 'dates_id' column from your Event migration

public function up()
    {
        Schema::create('events', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->timestamps();
        });
    }
Oct
08
1 month ago
Activity icon

Replied to Multi Select Dropdwon

@ramazan did you try my solution?

Activity icon

Replied to Multi Select Dropdwon

Try this:

public function store(Request $request)
    
    {
      foreach ($request->facility_name as  $name) {
        // code...
        $facility = new Facility;
        $facility->facility_name = $name;
        $facility->save();
      }
}
Oct
04
1 month ago
Activity icon

Replied to How Do I Loop Through This Array?

What about this:

foreach ($explodeItems['labstlfiles'] as $items) {
                            echo $items . "<br>";
                        }

or

foreach ($explodeItems->labstlfiles as $items) {
                            echo $items . "<br>";
                        }
Activity icon

Replied to Many-to-Many Attach() Backwards?

Both need to use the belongsToMany method.

User.php

public function permissions()
    {
        return $this->belongsToMany('App\Permission');
    }

Permission.php

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

https://laravel.com/docs/5.8/eloquent-relationships#many-to-many

Oct
02
1 month ago
Activity icon

Replied to Running "regular Javascript" In Vue

@wallyj you can also 'yield' your app.js (or whatever file contains your VueJs scripts) using blade's yield directive. In you main layout file you can do something like this:

main_layout.blade.php

<?php

<html>
<body>
.......


@yield('optional_js')

</body>
</html>


?>

Then wherever you want to load the additional scripts, use @section directives

some_blade_file.blade.php

<?php


@section('optional_js')

    <script src="app.js"></script>

@endsection

?>

The vue scripts will only be loaded in that blade file.

Activity icon

Replied to Laravel | Generate PDF File From Blade View. Data From Relationship Tables

Here is a way:

Page.php


public function subPageTitles()
{

    $array_string = [];
    foreach($this->subpages as $page){
        $array_string[] = $page->title;
    }
    
    return implode(', ',$array_string); ///"Title 1, Title 2, etc..."

}

PageController.php

    $title = $page->title;
        $subtitle = $page->subtitle;
        $description = $page->description;
        $subpage_title = $page->subPageTitles();
Sep
24
1 month ago
Activity icon

Replied to Pageviews On Laravel

Thanks for the snippet and explanation @snapey

Activity icon

Replied to How To I Solve This Error

@kkiragga what series are you watching?

Sep
23
1 month ago
Activity icon

Replied to Pageviews On Laravel

Is it too simple to have a view_count column on your Posts model, and each time your show method is runs, increment the view_count?

PostsController.php


public function show(Post $post)
{

    $count = $post->view_count + 1;
    $post->update([
        'view_count' => $count
    ]);
    return view(....);
}

Sep
19
2 months ago
Activity icon

Replied to Vue.JS + Laravel | How To Display The Name Taken From Other Table

Did you try loading navbars with Page query?

$page = Page::orderBy('order')->with(['videos', 'photos','navbars'])->get();

Then in your template:

<td v-if="page.navbar_id === 1">MAIN MENU</td>
            <td v-else>{{ page.navbars.name }}</td>
Sep
18
2 months ago
Activity icon

Replied to How To Run Bootstrapvue Toasts Inside Vuex Module

@mecjos Did you import the plugin in the app.js file? This is assuming you've installed bootstrap vue through npm or yarn.

app.js

import { ToastPlugin } from 'bootstrap-vue'
Vue.use(ToastPlugin)

const app = new Vue({
    el: '#application'
});

Thats an example, but something like that?

Activity icon

Replied to Error Testing With User Creation And Triggering Button Click

I could be missing something, but I think you're calling a method on $response before setting the variable.

$response->assertStatus(HTTP_RESPONSE_OK);
$response->assertSee(htmlspecialchars("Profile : Details"));

 // Error next lines triggering button click :
 $response = $this->actingAs($newUser, 'web')->json('POST', 'profile/generate-password',[ '_token'     => $csrf_token ]);

Should be:

$response = $this->actingAs($newUser, 'web')->json('POST', 'profile/generate-password',[ '_token'     => $csrf_token ]);

$response->assertStatus(HTTP_RESPONSE_OK);
$response->assertSee(htmlspecialchars("Profile : Details"));
Activity icon

Replied to Image Not Appear All In Slideshow

Try this to make sure the file is there

<div class="single-slider overlay" style="background-image:url({{asset('uploads/gallary/1568809246slider-bg1.jpg') }})">

If that works, dd($gallary->image) somewhere and make sure the string matches the expected path. If all else fails, inspect the page and look at what errors you are getting.

Sep
17
2 months ago
Activity icon

Replied to Array To String Conversion Feature Test

I'm referring to

$attributes = [ 'format:date' => [
            'key' => 'format:date',
            'value' => settings('format:date')
        ]];

Typically the $attributes array would look like this

$attributes = [
            'key' => 'format:date',
            'value' => settings('format:date')
        ];

If the store method is expecting an array that is only one layer deep, but your sending an array that is two layers deep, then you would get that error because its expecting the value to be a string, but your passing another array.

Activity icon

Replied to Array To String Conversion Feature Test

Could the issue be with the $attributes variable? Does the controller that handles the post method expect an array within an array - or just a normal array?

Activity icon

Replied to Snake_case Or CamelCase

hahaha, the first link at the top of a google search for 'laravel camelcase or snake case' is this thread

Activity icon

Replied to Sluggable Posts Appears More Than Once

Okay, so with that dd() in your controller, you should get an empty page when you don't provide a tag in the link. Is that what you're getting?

Activity icon

Replied to Sluggable Posts Appears More Than Once

Theres a few things going on here. Maybe its a typo, but hopefully Tags.php is actually Tag.php. And then you can try this for your relationships:

News.php


public function tags(){
    return $this->belongsToMany(Tag::class, 'news_tag');

}

Tags.php

public function news(){
    return $this->belongsToMany(News::class, 'news_tag');

}
Activity icon

Replied to Sluggable Posts Appears More Than Once

Did you define the pivot table name on the News and Tag models? It may be looking for a new_tag table. The documentation refers to a role_user table for a many-to-many relationship for roles and users.

Activity icon

Replied to Sluggable Posts Appears More Than Once

Is there a model observer on News that fires when news is created? It's sounds like the attach method is being called twice? Just throwing out thoughts as to why this is happening.

Activity icon

Replied to Sluggable Posts Appears More Than Once

Instead of creating the news will the all the request data, try creating it with just the data you need and see if thats where the duplication is happening.

$news=auth()->user()->news()->create($request->except(['tags']));
Sep
16
2 months ago
Activity icon

Replied to Protected Fillable Not Working With Vue Axios Patch

@chrisgrim If you have a test suite, you can create a new test and just dd(new Information). If you don't have a test suite, you might still have the empty default tests that ship with Laravel. You can add the dump to one of those tests and see what you get in the console.

tests/Unit/ExampleTest.php

public function testBasicTest()
{
    dd(new Information);
}
Sep
13
2 months ago
Activity icon

Replied to Pop Up Message For Incomplete Data Entry

@ain I try to put this code in my main layout file(s). That way I don't have to worry about putting this code on every page that needs validation error messages. Also, I like putting this code in a blade partial. Here is an example using bootstrap framework.

@if(count($errors)>0)

    <div class='alert alert-danger'>

        @foreach($errors->all() as $error)

        <li>{{$error}}</li>

        @endforeach

    </div>

@endif
Sep
09
2 months ago
Activity icon

Replied to Axios Patch Issue When Updating Model

Just so you know in your routes file, you have to specify the type of request the endpoint should accept. Patch will work fine as long as you specify that in your web.php file - or whatever file your using for routes.

Route::post('/endpoint_for_post_data');
Route::patch('/endpoint_for_patch_data');
Route::get('...')
Sep
08
2 months ago
Activity icon

Replied to Install 5.8 Instead Of 6

composer create-project --prefer-dist laravel/laravel projectName 5.8.*
Sep
06
2 months ago
Activity icon

Replied to Problem With Upadating Image On Controller

Try using the move method like this:


$request->file('photo')->move('images')

or


request('photo')->move('images')


Activity icon

Replied to Problem With Upadating Image On Controller

What do you get when run


dd($request->file('photo')->store('image'));

Don't forget to set your enctype to multi-part on the form


<form action="..." method="post" enctype="multipart/form-data">

Aug
30
2 months ago
Activity icon

Replied to Auto Generate Routes With The Controller

@randy_johnson yep. You can check your available routes by running

php artisan route:list

The output from that command should display all of your resource routes, and well as any other routes you have defined in the routes file.

Activity icon

Replied to Passing Data To Partial.sidebar

I don't think you need a view composer for this. It looks like the information that you want to display on your sidebar will differ depending on what company your looking at. If I were you I would use relationships and fetch the data in the controller.

Aug
27
2 months ago
Activity icon

Replied to Retrieve Id From Another Controller Than Put It In View

class OrdersController extends Controller
{

    public function myFunction(Request $request)
    {
        $order_id = $request('order_id'); //or however you retrieve order_id
        return view('OrderDetail',['order_id' => $order_id]) //or compact('order_id')
    }

}

then in OrderDetail.blade.php


<input type="text" name="name" value="{{ $order_id }}"> //or whatever you want to do with order_id

Aug
26
2 months ago
Activity icon

Replied to Duplicate Entry Issue With UpdateOrCreate

Should you be using $event->organizer() as opposed to $event->organizers() - plural?

Aug
15
3 months ago
Activity icon

Replied to OOP Bootcamp - Lesson 5

Have you tried setting the Staff constructor to public to see if that fixes the problem?

Activity icon

Replied to Storage::assertMissing Failing; File Is Actually Gone In Real Life

I would extract a method for the actual removal of the file. In that method I would check the environment configuration and then act accordingly. Something like this:


public function destroy(Studio $studio)
{
    $this->deleteFile($studio->logo);
    ....
}

public function deleteFile($logo)
{

    config('app.env') == 'testing' 
       ? unlink(storage_path("framework/testing/disks/digitalocean/{$logo}"))
        : Storage::disk('digitalocean')->delete($logo);
}

This should get your test to green.

Edit: for clarification, when you call Storage::fake('digitalocean'), Laravel creates a directory at storage_path("framework/testing/disks/digitalocean"). This is where your 'fake' files are going. So when you hit your destroy method you have to specify that you want to delete your file from the fake disk, and not the actual 'digitalocean' disk.

Activity icon

Replied to RefreshDatabase Not Rolling Back The Transaction After Running Test

Try using 'DatabaseTransactions'.

    use DatabaseTransactions;

Also, is there a reason why you are setting your testing database connection in the phpunit.xml file?