madsynn

madsynn

Member Since 4 Years Ago

Experience Points 9,390
Experience Level 2

610 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 82
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.

28 May
2 months ago

madsynn left a reply on Loop Question

@tykus @sergiu17 Thanks for the help.

I am still having a little trouble getting it to work though. Something like this? Thanks for the patience i have never used this before.

@foreach ($values as $value)
@foreach (range(0, 20) as $value)
    //
@endforeach
@endforeach

madsynn started a new conversation Loop Question

I need a foreach loop to loop 20 times even if the values within are empty can anyone help me i am not sure how to do it.

$count = 0;
if (count($values > 20)):
foreach ($values as $value):

$count . $value

endforeach
endif

15 May
3 months ago

madsynn left a reply on Query Help

Here is what i am trying to use it. The controller show function.

$cs_count            = 0;
foreach ($server->cs as $c) {

$cs_count = $cs_count + 1;
$contents .= "C" . $cs_count . "=" . @$c->channel->source_name . "&PROTOCOL" . $cs_count . "=" . @$c->protocol->protocol . "&URL" . $cs_count . "=" . @$c->channel->id . "\n";
 
}

I cannot get the @$c->channel->source_name and @$c->channel->id to come through no matter what i try.

Any Suggestions anyone

I need something like this $server->cs->channels()->get();

madsynn left a reply on Query Help

@snapey

Ok here is what i have tried. no luck.

$channels = \App\Channel::get()->pluck('source_name', 'id')->where('cs_id', 'channel_id');
$channels = \App\Channel::where('cs_id', 'channel_id')->get();
 
$channels = \App\Channel::where('server_id', 'channel_id', $id)->get();
$channels = \App\Channel::get()->pluck('source_name', 'id')->get();
$channels = \App\Channel::where('csi_id', $cs->server_id)->get();
$channels = \App\Channel::selectRaw('id, CONCAT(source_name," | ", env) as source_name')->pluck('source_name', 'id');

madsynn left a reply on Query Help

@snapey

Good catch sorry here is the fix.

Server
  └── CS
       └── Channel

I got this grabbing the source name from channels but i need it to also pass through the server. This returns all channels with a Cs relation but i need it to also filter for the Server

$server        =  \App\Server::findOrFail($id);
$cs                = \App\Cs::where('server_id', $id)->get();
// tried these but not sure how to tie the third one into the query


$channels    = \App\Channel::get()->pluck('source_name', 'cs_id');
$channels = \App\Channel::where('cs_id', $id)->get();

On

$channels = \App\Channel::where('cs_id', $id)->get();

the $id would have to be the $id that matches the server_id id of Cs::class

I need it to get the results for Channels that belong to the CS if it belongs to the Server

hope that makes sense.

madsynn started a new conversation Query Help

Have 3 models

Server
  └── Player
         └── Channel

MODEL    |  RELATIONSHIP 
Server   hasManyThrough 🠊 Cs::class 🠊 Channel::class
Cs       belongsTo 🠊 Server::class ⭢ server_id
Cs       hasOne 🠊 Cs::class 
Channel  belongsTo 🠊 Cs::class ⭢ cs_id

I need help getting name of Channel in the Server

something like this?

$channels = Server::latest()->with->csi->where->channel;

Any help welcome

08 May
3 months ago

madsynn left a reply on Blade Help

Thanks for your help everyone i found my provblem rookie mistake sorry.

@switch($ss->status->id)

needed to be

@switch($smart->status->id)

madsynn left a reply on Blade Help

@tray2

Here is the dd of one record in the array of output foreach items.

    0 => Host {#17217 ▼
      #fillable: array:11 [▶]
      #hidden: []
      #connection: "mysql"
      #table: "hosts"
      #primaryKey: "id"
      #keyType: "int"
      +incrementing: true
      #with: []
      #withCount: []
      #perPage: 15
      +exists: true
      +wasRecentlyCreated: false
      #attributes: array:15 [▼
        "id" => 3
        "name" => "aass1-1"
        "host" => "aass1-1.imovetv.com"
        "server_exists" => 1
        "is_setup" => 0
        "ready_to_receive_conf" => 0
        "last_received_conf" => null
        "configured" => 0
        "notes" => null
        "cs_token" => "afd0b036-625a-3aa8-b639-9dc8c8fff0ff"
        "created_at" => "2019-05-08 22:10:17"
        "updated_at" => "2019-05-08 22:10:17"
        "deleted_at" => null
        "status_id" => 2
        "group_id" => 1
      ]
      #original: array:15 [▶]
      #changes: []
      #casts: []
      #dates: array:1 [▶]
      #dateFormat: null
      #appends: []
      #dispatchesEvents: []
      #observables: []
      #relations: []
      #touches: []
      +timestamps: true
      #visible: []
      #guarded: array:1 [▶]
      #forceDeleting: false
    }

If the switch statement only goes into effect if the previous passes then that is what i am trying todo. all 4 of the if statements need to pass and then it grabs the status of the relationship to $status.

Only problem is its not working.

here is a screenshot of what its being used on you can see the middle ones are all the same and they all shoudl be different but cant get it working.

madsynn started a new conversation Blade Help

I have a loop of five variables i need to return a value from each. but i am not getting the last part and cannot figure out why. Here is what i have so far.

@php $z = 'B'; @endphp
 @foreach($sss as $smart)
        @php $z++;  @endphp


        @if($smart->server_exists == true && $smart->is_setup == false && $smart->ready_to_receive_conf == false && $smart->configured== false)
        class {{ $z }} serverexists <br>
        @elseif($smart->server_exists == true && $smart->is_setup == true && $smart->ready_to_receive_conf == false && $smart->configured== false)
        class {{ $z }} hascaipy <br>
        @elseif($smart->server_exists == true && $smart->is_setup == true && $smart->ready_to_receive_conf == true && $smart->configured== false)
        class {{ $z }} needsconf <br>
        @elseif($smart->server_exists == true && $smart->is_setup == true && $smart->ready_to_receive_conf == true && $smart->configured== true)
            @switch($ss->status->id)
                @case($ss->status->id == 1)
                case1 {{ $z }} running <br>
                @break

                @case($ss->status->id == 2)
                case2 {{ $z }} notrunning <br>
                @break

                @case($ss->status->id == 3)
                case3 {{ $z }} stopped <br>
                @break
                @default
                default {{ $z }} configured <br>
            @endswitch
        @else
        class {{ $z }} before <br>
        @endif

@endforeach

Here is my output it all works fine until i get to the switch. I have also tried doing all of it as elseif but have the same problem it just returns the first or second depending on what i try.

class C serverexists 
class D hascaipy 
class E needsconf 
case2 F notrunning 
case2 G notrunning 
case2 H notrunning 
case2 I notrunning 
case2 J notrunning 
class K before 
class L before 
05 Apr
4 months ago

madsynn started a new conversation Request Help Please

Ok i have a problem connecting my select fields on my create.blade.php

$channel_sources = \App\Csi::get()->pluck('move_path', 'id')->prepend(trans('global.app_please_select'), '');

I have 4 Models.

channel.php

cs.php

csi.php

cso.php

My problem is im trying to get my cso.php to select channel from csi but only channels from channel.php that are assinged to cs.php and configured in csi.php

I need the select field to show the channel->source_name from channel.php but only show ones that have been configured in the csi.php

Maybe something like this?

 \App\Csi::get()->pluck($channel->source_name, 'channel_id', id)

any help would be great.

26 Mar
4 months ago

madsynn left a reply on Third Party API Series

@jlrdw

you posted " Taylor covers the basics already." but can you tell me which ones to check out to see the covered basics you talk about please?

26 Nov
8 months ago

madsynn left a reply on Spatie MediaLibrary Default Storage Depending On The Model

Giving props to @gcwilliams i would like to add to his answer.

If you add these to the filesystem config under disks it will solve the url part of your question also. Here is an updated answer.

'disks' => [
        'postFiles' => [
            'driver' => 'local',
            'root'   => storage_path('app/posts'),
            'url'        => env('APP_URL') . '/posts',
            'visibility' => 'public'
        ],

        'productFiles' => [
            'driver' => 'local',
            'root'   => storage_path('app/products'),
            'url'        => env('APP_URL') . '/products',
            'visibility' => 'public'
        ],

Paths files are stored at are:

public/posts/{id}/

public/products/{id}/

This will make the visible url links look like this.

www.yoursite.com/products/{product}

www.yoursite.com/posts/{post}

Anyway hope it helps someone.

madsynn started a new conversation Need Some Assistance With Spatie-medialibrary

1

I have this library installed and working just fine. Question is on this command i would like to run it for every 5 seconds not just once can you tell me how i would go about doing this? like a repeating command of some sort?

https://github.com/spatie/laravel-medialibrary

https://docs.spatie.be/laravel-medialibrary/v7/converting-other-file-types/using-image-generators

Current

$this->addMediaConversion('thumb')
     ->width(368)
     ->height(232)
     ->extractVideoFrameAtSecond(20)
     ->performOnCollections('videos');

What I need it to do?

$this->addMediaConversion('thumb')
     ->width(368)
     ->height(232)
     ->extractVideoFrameAtSecond(EVERY 5 SECONDS)
     ->performOnCollections('videos');

2

On this model i have both videos and images fields for multiple uploads where they upload to same collections.

toMediaCollection('images') toMediaCollection('videos')

Both are working correctly but when the images are generated from the video i need them to show in the images section if index.blade.php and i'm not sure how to make that happen.

Here is what is happening.

Video uploads to

uploads/clips/{id}/

Images generated from the video go to

uploads/clips/{id}/conversions/

Images uploaded are here

uploads/images/{id}/

I need the images from the video to show up as a uploaded image so they show in the same index.

Any help would be very appreciated as I am stuck.

18 Oct
10 months ago

madsynn left a reply on Help Saving My Form Passing It Through A Upload Trait

@Snapey

I found it i think on github but modified it to do the things i needed. I am not sure how to upload a file using it though. maybe you have a better way.

relationships

CLIP
 ╚═╦═ video 
   ╚═ images

each clip will have one video and multiple images each video has processing it needs when its uploaded or after (this is where i am stuck)

when i add a new clip and use the form to upload a file it works fine but the processing i need done on the file does not happen.

That is unless i use the video crud instead of the parent clip crud. then it uses the trait just fine.

For the life of me i cannot get it to use the trait when created from the clip.create

any help would still be apprecited

madsynn left a reply on Help Saving My Form Passing It Through A Upload Trait

@Cronix @Snapey Thanks guys but no luck.

I have tried all the things you said to try but still no luck.

@Snapey can you give me an example of you idea for having the file save and them run the file.

foreach ($request->input('videos', []) as $data) {
    
    $clip->videos()->create($data);
}


madsynn left a reply on Help Saving My Form Passing It Through A Upload Trait

@Snapey

When o go to video and add one manually it runs through the fileuploadtrait.php and does what its needing to do but when im on clip and ad the video to it it ads the information from the form just fine also problem is that the trait fills in the fields when it processes the video file. The fields such as duration and such are filled in when it runs through the ffmpeg filters to obtain that data. it also saves the extension and filename form fileinfo.

Attacking the video from the controller is the only way its going to be done. video crud is not part of it i only made it to test it out.

How would I go about doing it the way you said after save for instance. can you provide me a example please?

when i use

        foreach ($request->input('videos', []) as $data) {
            $output = $this->saveFiles($request);
            $clip->videos()->create($data);
        }

it saves the info i manually add to the form but its not being processed inside the fileuploadtrait.php like i need to. on upload all fields for video table are filled out by the trait function.

madsynn left a reply on Help Saving My Form Passing It Through A Upload Trait

HI @Snapey !! How are you. Good to hear from you.

So do you mean something like this?

        foreach ($request->input('videos', []) as $data) {
 
            $data = $this->saveFiles($request)

            $clip->videos()->create($data);

        }

new error from trying that is

Argument 1 passed to Illuminate\Database\Eloquent\Relations\HasOneOrMany::create() must be of the type array, object given, called in /home/vagrant/repos/gui/app/Http/Controllers/Admin/ClipsController.php on line 220

madsynn left a reply on Help Saving My Form Passing It Through A Upload Trait

@Cronix

The trait is used in the top of the controller do i need to move it to the model?



namespace App\Http\Controllers\Admin;

use App\Clip;
use App\Video;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Gate;
use App\Http\Controllers\Controller;
use App\Http\Requests\Admin\StoreClipsRequest;
use App\Http\Requests\Admin\UpdateClipsRequest;
use Yajra\DataTables\DataTables;
use App\Http\Controllers\Traits\FileUploadTrait;
use Input;

class ClipsController extends Controller
{
    use FileUploadTrait;

I know where the problem is i just dont know how to fix it. I think its in the store function of the controller.


        foreach ($request->input('videos', []) as $data)            
            $clip->videos()->create($data);
        }

Everything i try to get it to pass thought / use the trait fails.

            // tried these but they dont work
            // $data = $this->saveFiles($request->all());
            // $data = $this->saveFiles($data['videos']['1']['video']);
            // $data = $this->saveFiles(Input::get('video')->get());
            // $request = $this->saveFiles($request->videos()->video); 

error i keep getting is

Argument 1 passed to App\Http\Controllers\Admin\ClipsController::saveFiles() must be an instance of Illuminate\Http\Request, array given, called in /home/vagrant/repos/gui/app/Http/Controllers/Admin/ClipsController.php

madsynn started a new conversation Help Saving My Form Passing It Through A Upload Trait

Hi everyone im stuck and would love your help.

I have a ClipController.php and in the clip it contains relationships to Video.php and Image.php models.

i am able to save the form data just find when i hit cClipController.php store function but here is the catch.

my clip->video form needs to pass through a fileuploadtrait.php but i am unable to get it to work. I am sure its a simple fix but im not seeing it. ill include my code for you to review.

File location paths

use App\Clip;
use App\Video;
use App\Http\Controllers\Traits\FileUploadTrait;
use App\Http\Controllers\ClipController;

Clip controller store funtion

    public function store(StoreClipsRequest $request)
    {
        if (! Gate::allows('clip_create')) {
            return abort(401);
        }

        // This works on the controllers for each individual form.  but not on the combined form here.  example:  on VideoController store this line works fine.
        // $request = $this->saveFiles($request); 

        $clip = Clip::create($request->all());

        foreach ($request->input('videos', []) as $data) {

            // tried these but they dont work
            // $data = $this->saveFiles($request->all());
            // $data = $this->saveFiles($data['videos']['1']['video']);
            // $data = $this->saveFiles(Input::get('video')->get());
            // $request = $this->saveFiles($request->videos()->video); 
            
            $clip->videos()->create($data);
        }
        foreach ($request->input('brands', []) as $data) {
            $clip->brands()->create($data);
        }
        return redirect()->route('admin.clips.index');
    }

Form line in my clip/create.blade.php This part is for the clip => video store functionality

<tr data-index="{{ $index }}">
    <td>{!! Form::hidden('videos['.$index.'][video]', old('videos['.$index.'][video]')) !!}{!! Form::file('videos['.$index.'][video]', ['class' => 'form-control']) !!}</td>
    <td>{!! Form::text('videos['.$index.'][name]', old('videos['.$index.'][name]', isset($field) ? $field->name: ''), ['class' => 'form-control']) !!}</td>
    <td>{!! Form::text('videos['.$index.'][extention]', old('videos['.$index.'][extention]', isset($field) ? $field->extention: ''), ['class' => 'form-control']) !!}</td>
    <td>{!! Form::text('videos['.$index.'][ad_duration]', old('videos['.$index.'][ad_duration]', isset($field) ? $field->ad_duration: ''), ['class' => 'form-control']) !!}</td>

    <td>
        <a href="#" class="remove btn btn-xs btn-danger">remove</a>
    </td>
</tr>

this form saves just fine into the video table just fine but its not using the FileUploadTrait.php file it needs.

FileUploadTrait.php

namespace App\Http\Controllers\Traits;

use Illuminate\Http\Request;
use Intervention\Image\Facades\Image;
use File;
use FFMpeg;
use FFMpeg\FFProbe;
use Illuminate\Support\Facades\Log;
use App\Helpers\Normalize;
use App\Helpers\FFMPEG_helpers;
use App\Clip;
use App\Video;

trait FileUploadTrait
{

    /**
     * File upload trait used in controllers to upload files
     */
    public function saveFiles(Request $request)
    {

        if (! file_exists(public_path().'/uploads')) { File::makeDirectory(public_path().'/uploads',0777, true);}
 
        $uploadPath = env('UPLOAD_PATH', 'uploads');

        $finalRequest = $request;

        foreach ($request->all() as $key => $value) {
            if ($request->hasFile($key)) {
         
                    $filename = $request->file($key)->getClientOriginalName();
                    $extension = $request->file($key)->getClientOriginalExtension();
                    if(preg_match('/^.*\.(mp4|mov|mpg|mpeg|wmv|mkv)$/i', $filename)){
                        //Log::info('passed valication: '.$filename);
                        $filename = $request->file($key)->getClientOriginalName();
                        $basename = substr($filename, 0, strrpos($filename, "."));
                        $basename = Normalize::titleCase($basename);
                        $ad_duration = FFMPEG_helpers::getDuration($request->file($key));

                        $filename = str_slug($basename) . '.' . $extension;
                        $request->file($key)->move($clipPath, $filename);
                        $finalRequest = new Request(array_merge($finalRequest->all(), [$key => $filename, 'video' => $request->video, 'extention' => $extension, 'name'=> $basename, 'ad_duration'=>$ad_duration]));

                        $file_w_path = $clipPath . "/" . $filename;
                    }
                }
            }
        }

        return $finalRequest;
    }
}
11 Oct
10 months ago

madsynn started a new conversation Help Trying To Table In Markdown

this is not working

First Header | Second Header
------------ | -------------
Content from cell 1 | Content from cell 2
Content in the first column | Content in the second column

another try

| First Header  | Second Header |
| ------------- | ------------- |
| Content Cell  | Content Cell  |
| Content Cell  | Content Cell  |

madsynn started a new conversation Need Help With Setting Up A Nested Hierarchy Taxonomy

I am trying to use googles taxonomy but not sure how or the easiest way to do this.

do i need to put each parent in a parent table? then each sub under that and then the next one after that?

And once its in my tables how would i reference it when doing queries to i later.

Need help any help would be great

Trying to make this work for products and them reference it when its queried.

Animals & Pet Supplies
Animals & Pet Supplies,Live Animals
Animals & Pet Supplies,Pet Supplies
Animals & Pet Supplies,Pet Supplies,Bird Supplies
Animals & Pet Supplies,Pet Supplies,Bird Supplies,Bird Cage Accessories
Animals & Pet Supplies,Pet Supplies,Bird Supplies,Bird Cage Accessories,Bird Cage Bird Baths
29 Aug
11 months ago

madsynn left a reply on Help Determining The Best Way To Generate Text Files

@jlrdw Sorry i should have been more clear. I am not looking for the best functions or php ways to write the files im looking for the best way to create the process in laravel.

Using controllers or listeners or custom provider or any other means of making this work best in laravel.

madsynn left a reply on Is It Possible To Put Composer Require In A Command Like Pre-update-cmd

@nash thank you.

i got lost in my thoughts on that one lol

madsynn started a new conversation Help Determining The Best Way To Generate Text Files

Can you guys help me. I am trying to generate text files that contain the looped data from each crud when a button is pushed. Can anyone help me i have never had to do something like this with laravel before and i am at a loss on how to do it.

lets say crud is called config i need to print all values from config into a text.txt file in the public folder. Do i do this with a controller and use that to loop through it and create the text file when the button is pushed or is there a better and easier way to make this happen.

Any of your thoughts an suggestions would be very helpful and welcome please.

Thank you for the help in advance.

07 Apr
1 year ago

madsynn started a new conversation Is It Possible To Put Composer Require In A Command Like Pre-update-cmd

I have a repo that is bare bones but i would like to just update the files after i add them but everytime i take a fresh copy to use i have to reinstall the packages being used.

Is it possible to run the php composer require package/package command from composer update somehow.

I have tried this but it just loops over and over.

        "pre-update-cmd":[
            "@php /usr/local/bin/composer require guzzlehttp/guzzle",
            "@php /usr/local/bin/composer require thomaswelton/laravel-gravatar",
            "@php /usr/local/bin/composer require webpatser/laravel-uuid"
        ],

Any help would be greatly appreciated.

thanks in advance.

25 Jan
1 year ago

madsynn left a reply on What Am I Missing.

@godbout

Thanks for getting back to me.

The repo bit is because im using repositories as datacontroller.

As for bind your route with your model, i have already done this but im still getting the same problem how would you do this and ill try it your way.

I have this in my routes web.php

Route::model('user', App\Models\User::class);

And in my repo i have this

    /**
     * Configure the Model
     **/
    public function model()
    {
        return User::class;
    }

Once again if im missing something please let me know.

Thanks in advance.

23 Jan
1 year ago

madsynn left a reply on What Am I Missing.

@Drfraker maybe you can help me with this also.

on my userController i need to make sure this runs and stores the data from it while a new user is being created and i am having issues getting it to work. any ideas i appreciate the help.

$this->attributes['confirmation_code'] = \Hash::make( $this->email . time() );

i tried to set the attribute in my model but it doesnt run when the user is created.

    public function getConfirmationCodeAttribute()
    {
        return \Hash::make( $this->email . time() );
    }

madsynn left a reply on What Am I Missing.

@Drfraker

Here is my whole controller:

class UserController extends AppBaseController
{
    /** @var  UserRepository */
    private $userRepository;
    private $profileRepository;

    public function __construct(UserRepository $userRepo, ProfileRepository $profileRepo)
    {
        $this->userRepository = $userRepo;
        $this->profileRepository = $profileRepo;
    }

    /**
     * Display a listing of the User.
     *
     * @param Request $request
     * @return Response
     */
    public function index(Request $request)
    {
        $this->userRepository->pushCriteria(new RequestCriteria($request));
        $users = $this->userRepository->all();

        //return $users;
         return view('users.index')->with('users', $users);
    }

    /**
     * Show the form for creating a new User.
     *
     * @return Response
     */
    public function create()
    {
        return view('users.create');
    }

    /**
     * Store a newly created User in storage.
     *
     * @param CreateUserRequest $request
     *
     * @return Response
     */
    public function store(CreateUserRequest $request)
    {
        $input = $request->all();

        $user = $this->userRepository->create($input);

        

        Flash::success('User saved successfully.');

        return redirect(route('users.index'));
    }

    /**
     * Display the specified User.
     *
     * @param  int $id
     *
     * @return Response
     */
    public function show($id)
    {
        $user = $this->userRepository->findWithoutFail($id);

        if (empty($user)) {
            Flash::error('User not found');

            return redirect(route('users.index'));
        }

        return view('users.show')->with('user', $user);
    }

    /**
     * Show the form for editing the specified User.
     *
     * @param  int $id
     *
     * @return Response
     */
    public function edit($id)
    {
        $user = $this->userRepository->findWithoutFail(id);

        // dd($user);

        if (empty($user)) {
            Flash::error('User not found');

            return redirect(route('users.index'));
        }

        return view('users.edit', compact('user'));
    }

    /**
     * Update the specified User in storage.
     *
     * @param  int              $id
     * @param UpdateUserRequest $request
     *
     * @return Response
     */
    public function update($id, UpdateUserRequest $request)
    {
        $user = $this->userRepository->findWithoutFail($id);

        if (empty($user)) {
            Flash::error('User not found');

            return redirect(route('users.index'));
        }

        $user = $this->userRepository->update($request->all(), $id);

        Flash::success('User updated successfully.');

        return redirect(route('users.index'));
    }

    /**
     * Remove the specified User from storage.
     *
     * @param  int $id
     *
     * @return Response
     */
    public function destroy($id)
    {
        $user = $this->userRepository->findWithoutFail($id);

        if (empty($user)) {
            Flash::error('User not found');

            return redirect(route('users.index'));
        }

        $this->userRepository->delete($id);

        Flash::success('User deleted successfully.');

        return redirect(route('users.index'));
    }

}

madsynn started a new conversation What Am I Missing.

I run into this problem all the time. Any help would be appreciated. I need to get past this.

I have my controller edit function as below:

    public function edit(User $user)
    {
        $user = $this->userRepository->findWithoutFail($id);
        if (empty($user)) {
            Flash::error('User not found');
            return redirect(route('users.index'));
        }
        return view('users.edit')->with('user', $user);
    }

and my index.blade.php has a link to edit pretty much the normal way.

{!! Form::open(['route' => ['users.destroy', $user->id], 'method' => 'delete']) !!}
                <div class='btn-group'>
                    <a href="{!! route('users.show', [$user->id]) !!}" class='btn btn-success btn-xs'><i class="fa fa-eye fa-2x"></i></a>
                    <a href="{!! route('users.edit', [$user->id]) !!}" class='btn btn-warning btn-xs'><i class="fa fa-pencil-square-o fa-2x"></i></a>
                    {!! Form::button('<i class="fa fa-trash fa-2x"></i>', ['type' => 'submit', 'class' => 'btn btn-danger btn-xs', 'onclick' => "return confirm('Are you sure?')"]) !!}
                </div>
                {!! Form::close() !!}

but when I click on edit i get the following error!

Undefined variable: id

Also if i change my edit function to this:

    public function edit($id)
    {
        $user = $this->userRepository->findWithoutFail($id);
        if (empty($user)) {
            Flash::error('User not found');
            return redirect(route('users.index'));
        }
        return view('users.edit')->with('user', $user);
    }

The error changes to this:

Property [id] does not exist on this collection instance. 

Can anyone help me, i cannot figure out what i missed.

10 Jan
1 year ago

madsynn started a new conversation Blade Help

Is there a way in blade to conditionally load according to filetype?

@if( \File::exists(public_path('/uploads/' . $item->filename)) && if(this.files[0].type == 'image') ) @endif

Something along those lines. if anyone can help me i would be really greatful.

I need to load conditionally if in image or regular file.

Thanks in advance

21 Nov
1 year ago

madsynn left a reply on Need Help With Pulling Data.

@drfraker

Normally i would but in this instance i do not know enough about googles library to build my own version of the services needing to be pulled in.

madsynn left a reply on Relationship Help

@robrogers3

The clinics can have many zip codes which are comprised of all the zip codes of the area they cover.

Locations will only have 1 zip code because locations are physical addresses for service from that clinic.

CLINIC 1
Covers: Zipcodes 1-20
With 3 locations:
    Location 1
        has a physical address and Zipcode 1 
    Location 2
            has a physical address and Zipcode2
    Location 3
            has a physical address and ZipCode3
    
CLINIC 2
Covers: Zipcodes 20-50
With 3 locations:
    Location 22 
            has a physical address and Zipcode 22
    Location 23
            has a physical address and Zipcode 23
    Location 24
            has a physical address and  Zipcode 24

view schema screenshot here: https://s.nimbus.everhelper.me/share/1260032/79noieuxsn6hzbehh11p

So far my relationships are as follows.

clinic hasMany zipcodes clinic hasMany locations location belongsTo clinic location hasOne zipcode zipcodes belongToMany clinics zipcode belongsTo location

Please let me know your thoughts.

Thank you

20 Nov
1 year ago

madsynn started a new conversation Need Help With Pulling Data.

I have a package that uses info entered into the config file but i need to have it pull from a table record instead.

config file

 'oauth' => [
            'client_id' => env('GOOGLE_CLIENT_ID'),
            'client_secret' => env('GOOGLE_CLIENT_SECRET'),
        ],
 
        'oauth_json' => [
            'auth_config' => env('GOOGLE_AUTH_CONFIG'),
        ],
 
        'service_account' => [
            'application_credentials' => env('GOOGLE_APPLICATION_CREDENTIALS'),
        ],

but instead i need it to pull the same data that is entered into a table for each company logging in.

not user how to tell the package to pull from the table instead of the config file what would be the easiest way to do this.

Any help would be appreciated.

madsynn left a reply on Relationship Help

@robrogers3 you still around?

16 Nov
1 year ago

madsynn left a reply on Relationship Help

@robrogers3

You almost guessed it right sorry for not being clear enough. The part that is a little off is this line: "A Zipcode belongsTo (Clinic) <-- this means only one ZipCode can be associated with a clinic. (attached to)"

A Zipcode belongsTo clinic but is attached to one Location.

As for the schema, I have not created them yet because I'm trying to determine the best way to structure them.

Here is a better example:

The owner Steve has a business called steves family health clinic. So the clinic is Steves family health clinic. Now The business = clinic services 20 zip codes in that area before he goes into someone else's territory. The Clinic has 3 location in 3/20 zipcodes.

so id a person searching for service in their own zip code searches for a clinic in one of the 20 zip codes it will pull up the clinics 3 locations even if it's not in the zip codes with no location attached.

Hope this clears it up a little.

What I have built so far you can check out here.

http://www.laravelsd.com/share/OMviLu

Thanks

14 Nov
1 year ago

madsynn started a new conversation Relationship Help

I'm using L5 and I'm trying to figure out how to do the relationships for the following tables any help would be appreciated.

clinics locations zipcodes

clinics are over a list of zip codes

locations are attached to some of the zip codes assigned to the clinic but not all.

clinic 1 has 10 zip codes assigned to it. clinic 1 has 3 locations 1 locations are attached to 3 of the zipcodes attached to the clinic zip codes 3 out of 10 assigned zip codes.

Thanks in advance for your help.

27 Oct
1 year ago

madsynn started a new conversation Possible Site Concept

I am looking for any advice on how to create the following with laravel. Any ideas are welcome and appreciated.

I have one main site that is the main site for other sites but im not sure how i can structure this and im looking for your guys help. Let me start with concept layout.

portal.com (this is the manager and main part of the whole thing.)

→ site1.com (site created and managed by portal) → site2.com (site created and managed by portal) → site3.com (site created and managed by portal)

The portal site would create all content and pages and select wich one it would publish to in the creation. the problem i am seeing is how do i get the routes to work if they are a different domain then portal.com

17 Apr
2 years ago

madsynn left a reply on Blade Conditional Help

@aivis That worked thank you!!

madsynn left a reply on Blade Conditional Help

@aivis thank you in advance.

Ok i tried the following but still nothing.

@if(Request::is('/en/resources/blog/*'))
     @include('frontend.article.partials.temp')
      @else
    // duh not working
@endif 

madsynn started a new conversation Blade Conditional Help

Can anyone tell me why these will not work? I have tried them all and to no avail. I am trying to only show code if the view is part of the blog.

@if(Request::is() === '/en/resources/blog/')
<h1>this is a blog article</h1>
 @else
    // duh not working
@endif

@if(Request::is() === '/en/resources/blog/')
     @include('frontend.article.partials.temp')
      @else
    // duh not working
@endif


@if(Request::path() == '/en/resources/blog/')
    <h1>article for the blog</h1>
     @else
    // duh not working
@endif

@if(Request::path() === '/en/resources/blog/home-use')
    // code
    @else
    // duh not working
@endif 
24 Mar
2 years ago

madsynn started a new conversation Can Someone Point Me In The Right Direction?

I need to create a function that will inventory all images and all sizes and versions of it are created on upload and if one is missing in any of the different sizes grab the original image and add it again so all version and sizes are in inventory.

I am not sure how to go about this. Can any of you tell me your thoughts on what to use for each step, i would love to hear them.

This is an example of my upload function with the different sizes being created. I would need this function to check each directory for the file and if missing regenerate it from the original image that is in the $dest.

$dest = 'uploads/products';

$Path = public_path() . $this->imgDir;
$ThumbPath = public_path() . $this->thumbDir;
$LoopPath = public_path() . $this->loopDir;
$ShopLoopPath = public_path() . $this->shopLoopDir;
$FitPath = public_path() . $this->shopLoopDir . "fit/";

File::exists($Path) or File::makeDirectory($Path);
File::exists($ThumbPath) or File::makeDirectory($ThumbPath);
File::exists($LoopPath) or File::makeDirectory($LoopPath);
File::exists($ShopLoopPath) or File::makeDirectory($ShopLoopPath);
File::exists($FitPath) or File::makeDirectory($FitPath);

$name = $request->file('thumbnail')->getClientOriginalName();
$from = $request->file('thumbnail');
Image::make($from)->resize($this->width, $this->height)->save($Path . $name);
Image::make($from)->resize($this->thumbWidth, $this->thumbHeight, function ($constraint) {$constraint->upsize(); })->save($ThumbPath . $name);
Image::make($from)->resize($this->loopWidth, $this->loopHeight, function ($constraint) {$constraint->upsize(); })->save($LoopPath . $name);
Image::make($from)->fit($this->shopLoopWidth, $this->shopLoopHeight, function ($constraint) {$constraint->upsize(); })->save($ShopLoopPath . $name);
Image::make($from)->resize($this->shopLoopWidth, $this->shopLoopHeight, function ($constraint) {$constraint->upsize(); })->save($FitPath . $name);

$request->file('thumbnail')->move($Path, $name);

$product = $request->all();
$product['thumbnail'] = $name;
12 Oct
2 years ago

madsynn left a reply on Help Converting Auth::user To Sentinel::getUser

@jlrdw the facedes in config/app.php

        'Activation'          => Cartalyst\Sentinel\Laravel\Facades\Activation::class,
        'Reminder'            => Cartalyst\Sentinel\Laravel\Facades\Reminder::class,
        'Sentinel'            => Cartalyst\Sentinel\Laravel\Facades\Sentinel::class,

facedes in app/Http/Kernel.php

 protected $routeMiddleware = [
        'before' => \App\Http\Middleware\BeforeMiddleware::class,
        'sentinel.auth' => \App\Http\Middleware\SentinelAuth::class,
        'sentinel.permission' => \App\Http\Middleware\SentinelPermission::class,
        'localize' => \Mcamara\LaravelLocalization\Middleware\LaravelLocalizationRoutes::class,
        'localizationRedirect' => \Mcamara\LaravelLocalization\Middleware\LaravelLocalizationRedirectFilter::class,
        'isAdmin' => \App\Http\Middleware\isAdmin::class,

    ];

Do you mean these ones?

11 Oct
2 years ago

madsynn started a new conversation Help Converting Auth::user To Sentinel::getUser

I have been trying to make my working cart use Sentinel instead of Auth but i cannot get it to work can any of you help me?

old file https://gist.github.com/phillipmadsen/91acea7c9330bd6fd1d83116db9467a3

new file i am having trouble with

https://gist.github.com/phillipmadsen/37d506a99a9120fb27be7763e5717bf6

madsynn left a reply on Blade @include Help

@wolle404 Thanks,

Can you show me an example of share of view?

10 Oct
2 years ago

madsynn started a new conversation Sentinel?

Can you guys look at my implementations for Sentinel and tell me why they are not working please.

1 in my helper file

  public static function getPageInfo(&$cart, &$total)
    {
        if (Sentinel::getUser()) {
            $cart = Sentinel::getUser()->cart;
        } else {
            $cart = new Collection;
            if (Session::has('cart')) {
                foreach (Session::get('cart') as $item) {
                    $elem = new Cart;
                    $elem->product_id = $item['product_id'];
                    $elem->amount = $item['quantity'];
                    if (isset($item['options'])) {
                        $elem->options = $item['options'];
                    }
                    $cart->add($elem);
                }
            }
        }
        $total = 0;
        foreach ($cart as $item) {
            $total += $item->product->price * $item->amount;
        }
    }

madsynn started a new conversation Blade @include Help

Hi everyone, i was wondering if you guys might be able to help me understand the @include in blade.

I have a blade page i am trying to organize and break into smaller chunks of with the @include in a laravel 5.1 site and keep running into problems.

If i use this according to the laravel docs it should get all the same data available in the parent.

Even though the included view will inherit all data available in the parent view, you may also pass an array of extra data to the included view:

Problem is it is not working. If i use @inject('model', 'App\Model') some of the data seems to work but on other parts it does not.

I also have a header with a menu item that has to always be present and i cannot get that to keep it looping through the data because on some pages it tells me the variable is not valid and its an incorrect for each.

layout.blade.php
│   └── INCLUDES header.blade.php
│       └── INCLUDES menu-cart.blade.php  (this part needs to show the cart products  and is not working)
└── EXTENDS
    └── index.blade.php
        ├── INCLUDES product-details.blade.php
        ├── INCLUDES product-sidebar.blade.php
        ├── INCLUDES product-features.blade.php
        ├── INCLUDES product-options.blade.php
        └── INCLUDES product-additional.blade.php

The menu-cart.blade.php is the component i need to loop through the current user or guests car at all times.

All the includes inside the index.blade.php are wrapped in a foreach on the index.blade.php but when i try and get data back using something like this {!!$product->name !!} i get a invalid foreach loop variable products is not valid.

Please tell me what you think please.

madsynn left a reply on Sentinel:: Help

Anyone?

07 Oct
2 years ago

madsynn started a new conversation Retrieve Multiple Fields From Another Model As Select

Can anyone tell me how i would go about creating the relationship that would allow me to pull multiple fields from one model to another almost like a mirror copy but in a different area of the site.

Explination example:

ProductsModel table fields:

  • name
  • upc
  • price
  • sku
  • barcode

Warehouse Model table fields:

  • name = name from products
  • upc = upc from products
  • price = price from products
  • barcode = barcode from products

madsynn left a reply on Where Are You All From?

Salt Lake City UT Here!!

06 Oct
2 years ago

madsynn left a reply on Sentinel:: Help

@wallyjaw Thanks for your reply but not quite what i need. I will post my whole function for you to see. Maybe you can see my error.


    public static function getPageInfo(&$cart,&$total)
    {
        if (Sentinel::check()) {
            $cart = Sentinel::getUser()->cart;
        } else {
            $cart = new Collection;
            if (Session::has('cart')) {
                foreach (Session::get('cart') as $item) {
                    $elem = new Cart;
                    $elem->product_id = $item['product_id'];
                    $elem->amount = $item['quantity'];
                    if (isset($item['options'])) {
                        $elem->options = $item['options'];
                    }
                    $cart->add($elem);
                }
            }
        }
        $total = 0;
// THIS IS WHERE I AM GETTING AN ERROR IS KEEPS SAYING 
// ErrorExceptionapp/Ecommerce/helperFunctions.php in handleError

        foreach ($cart as $item) {
            $total += $item->product->price*$item->amount;
        }
    }