jbowman99

jbowman99

Member Since 3 Years Ago

Champaign, IL, USA

Web Developer at The News-Gazette

Experience Points 30,440
Experience Level 7

4,560 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 5
Best Reply
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.

24 Aug
1 year ago

jbowman99 left a reply on Trying To Send Array Of Id's In An Email

figured it out.

$vdids = Job::yesterday()->pluck('vdid')->toArray();

        $data = ['vdids' => $vdids, 'date' => date("m.d.y") ];

jbowman99 started a new conversation Trying To Send Array Of Id's In An Email

i have an array of id's that i need to send out daily in an email.

$vdids = Job::yesterday()->pluck('vdid')->toArray();

not sure how to do this in

Mail::send('emails.imported', $vdids, function($message)
        {
            $message->to('[email protected]', 'Job App')->subject('imported jobs');
        });

when trying to access this array in the email template it throws an error. how do i send this array to the template and foreach over the values in order to send the list to an email address?

10 Aug
1 year ago

jbowman99 left a reply on Routing Issues

@thomaskim

thank you! I knew it was going to be a route ordering issue, just didn't know exactly how to do what i needed to do.

09 Aug
1 year ago

jbowman99 left a reply on Routing Issues

@thomaskim @jestins

this turned out to be a package i am using issue. Laravel Backpack. so the route /admin/dashboard is being created with the package, anything i put in the routes.php files are conflicting with these package routes.

08 Aug
1 year ago

jbowman99 started a new conversation Routing Issues

Almost Lunch time!!, where I am at least.

I have a route:

Route::get('/{issue_title}/{story_title}', '[email protected]')->name('story');

that's conflicting with my admin.php routes file. which when trying to find

/admin/dashboard

error's out like its trying to find {admin}/{dashboard}

not sure how to get around this issue.

18 Jul
1 year ago

jbowman99 started a new conversation Upgrading From 5.1 To 5.2 Fatal Error

I am updating from 5.1 to 5.2, and was following along in the upgrade docs, bindShared has been changed to singleton in the illuminate/html/HtmlServiceProvider which i have changed. I have also commented out the Illuminate\Html\HtmlServiceProvider::class, in the config/app.php file

I want to upgrade to laravelcollective so i removed illuminate\html from the composer.json and replaced it with "laravelcollective/html": "5.2.*",

when i run composer update this error continues to be thrown

 [Symfony\Component\Debug\Exception\FatalThrowableError]
  Call to undefined method Illuminate\Foundation\Application::bindShared()

how do i get around that? still need to take this app to 5.4 and i can't get past 5.2 update

14 Jul
1 year ago

jbowman99 started a new conversation Most Efficient Way To Get Data Sets

I need to get several data sets from a pair of table. Table 1 will be updated every 15 minutes Table 2 will be what my api uses to show data outward.

table 1 will be what needs to be currently active -- table 2 will have all of the subsequent data attached to the active list --

I need to fetch -- whats new in table 1 that does not exist in table 2 what exists in both table 1 and table 2 and what is in table 2 and not in table 1

each table will have an id that can be matched in both tables

should I join sets, intersect arrays, array_diff. beginning with a few thousand entries climbing to hundreds of thousands of entries

05 Jul
1 year ago

jbowman99 left a reply on NPM Run Dev Errors

@PaulClarke

updated dev script and laravel-mix version

new error's

> @ dev /home/vagrant/Code/forum
> cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js

sh: 1: cross-env: not found
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! @ dev: `cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the @ dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/vagrant/.npm/_logs/2017-07-05T14_14_09_633Z-debug.log


03 Jul
1 year ago

jbowman99 left a reply on NPM Run Dev Errors

@PaulClarke

my package.json file looks like this right now

"private": true,
  "scripts": {
    "dev": "node node_modules/cross-env/dist/bin/cross-env.js NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
    "watch": "node node_modules/cross-env/dist/bin/cross-env.js NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
    "watch-poll": "node node_modules/cross-env/dist/bin/cross-env.js NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --watch-poll --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
    "hot": "node node_modules/cross-env/dist/bin/cross-env.js NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js",
    "production": "node node_modules/cross-env/dist/bin/cross-env.js NODE_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
  },
  "devDependencies": {
    "axios": "^0.16.2",
    "bootstrap-sass": "^3.3.7",
    "cross-env": "^5.0.1",
    "jquery": "^3.1.1",
    "laravel-mix": "^1.0",
    "lodash": "^4.17.4",
    "vue": "^2.1.10"
  }

jbowman99 left a reply on NPM Run Dev Errors

@PaulClarke

looked at this thread before and made some changes.

node node_modules/cross-env/dist/bin/cross-env.js NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js

/home/vagrant/Code/forum/node_modules/laravel-mix/setup/webpack.config.js:24
let WebpackConfig = require('../src/builder/WebpackConfig');
^^^

SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:387:25)
    at Object.Module._extensions..js (module.js:422:10)
    at Module.load (module.js:357:32)
    at Function.Module._load (module.js:314:12)
    at Module.require (module.js:367:17)
    at require (internal/module.js:20:19)
    at requireConfig (/home/vagrant/Code/forum/node_modules/webpack/bin/convert-argv.js:96:18)
    at /home/vagrant/Code/forum/node_modules/webpack/bin/convert-argv.js:109:17
    at Array.forEach (native)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ dev: `node node_modules/cross-env/dist/bin/cross-env.js NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/vagrant/.npm/_logs/2017-07-03T14_25_58_314Z-debug.log


new errors

30 Jun
1 year ago

jbowman99 started a new conversation NPM Run Dev Errors

Read through a couple of stackoverflow threads and a couple on laracasts and haven't quite been able to resole my issue

Having some issues running npm run dev, i have the updated package.json file as @TaylorOtwell suggested, removed node_modules and ran npm install --no-bin-links. when i run npm run dev it produces this error:

> npm run development


> @ development /home/vagrant/Code/forum
> cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js

sh: 1: cross-env: not found
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! @ development: `cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the @ development script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/vagrant/.npm/_logs/2017-06-30T15_36_36_192Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ dev: `npm run development`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/vagrant/.npm/_logs/2017-06-30T15_36_36_215Z-debug.log

jbowman99 left a reply on Laravel 5.4 Dev Npm Run Dev Error

Having some issues running npm run dev, i have the updated package.json file as @TaylorOtwell suggested, removed node_modules and ran npm install --no-bin-links. when i run npm run dev it produces this error:

> npm run development


> @ development /home/vagrant/Code/forum
> cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js

sh: 1: cross-env: not found
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! @ development: `cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the @ development script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/vagrant/.npm/_logs/2017-06-30T15_36_36_192Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ dev: `npm run development`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/vagrant/.npm/_logs/2017-06-30T15_36_36_215Z-debug.log

07 Jun
1 year ago

jbowman99 left a reply on How To Make The Auth Before Everything?

@MoHKh67

wrap all your routes in a route group

Route::group(['middleware' => 'auth'], function () {}):

jbowman99 started a new conversation Update From 5.2 To 5.4 Using Multiple Database Connections Have Broken Down Since The Update

Good Morning,

updated from 5.2 to 5.4 on an app. I was authenticating users against one database outside of this application,

in 5.2, everything was working fine, by adding in the User model this line

protected $connection = 'mysql2';

since the update this relationship has broken down, anywhere i am trying to query against the authenticated user, is now throwing an error. saying that table doesn't exist.

Auth::user()->anyrelationship

is failing. How can i resolve this?

01 Jun
1 year ago

jbowman99 left a reply on Undefined Index: 2017_06_01_141532_create_jobs_table

@bitspy

i'd try reinstalling fresh, that's a weird issue.

jbowman99 left a reply on Undefined Index: 2017_06_01_141532_create_jobs_table

@bitspy

Fresh Install shouldn't have a Jobs table

jbowman99 left a reply on Unable To Pass The Auth_> Id In Each View Page

also, if you just need access to the Authenticated users id you can call it in the blade itself:

{{ Auth::id }}

this of course will only work if {{ Auth::check() }} is true but you can fetch all user data {{ Auth::user()->attribute }}

jbowman99 left a reply on Unable To Pass The Auth_> Id In Each View Page

@DurgeshJha

you are not passing the id to the view in this code.

public function index() 
    {
        //show task
         $tasks = Task::all();
         $id= Auth::id();
         $users = DB::table('students')->where('id', $id)->get();
         $tasks = DB::table('tasks')->where('student_id', $id)->get();
         $counts =DB::table('tasks')->where('student_id', $id)->count();
         return view('studentzone.homework.index',  
         compact('users','tasks','counts'));
    }

31 May
1 year ago

jbowman99 left a reply on Is There A Laravel Helper To Reverse A Slug?

@josephmtinangi

good question, I've had to just reverse engineer whatever was being passed in as a slug, to return it to the string i wanted.

using

preg_split() - Split string by a regular expression str_split() - Convert a string to an array

if someone has a cleaner quicker way I'm all ears

25 May
1 year ago

jbowman99 left a reply on Trying To Get Property Of Non-object

@Raindrops

out of curiosity whats your User's table look like?

24 May
1 year ago

jbowman99 left a reply on Design Database Tables For Real Estate Contracts

@sork

just an idea, you could have 1 contracts table and add a column of type, have all of the fields on the one table, including rent start and end etc... you could make certain column's null-able so they could remain empty or NULL

then query the table on the type column, this way you can still call all() on contracts and limit your queries at times, since you'd only have the one model Contract...

23 May
1 year ago

jbowman99 left a reply on How To Auth With Laravel 5.4

@nmeri17

trying to find id=nmeri17 will fail if your username is nmeri17. The id will be 1,2....

did you modify your users table?

if you did make:auth you should be able to register and login a user without modfiying anything, all the routes and views are already there. you do have to php artisan migrate

01 May
1 year ago

jbowman99 started a new conversation Laracart Losing Session Data

I am using Laracart for adding items to a shopping cart. The user can move around the site and all seems fine. I have a review cart view where the user can see what they've added to the cart. If the user clicks a link away from this page I'm losing the session and the carts clearing.

Can't seem to track down why I am losing the session from this view and not any other?

19 Apr
1 year ago

jbowman99 started a new conversation Custom CSS For Laravel Paginator

Is there a good tutorial on doing custom CSS for the laravel pagination links?

currently using {!! $model->links() !!}

works fine, would like to change the look of it, but maintain the same functionality that's already baked in.

jbowman99 left a reply on Carbon Timeformat

@mturner20

what is your input for the time like?

18 Apr
1 year ago

jbowman99 left a reply on Laravel 5.4MassAssignmentException In Model.php Line 225: _token

@carlek

whats being sent in the request?

dd($request->all());

jbowman99 left a reply on Laravel 5.4MassAssignmentException In Model.php Line 225: _token

@carlek

try this in your User::create($request->except('_token'));

jbowman99 left a reply on Carbon Timeformat

from the docks:


$dt = Carbon::create(1975, 12, 25, 14, 15, 16);

var_dump($dt->toDateTimeString() == $dt);          // bool(true) => uses __toString()
echo $dt->toDateString();                          // 1975-12-25
echo $dt->toFormattedDateString();                 // Dec 25, 1975
echo $dt->toTimeString();                          // 14:15:16
echo $dt->toDateTimeString();                      // 1975-12-25 14:15:16
echo $dt->toDayDateTimeString();                   // Thu, Dec 25, 1975 2:15 PM

// ... of course format() is still available
echo $dt->format('l jS \\of F Y h:i:s A');         // Thursday 25th of December 1975 02:15:16 PM

jbowman99 left a reply on Return Search With Search Values

@EventFellows

just a snippet:

<div class="form-group search-mls">
                    <label class="control-label" for="mlsnumber">MLS&#35;</label>
                    <div>
                        <input id="mlsnumber" name="mlsnumber" placeholder="MLS&#35;" class="form-control input-md" type="text" value="{{ $data ? $data['mlsnumber'] : "" }}">
                    </div>
                </div>

                <div class="form-group search-zip">
                    <label class="control-label" for="zipcode">Zip</label>
                    <div class="">
                        <input id="zipcode" name="zipcode" placeholder="Zip Code" class="form-control input-md" type="text" value="{{ $data ? $data['zipcode'] : "" }}">
                    </div>
                </div>

                <div class="form-group search-type">
                    <label class="control-label hidden-on-desktop" for="propertytype">Property Type</label>
                    <div class="">
                        <select id="propertytype" name="propertytype" class="form-control">
                            <option value="" selected="selected">Type</option>
                            <option value="Residential">Residential</option>
                            <option value="Townhouse">Townhouse / Condo</option>
                            <option value="Multi">Multi-Family</option>
                            <option value="Land">Land</option>
                            <option value="Commercial">Commercial / Business</option>
                        </select>
                    </div>
                </div>

jbowman99 left a reply on Return Search With Search Values

@EventFellows

Controller method:

public function listings(Request $request)
    {
        $data = $request->all();

        $listings = Listing::all();

        if($data){
            $listings = (new SearchListings($request))->search();
        }

        return view('listings', compact('listings'))->with('data');
    }

jbowman99 started a new conversation Return Search With Search Values

I have a search bar with multiple inputs, when the page returns the view with the search results, how can I pass back the inputs that were searched for so the Search Fields remain populated?

currently i'm returning a view:

return view('listings', compact('listings');

i tried withInput() didn't work.

how can i return the search results and the input?

11 Apr
1 year ago

jbowman99 started a new conversation Real-estate Style Search Forms, Return Query, Add Searched Parameters To URI

I am building a real-estate site, which includes a search form, I would like to return search results based off of whats input into the form. Search functionality isn't the hard issue, I need to build out the URI based upon the input search resulting in something like so:

realestate.com/listings/main/mls-12345/type-house/city-CHICAGO 

How can i take the query string and create the return route from it?

10 Apr
1 year ago

jbowman99 started a new conversation Updating To 5.4 From 5.3

getting a error when updating to 5.4, found a few StackOverflow threads treating the same issue but nothing worked. I don't think Laravel Docs didn't mention this.

[Symfony\Component\Debug\Exception\FatalErrorException] Trait 'Illuminate\Console\AppNamespaceDetectorTrait' not found

other threads talked about Laravel/Generators being the fix, but this didn't work for me.

28 Mar
1 year ago

jbowman99 started a new conversation Clicking Back, Resubmitting Form Creating Duplicates

I have a form submit, that when submitted redirects the user to the newly created profile page. if the user clicks the back button, the form is resubmitting and a duplicate is being created.

How can I prevent this?

23 Mar
1 year ago

jbowman99 started a new conversation Toggle Config Values And Env Variables

I have a web API and would like to be able to set either a config value or env variable based on a setting selected within the admin tools of the api. For example if the API is being used by Business A has a set of modes or rules that apply to itself -- Toggle Mode variable to A Business B has its own set of modes -- Toggle Mode variable to B etc...

is it possible for me to have a switch or selector to set this variable from within the API in order to change how the overall API will worked based on the mode selected, like if Business B wants to adhere to Mode A?

not sure that makes sense...but its a work in progress

20 Mar
1 year ago

jbowman99 left a reply on Php Artisan Migrate

@zacharynn

what do your migrations look like?

17 Mar
1 year ago

jbowman99 left a reply on Proper Table Layout For Shared Item

check out the docs for relationships -- many to many

https://laravel.com/docs/5.4/eloquent-relationships

15 Mar
1 year ago

jbowman99 started a new conversation Laravel Logs

Looking through some docs on logging and emailing exceptions to myself for production sites. if my logs are created =>daily can i at the end of each day send the entire log to an email?

I don't want to send an email each time an exception occurs, but send one email a day with all of them, if they occured?

maybe i'm just overthinking it, would it be as simple as:

find todays log email file to [email protected]

14 Mar
1 year ago

jbowman99 left a reply on Concept Issue! "Trying To Get Property Of Non-object"

like @samalapsy said in your foreach try

@foreach($parents as $key => $value)
    {{$value}}
@endforeach 

key will be your array index, and value will be whatever value it has

jbowman99 left a reply on Concept Issue! "Trying To Get Property Of Non-object"

what do you see if you dd($parents);

?

10 Mar
1 year ago

jbowman99 left a reply on Type Error: Argument 1 Passed To Controller::show() Must Be An Instance Of Model, String Given

in the show method pass in a your first parameter also and it should work. right now your show method is just taking the first value as the expense value i think

jbowman99 left a reply on Type Error: Argument 1 Passed To Controller::show() Must Be An Instance Of Model, String Given

if you hard code in a value, will it still return 1?

/apartments/1/expenses/5?

jbowman99 started a new conversation Help With Query To Get Check Whether Entry Is First Of Its Kind

I have an activities table, the table has fields

user_id,
customer_id
type

I want to check whether a activity of type close is the first time a specific user has closed and activity for a specific customer. i.e. users first closed sale to a client.

if it is the first activity i need to update another table.

so i have all the users activities where type='close'

$closes = Activity::where('type', 'close')->where('user_id', $user->id)->get();

not sure what to do next.

09 Mar
1 year ago

jbowman99 started a new conversation Display PDF File From Storage In New Window

I have a page that lists pdf's stored in storage/app/flyers trying to make a link when clicked it will open up a new window and display the flyer. I get this error:

NotFoundHttpException in RouteCollection.php line 161:

heres my link:

<a href="/show/{{$flyer->file}}" target="_blank">
            <img class="flyer-thumbnail" src="/flyer_thumbs/{{$flyer->thumbnail}}">
        </a>

here's my route

Route::get('/show/{flyer}', function ($flyer) {
    $filename = $flyer->file;
    $path = storage_path($filename);

    return Response::make(file_get_contents($path), 200, [
        'Content-Type' => 'application/pdf',
        'Content-Disposition' => 'inline; filename="' . $filename . '"'
    ]);
});

not sure how to correct, assuming its a path issue, but i could be wrong

07 Mar
1 year ago

jbowman99 left a reply on Return Models Based Upon Pivot Table Data

So far, this works

$recently_attached = DB::table('customer_user')
            ->where('user_id', $this->id)
            ->where('created_at', '>=', $start_week)
            ->where('created_at', '<=', $end_week)
            ->pluck('customer_id')->toArray();

        $recent = Customer::whereIn('id', $recently_attached)->get();

is there a more eloquent way to do this?

jbowman99 started a new conversation Return Models Based Upon Pivot Table Data

I have a user model and customer model with a pivot table customer_user table. I want to fetch all customers that a user has attached within a specific span of time.

I was going to fetch all of the customer_user entries where the created_at date fell between a specific date range. then for each over the results and build a collection with that data:

$recent = DB::table('customer_user')
            ->where('user_id', $this->id)
            ->where('created_at', '>=', $start_week)
            ->where('created_at', '<=', $end_week)
            ->get();

foreach($recent as $new_customer){
    //create customer collection based of of the id's here
}

return //that collection

is there an easier way? can i add withPivot created_at to the relationship and find this same collection that way?

06 Mar
1 year ago

jbowman99 left a reply on How To Wait For Multiple Events To Happen Before Sending Mail?

event and listeners.

when a certain amount of comments are built up fire an event.

like @sbcman74 said, scheduling would be a good way too. just have the scheduler grab all comments at a set time and send an email. if no comments don't send

17 Feb
2 years ago

jbowman99 left a reply on A One-To-Many Relationship Between An User And Other Users ?

I needed to create a relationship from one user to another for something similar.

i based it off of this:

http://alexsears.com/tutorial/user-friendships-laravel/

13 Feb
2 years ago

jbowman99 left a reply on Multidimensional Array Searching To Return Key If Value Found

this did the trick

$radioreps = [
            ['id' => 7, 'name' => 'Larry'],
            ['id' => 7, 'name' => 'Fredrickson'],
            ['id' => 8, 'name' => 'Steve'],
            ['id' => 8, 'name' => 'Kelly'],
            ['id' => 9, 'name' => 'Dave'],
            ['id' => 9, 'name' => 'David'],
            ['id' => 9, 'name' => 'Burns'],
            ['id' => 10, 'name' => 'Burress'],
            ['id' => 10, 'name' => 'Dana'],
            ['id' => 11, 'name' => 'Marsha'],
            ['id' => 11, 'name' => 'Silver'],
            ['id' => 12, 'name' => 'Elaine'],
            ['id' => 12, 'name' => 'Lueth'],
            ['id' => 17, 'name' => 'Mike'],
            ['id' => 17, 'name' => 'Haile'],
            ['id' => 34, 'name' => 'Ennen'],
        ];


        foreach($radioreps as $key => $rep)
        {
            if (in_array($username, $rep)) {
                echo "Found {$rep['id']} for {$username}" . PHP_EOL;
                return $rep['id'];
            }
        }
        return false;