madsynn

madsynn

Member Since 3 Years Ago

Experience Points 7,460
Experience
Level
Lessons Completed 66
Lessons
Completed
Best Reply Awards 0
Best Answer
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.

18 Oct
3 weeks 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);

        }

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>
11 Oct
1 month ago

madsynn started a new conversation Help Trying To Table In Markdown

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

| 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

| PARENT CAT | FIRST SUBCAT | SECOND SUBCAT | THIRD SUBCAT | FORTH SUBCAT | FIFTH SUBCAT | | --- | --- | --- | --- | --- | --- | | 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
2 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 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
7 months 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
9 months 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
9 months 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.

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
10 months 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
11 months 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
11 months 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
11 months 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
1 year 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
1 year 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,
        'clearcache' => \App\Http\Middleware\ClearCache::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

new file i am having trouble with

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 Help

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

1

  public static function getPageInfo(&$cart,&$total)
    {
        if (Sentinel::check()) {
            $cart = Sentinel::getUser()->cart;
        }
}

2

if (Sentinel::check()) {
            $exists = 0;
            if (Session::has('cart')) {
                foreach (Session::get('cart') as $key => $cart) {
                    if ($cart['product_id'] == $product_id) {
                        $cart['quantity'] += $request->quantity;
                        if ($cart['quantity'] <= 0) {
                            $cart['quantity'] = 1;
                        }

3

$userCart = Sentinel::getUser()->cart;

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;
        foreach ($cart as $item) {
            $total += $item->product->price*$item->amount;
        }
    }

madsynn started a new conversation Sentinel Help

How can i get the user email using sentinel?

Sentinel::getUser()->email

madsynn left a reply on Sentinal And Helper File Issue

The file;

<?php namespace Ecommerce;

use App\Models\Section;
use App\Models\Cart;

use Sentinel;
use Session;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Support\Collection;

class helperFunctions
{
    public static function getPageInfo(&$sections,&$cart,&$total)
    {
        $sections = Section::all();
        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 left a reply on Sentinal And Helper File Issue

@Snapey

Can you see what my problem is i keep getting this error on the helperFunctions.php

ErrorExceptionapp/Ecommerce/helperFunctions.php in handleError

Thanks

05 Oct
2 years ago

madsynn left a reply on Sentinal And Helper File Issue

Can any one help ?

03 Oct
2 years ago

madsynn started a new conversation Sentinal And Helper File Issue

Hope someone can see what i am missing.

I keep getting an error when trying to use helper functions on my index and view pages. It is the mechanism that shows my cart and contents in the head menu on all the pages. I am using Sentinel and i think that might be part of my problem I keep getting this error.

ErrorException in helperFunctions.php line 34:  Invalid argument supplied for foreach()

my helper file:

use App\Models\Section;
use App\Models\Cart;
use App\Models\Option;
use App\Models\Price;

use Sentinel;
use Session;
use \Illuminate\Database\Eloquent\Collection;

class helperFunctions
{
    public static function getPageInfo(&$sections,&$cart,&$total)
    {
        $sections = Section::all();
        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['qty'];
                    if (isset($item['options'])) {
                        $elem->options = $item['options'];
                    }
                    $cart->add($elem);
                }
            }
        }
        $total = 0;
        foreach ($cart as $item) {
            $total += $item->product->price*$item->amount;
        }
    }
}

index function in my productscontroller.php

namespace app\Http\Controllers;

use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Controllers\Controller;
 
use App\Models\Category;
use App\Models\Product;
use App\Models\CategoryProduct;
use App\Models\AlbumPhoto;
use App\Models\Section;
use App\Models\Cart;
use App\Models\Option;
use App\Models\OptionValue;
use App\Models\ProductFeature;
use App\Models\ProductVariant;
use App\Models\OrderProduct;
use File;
use Sentinel;
use App;
use Session;
use \Illuminate\Database\Eloquent\Collection;
use App \Ecommerce\helperFunctions;

class ProductController extends Controller
{
    public function index()
    {
       $new_products = Product::orderBy('created_at', 'desc')->take(12)->get();
        helperFunctions::getPageInfo($sections,$cart,$total);
        return view('frontend.shop.index', compact('new_products','sections', 'cart', 'total'));

    }

the models:


// CART 
class Cart extends Model
{
    protected $table = "cart";
    protected $fillable = ['product_id','amount'];

    public function user()
    {
        return $this->belongsTo(User::class);
    }

    public function product()
    {
        return $this->belongsTo(Product::class);
    }
}

// PRODUCT
lass Product extends Model
{
    protected $table = "products";

    protected $fillable = ['name' , 'manufacturer' , 'price' , 'details' , 'quantity' , 'category_id' , 'thumbnail'];

    public function categories()
    {
        return $this->belongsToMany('App\Category', 'category_product');
    }

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

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

    public function photos()
    {
        return $this->hasMany('App\AlbumPhoto');
    }

    public function options(){
        return $this->hasMany('App\Option');
    }
}
// SECTION
class Section extends Model
{
    protected $table = "sections";
    protected $fillable = ['name'];

    public function categories()
    {
        return $this->hasMany(App\Models\Category::class);
    }
}

If anyone can see what im missing it would be very helpful.

28 Sep
2 years ago

madsynn left a reply on Relationship Not Returning Fields

@Snapey you still around?

27 Sep
2 years ago

madsynn left a reply on Relationship Not Returning Fields

@Snapey

I have been trying this for almost 2 weeks now can you show me an example of how to use the create like you are talking about please. thank you for your patience.

madsynn left a reply on Relationship Not Returning Fields

@Snapey

Question in your profile it says hire me. How much do you charge. I might have you finish getting our cart working but need to know your pricing. You can email me at pmadsen2013 at gmail.com

26 Sep
2 years ago

madsynn left a reply on Relationship Not Returning Fields

@Snapey Sorry about that i thought i clarified it already. I am creating new product with multiple prices. The update stuff you helped me with will probably work great if i can get them created.

madsynn left a reply on Relationship Not Returning Fields

@Snapey Thank you for your response.

instead of the product listing only once it is listing the product for each new product.

What i mean here is in my admin when i got to products.blade.php where i get a list of all the products, when i create a new product with multiple prices it saves as the same product the same number of the alternate prices. Instead of one product.

Don't use the existing price id, and just assign a counter to each row in the table, irrespective if its a new price or not. In the save method, first delete all the old product prices (bear in mind if there is a fault in saving you could lose all the rows), and then create all new prices.

So you are telling me not to use a counter here because it might overwrite the products that are already listed in those rows. correct? how would i add new prices. The product->price has not been created yet so i cannot get the priceID what can i use for this part. i see you use prices[{{ $price->id }}][quantity] with $price->id but until i save the product the price does not have an id correct?

madsynn left a reply on Relationship Not Returning Fields

@Snapey " //needs more thought about handling new prices. This just copes with editing existing ones"

Not sure what you mean here. wouldn't this be handled in the store method. this is the part im having troubles with. the $product = new Product::create(); is the part that will not work for me.

madsynn left a reply on Relationship Not Returning Fields

@Snapey

Thank you for your help i will try them in the morning. I have another question about the saving also. When i does save it saves all new prices but ties them to the product id. which is what its supposed to do. but in my products view in the admin instead of the product listing only once it is listing the product for each new product. Do you know why its doing this. that would be the product.blade.php in the backend/ecom/products/ part of the views.

23 Sep
2 years ago

madsynn left a reply on Relationship Not Returning Fields

@Snapey

I tried what you recommended but to no avail. can you please take a look at my files and see if you can find why i cannot get the prices to save to the database. I have worked on this for a week now and am really frustrated. Do you by chance freelance?

my files are added to this.

https://github.com/madsynn/laravelEcom.git

Thank you for taking the time to help me.