shinigaimi

Experience

4,140

0 Best Reply Awards

  • Member Since 3 Years Ago
  • 37 Lessons Completed
  • 3 Favorites

19th May, 2018

shinigaimi left a reply on Image Intervention + S3 = Weirdness HELP! :( • 4 months ago

I Found a workaround, first saving locally and pulled the locally stored image to S3 and Deleting from local after upload


            foreach ($request->image_upload as $image) {

                //      Store Image with random name
                $path         = $image->store('');
                $get_doc_name = explode('/', $path);

                //
                //  Upload Max File size specified above
                //
                $img_full = Image::make(storage_path('app/documents/' . $get_doc_name[0]));

                $img_full->height() > $img_full->width() ? $width = null : $height = null;
                $img_full->resize($width, $height, function ($constraint) {
                    $constraint->aspectRatio();
                    $constraint->upsize();
                })->orientate();
                //      Replace + Upload re-sized thumbnails to local disk
                $img_full->save(storage_path('app/documents/' . $get_doc_name[0]));
                //      Send Uploaded Image to S3 with unique name
                $name    = Storage::disk('s3')->putFile($file_path, new File(storage_path('app/documents/' . $get_doc_name[0])), 'public');
                $getName = explode('/', $name); //      Default is $getName[6] for image name

//      Delete Thumbnail locally after Upload to S3
                unlink(storage_path('app/documents/' . $get_doc_name[0]));
}

16th May, 2018

shinigaimi started a new conversation Image Intervention + S3 = Weirdness HELP! :( • 4 months ago

I am attempting to Upload a resized image via Image Intervention, does not work! says success but uploads a folder with no extension

Here is code that does not work!

//Global directory in S3 $file_path = 'companies/' . Auth::User()->company_id . '/' . $request->prop_id . '/' . $request->page_id . '/pictures/';

foreach ($request->image_upload as $image) { // // DRIVERS LICENSE UPLOAD // PUTS PICTURES IN USERS FOLDER UNDER "PICTURES FOLDER"

            $image_regular = Image::make($image)->resize($width, $height, function ($constraint) {
                $constraint->aspectRatio();
                $constraint->upsize();
            })->orientate();
            $image_upload  = $image_regular->stream();

            //      Upload to AWS with no file resizing
            Storage::disk('s3')->put($file_path, $image_upload->__string(), 'public');
            dd('uploaded to S3');

}

When it uploads it looks like this ->https://imgur.com/a/iG5EeSK

I am able to upload to S3 normally using the code below, this works perfectly fine but I want to resize to a smaller size as you can upload LARGE pictures and I want to create smaller 200x200 thumbnails so the page loads quicker!

        foreach ($request->image_upload as $image) {
            // PUTS PICTURES IN USERS FOLDER UNDER "PICTURES FOLDER"



            //      Upload to AWS with no file resizing
            Storage::disk('s3')->put($file_path, $image, 'public');
            dd('upload to S3');

}

18th July, 2017

shinigaimi left a reply on Eloquent Relationship Via Email Field • 1 year ago

@tisuchi sure, heres the relations

```

Properties.php // displays tenants assigned to specific property that I want to show how many requests are submitted and found via email entered public function tenants() { return $this->hasMany(Tenants::class); }

public function request()
{
    return $this->hasMany(RepairRequest::class);
}

Tenants.php public function property() { return $this->BelongsTo(Properties::class); }

public function request()
{
    return $this->hasMany(RepairRequest::class);
}

RepairRequest.php // This is where everybody submits questions with their emails public function tenants() { return $this->hasMany(Tenants::class); }

17th July, 2017

shinigaimi started a new conversation Eloquent Relationship Via Email Field • 1 year ago

Hey all I am wanting to show specific results when a someone submits a form it will correlate with someone who is already in the database here is how it is setup right now:

Current Query;
$properties = Properties::with('tenants')->get();
        return $properties;
Output
[
{
"id": 1,
"name": "Building 1",
"created_at": "2017-06-10 05:14:59",
"updated_at": "2017-06-10 05:14:59",
"tenants": [
{
"id": 1,
"name": "John Doe",
"email": "[email protected]",
"properties_id": 1,
"created_at": "2017-06-16 21:31:33",
"updated_at": "2017-06-16 21:31:33"
}
]
},
{
"id": 2,
"name": "Building 2",
"created_at": "2017-06-17 00:20:29",
"updated_at": "2017-06-17 00:20:29",
"tenants": []
}
]

I want to also connect to the form model via "Request" I want to be able to connect the "EMAIL" from someone who is in the building 1 and if the user submits a "REQUEST" it will show automatically in the dashboard under that specific user

So if "JOHN DOE" submits 2 requests it will show 2 next to his name and also load those requests

pretty much I want to say that in the Request model IF any request matches "[email protected]" put it with John Doe anything else move to next person etc...

I am stumped, I know how to add another relationship but it gives me property_id error

26th May, 2017

shinigaimi left a reply on Share Wordpress Login With Laravel • 1 year ago

nevermind, I forgot to add this

'wordpress' => [ // this is your Corcel database connection, where WordPress tables are
        'driver'    => 'mysql',
        'host'      => 'localhost',
        'database'  => 'corcel',
        'username'  => 'admin',
        'password'  => 'secret',
        'charset'   => 'utf8',
        'collation' => 'utf8_unicode_ci',
        'prefix'    => 'wp_',
        'strict'    => false,
        'engine'    => null,
    ],

that resolved my error

shinigaimi left a reply on Share Wordpress Login With Laravel • 1 year ago

I have followed the doc to share the login and It gave me the following error

QueryException in Connection.php line 647:
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'user_email' in 'where clause' (SQL: select * from users where user_email = [email protected] order by user_registered desc limit 1)

the Laravel DB is the same as the WP Database

shinigaimi started a new conversation Share Wordpress Login With Laravel • 1 year ago

Hey all, I am trying to share login credentials between WordPress and laravel, I found a project called corcel but I didn't see if it shared logins.

I am creating an eCommerce site that has a shopping cart etc

17th May, 2017

shinigaimi left a reply on Moved From Localhost To Another Localhost • 1 year ago

@TylerODonnell it was missing, I had it backed up the backup had the config/view.php

<?php

return [

    /*
    |--------------------------------------------------------------------------
    | View Storage Paths
    |--------------------------------------------------------------------------
    |
    | Most templating systems load templates from disk. Here you may specify
    | an array of paths that should be checked for your views. Of course
    | the usual Laravel view path has already been registered for you.
    |
    */

    'paths' => [
        resource_path('views'),
    ],

    /*
    |--------------------------------------------------------------------------
    | Compiled View Path
    |--------------------------------------------------------------------------
    |
    | This option determines where all the compiled Blade templates will be
    | stored for your application. Typically, this is within the storage
    | directory. However, as usual, you are free to change this value.
    |
    */

    'compiled' => realpath(storage_path('framework/views')),

];

so strange that it was not copied over. ugh so frustrating!

shinigaimi left a reply on Moved From Localhost To Another Localhost • 1 year ago

@MaverickChan do you have any other ideas ? :(

16th May, 2017

shinigaimi left a reply on Moved From Localhost To Another Localhost • 1 year ago

heres some info

Server Configuration
Apache Version:
2.4.23  - Documentation
PHP Version:
7.0.10  - Documentation
Server Software:
Apache/2.4.23 (Win64) PHP/7.0.10 - Port defined for Apache: 80
Loaded Extensions :
apache2handlerbcmathbz2calendarcom_dotnetCorectypecurldatedomexiffileinfofiltergdgettextgmphashiconvimapintljsonldaplibxmlmbstringmcryptmysqlimysqlndopensslpcrePDOpdo_mysqlpdo_sqlitePharReflectionsessionSimpleXMLsoapsocketsSPLsqlite3standardtokenizerwddxxdebugxmlxmlreaderxmlrpcxmlwriterxslZend OPcachezipzlib
MySQL Version:
5.7.14 - Port defined for MySQL: 3306 -  Documentation

shinigaimi left a reply on Moved From Localhost To Another Localhost • 1 year ago

I ran the "composer update" again and got the same error

Generating autoload files
> Illuminate\Foundation\ComposerScripts::postUpdate
> php artisan optimize


  [ErrorException]
  Argument 2 passed to Illuminate\View\FileViewFinder::__construct() must be of the type array, null given, called in
   C:\wamp64\www\telemarketing-leaderboard\vendor\laravel\framework\src\Illuminate\View\ViewServiceProvider.php on li
  ne 64 and defined


Script php artisan optimize handling the post-update-cmd event returned with error code 1

shinigaimi left a reply on Moved From Localhost To Another Localhost • 1 year ago

@jlrdw when I try those commands I get an error also same thing

C:\wamp64\www\sunfield>php artisan config:cache


  [ErrorException]
  Argument 2 passed to Illuminate\View\FileViewFinder::__construct() must be of the type array, null given, called in
   C:\wamp64\www\sunfield\vendor\laravel\framework\src\Illuminate\View\ViewServiceProvider.php on line 64 and defined

shinigaimi started a new conversation Moved From Localhost To Another Localhost • 1 year ago

Just moved to another local dev computer moved project and now I am receiving the following error,

FatalThrowableError in FileViewFinder.php line 53:
Type error: Argument 2 passed to Illuminate\View\FileViewFinder::__construct() must be of the type array, null given, called in C:\wamp64\www\projects\sunfield\vendor\laravel\framework\src\Illuminate\View\ViewServiceProvider.php on line 64

shinigaimi left a reply on Reformated Local Dev Computer • 1 year ago

here is the error log,

[2017-05-16 05:53:24] local.ERROR: exception 'ErrorException' with message 'Argument 2 passed to Illuminate\View\FileViewFinder::__construct() must be of the type array, null given, called in C:\wamp64\www\projects\telemarketing-leaderboard\vendor\laravel\framework\src\Illuminate\View\ViewServiceProvider.php on line 64 and defined' in C:\wamp64\www\projects\telemarketing-leaderboard\vendor\laravel\framework\src\Illuminate\View\FileViewFinder.php:53
Stack trace:
#0 C:\wamp64\www\projects\telemarketing-leaderboard\vendor\laravel\framework\src\Illuminate\View\FileViewFinder.php(53): Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(4096, 'Argument 2 pass...', 'C:\\wamp64\\www\\p...', 53, Array)
#1 C:\wamp64\www\projects\telemarketing-leaderboard\vendor\laravel\framework\src\Illuminate\View\ViewServiceProvider.php(64): Illuminate\View\FileViewFinder->__construct(Object(Illuminate\Filesystem\Filesystem), NULL)
#2 C:\wamp64\www\projects\telemarketing-leaderboard\vendor\laravel\framework\src\Illuminate\Container\Container.php(716): Illuminate\View\ViewServiceProvider->Illuminate\View\{closure}(Object(Illuminate\Foundation\Application), Array)
#3 C:\wamp64\www\projects\telemarketing-leaderboard\vendor\laravel\framework\src\Illuminate\Container\Container.php(598): Illuminate\Container\Container->build(Object(Closure))
#4 C:\wamp64\www\projects\telemarketing-leaderboard\vendor\laravel\framework\src\Illuminate\Container\Container.php(567): Illuminate\Container\Container->resolve('view.finder')
#5 C:\wamp64\www\projects\telemarketing-leaderboard\vendor\laravel\framework\src\Illuminate\Foundation\Application.php(702): Illuminate\Container\Container->make('view.finder')
#6 C:\wamp64\www\projects\telemarketing-leaderboard\vendor\laravel\framework\src\Illuminate\Container\Container.php(1139): Illuminate\Foundation\Application->make('view.finder')
#7 C:\wamp64\www\projects\telemarketing-leaderboard\vendor\laravel\framework\src\Illuminate\View\ViewServiceProvider.php(41): Illuminate\Container\Container->offsetGet('view.finder')
#8 C:\wamp64\www\projects\telemarketing-leaderboard\vendor\laravel\framework\src\Illuminate\Container\Container.php(716): Illuminate\View\ViewServiceProvider->Illuminate\View\{closure}(Object(Illuminate\Foundation\Application), Array)
#9 C:\wamp64\www\projects\telemarketing-leaderboard\vendor\laravel\framework\src\Illuminate\Container\Container.php(598): Illuminate\Container\Container->build(Object(Closure))
#10 C:\wamp64\www\projects\telemarketing-leaderboard\vendor\laravel\framework\src\Illuminate\Container\Container.php(567): Illuminate\Container\Container->resolve('view')
#11 C:\wamp64\www\projects\telemarketing-leaderboard\vendor\laravel\framework\src\Illuminate\Foundation\Application.php(702): Illuminate\Container\Container->make('view')
#12 C:\wamp64\www\projects\telemarketing-leaderboard\vendor\laravel\framework\src\Illuminate\Container\Container.php(1139): Illuminate\Foundation\Application->make('view')
#13 C:\wamp64\www\projects\telemarketing-leaderboard\vendor\laravel\framework\src\Illuminate\Support\ServiceProvider.php(88): Illuminate\Container\Container->offsetGet('view')
#14 C:\wamp64\www\projects\telemarketing-leaderboard\vendor\laravel\framework\src\Illuminate\Notifications\NotificationServiceProvider.php(18): Illuminate\Support\ServiceProvider->loadViewsFrom('C:\\wamp64\\www\\p...', 'notifications')
#15 [internal function]: Illuminate\Notifications\NotificationServiceProvider->boot()
#16 C:\wamp64\www\projects\telemarketing-leaderboard\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php(30): call_user_func_array(Array, Array)
#17 C:\wamp64\www\projects\telemarketing-leaderboard\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php(87): Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()
#18 C:\wamp64\www\projects\telemarketing-leaderboard\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php(31): Illuminate\Container\BoundMethod::callBoundMethod(Object(Illuminate\Foundation\Application), Array, Object(Closure))
#19 C:\wamp64\www\projects\telemarketing-leaderboard\vendor\laravel\framework\src\Illuminate\Container\Container.php(531): Illuminate\Container\BoundMethod::call(Object(Illuminate\Foundation\Application), Array, Array, NULL)
#20 C:\wamp64\www\projects\telemarketing-leaderboard\vendor\laravel\framework\src\Illuminate\Foundation\Application.php(762): Illuminate\Container\Container->call(Array)
#21 C:\wamp64\www\projects\telemarketing-leaderboard\vendor\laravel\framework\src\Illuminate\Foundation\Application.php(745): Illuminate\Foundation\Application->bootProvider(Object(Illuminate\Notifications\NotificationServiceProvider))
#22 [internal function]: Illuminate\Foundation\Application->Illuminate\Foundation\{closure}(Object(Illuminate\Notifications\NotificationServiceProvider), 10)
#23 C:\wamp64\www\projects\telemarketing-leaderboard\vendor\laravel\framework\src\Illuminate\Foundation\Application.php(746): array_walk(Array, Object(Closure))
#24 C:\wamp64\www\projects\telemarketing-leaderboard\vendor\laravel\framework\src\Illuminate\Foundation\Bootstrap\BootProviders.php(17): Illuminate\Foundation\Application->boot()
#25 C:\wamp64\www\projects\telemarketing-leaderboard\vendor\laravel\framework\src\Illuminate\Foundation\Application.php(208): Illuminate\Foundation\Bootstrap\BootProviders->bootstrap(Object(Illuminate\Foundation\Application))
#26 C:\wamp64\www\projects\telemarketing-leaderboard\vendor\laravel\framework\src\Illuminate\Foundation\Console\Kernel.php(270): Illuminate\Foundation\Application->bootstrapWith(Array)
#27 C:\wamp64\www\projects\telemarketing-leaderboard\vendor\laravel\framework\src\Illuminate\Foundation\Console\Kernel.php(115): Illuminate\Foundation\Console\Kernel->bootstrap()
#28 C:\wamp64\www\projects\telemarketing-leaderboard\artisan(36): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#29 {main}  

shinigaimi started a new conversation Reformated Local Dev Computer • 1 year ago

as the title says, I Just reformated my local dev computer and now I am receiving the following error

FatalThrowableError in FileViewFinder.php line 53:
Type error: Argument 2 passed to Illuminate\View\FileViewFinder::__construct() must be of the type array, null given, called in C:\wamp64\www\projects\sunfield\vendor\laravel\framework\src\Illuminate\View\ViewServiceProvider.php on line 64

21st April, 2017

shinigaimi started a new conversation Wordpress + Laravel Backend ?? • 1 year ago

Hey Guys,

I am in the process of setting up an eCommerce store on a WordPress for the e-commerce and Laravel for the backend only accessible for people with active subscriptions,

I am having the hardest time figuring out how to use Laravel auth system vs WordPress but have laravel check to make sure user has active sub.

I found that laracast has a system on accepting payments https://laracasts.com/series/how-to-accept-payments-with-stripe

was thinking if it would be easier to setup the ENTIRE site via laravel or do the 50/50 mix Wordpress/Laravel

What do you guys think?

13th April, 2017

shinigaimi left a reply on SQLSTATE[42000]: Syntax Error Or Access Violation: 1055 'q_answers.id' Isn't In GROUP BY • 1 year ago

nope that didnt work either :( im curious why it works on my local computer but not in production

shinigaimi left a reply on SQLSTATE[42000]: Syntax Error Or Access Violation: 1055 'q_answers.id' Isn't In GROUP BY • 1 year ago

@jimmck like this?

$fAQ = QAnswers::select(DB::raw('select q_answers.*, sum(answered) as answered'))
                    ->join('q_a_comments', 'q_answers.id', '=', 'q_a_comments.q_answers_id')
                    ->groupBy('q_answers_id')
                    ->where('answered', '>=', 1)
                    ->filter(request(['help']))
                    ->get();

that what you mean ? hmm

shinigaimi started a new conversation SQLSTATE[42000]: Syntax Error Or Access Violation: 1055 'q_answers.id' Isn't In GROUP BY • 1 year ago

Hey guys I am confused on my local server I receive 0 errors but when it's in production I am receiving this following error

SQLSTATE[42000]: Syntax error or access violation: 1055 'shinigai_tele-fun.q_answers.id' isn't in GROUP BY (SQL: select q_answers.*, sum(answered) as answered from `q_answers` inner join `q_a_comments` on `q_answers`.`id` = `q_a_comments`.`q_answers_id` where `answered` >= 1 and `category` = General group by `q_answers_id`)

Here's the code that is causing all the drama

$fAQ = QAnswers::select(DB::raw('q_answers.*, sum(answered) as answered'))
                    ->join('q_a_comments', 'q_answers.id', '=', 'q_a_comments.q_answers_id')
                    ->groupBy('q_answers_id')
                    ->where('answered', '>=', 1)
                    ->filter(request(['help']))
                    ->get();

so strange!

12th April, 2017

shinigaimi left a reply on Not Loading Relationship • 1 year ago

@willvincent yeah def I only displayed EXACTLY what I needed :) I am still learning laravel so this is a fun project :D appreciate the help though! :D

shinigaimi left a reply on Not Loading Relationship • 1 year ago

@willvincent thanks! :D

I figured out a different approach

        public function index(Winners $winner)
        {
            $winner = Winners::select(DB::raw('winners.*, sum(points) as total_points'))
                ->join('points', 'winners.id', '=', 'points.winners_id')
                ->groupBy('winners_id')
                ->orderBy('total_points', 'desc')
                ->get();
            
            return view('winners.index', compact('winner'));
        }

and it produces this which is actually better :)

[
{
"id": 1,
"user_id": 1,
"name": "John Doe",
"status": "active",
"created_at": "2017-04-11 17:16:10",
"updated_at": "2017-04-11 17:16:10",
"total_points": "13"
},
{
"id": 3,
"user_id": 1,
"name": "User #3",
"status": "active",
"created_at": "2017-04-11 17:16:30",
"updated_at": "2017-04-11 17:16:30",
"total_points": "4"
}
]

11th April, 2017

shinigaimi left a reply on Not Loading Relationship • 1 year ago

@willvincent yeah I figured it out :) what's the difference between load / with? I am new to laravel :) I will have to look into it

Also how do I orderBy('total_points) ?I am unable to get it to work

[
{
"id": 1,
"user_id": 1,
"name": "John Doe",
"status": "active",
"created_at": "2017-04-11 17:16:10",
"updated_at": "2017-04-11 17:16:10",
"points": [
{
"winners_id": 1,
"total_points": "10"
}
]
},
{
"id": 2,
"user_id": 1,
"name": "User #2",
"status": "active",
"created_at": "2017-04-11 17:16:24",
"updated_at": "2017-04-11 17:16:24",
"points": [
{
"winners_id": 2,
"total_points": "3"
}
]
},

shinigaimi left a reply on Not Loading Relationship • 1 year ago

@Indemnity83 I tried your code snippet but didn't work :( gave error

ErrorException in WinnersController.php line 32:
Non-static method Illuminate\Database\Eloquent\Model::load() should not be called statically

BUT I was able to figure it out via

$winner->load(['points' => function ($query) {
                $query->selectRaw('winners_id, SUM(points) total_points')->groupBy('winners_id')->orderBy('total_points', 'desc');
            }]);

Now I am trying to sort the results via "total_points" but it doesn't do anything WTF ?

shinigaimi started a new conversation Not Loading Relationship • 1 year ago

Hey guys, I am trying to SUM certain field in a relationship to display the total "points" but it doesnt want to load the relationship :(

        public function index(Winners $winner)
        {
            
            $winner = Winners::all();
//          $winner->load('points');
            $winner->load(['points' => function ($query) {
                $query->selectRaw('sum(points) as points_count')
                    ->groupBy('points')->get();
            }]);
            
            return view('winners.index', compact('winner'));
        }

it will produce the main method but not relationship

[
{
"id": 1,
"user_id": 1,
"name": "John Doe",
"status": "active",
"created_at": "2017-04-11 17:16:10",
"updated_at": "2017-04-11 17:16:10",
"points": []
},
{
"id": 2,
"user_id": 1,
"name": "User #2",
"status": "active",
"created_at": "2017-04-11 17:16:24",
"updated_at": "2017-04-11 17:16:24",
"points": []
},
{
"id": 3,
"user_id": 1,
"name": "User #3",
"status": "active",
"created_at": "2017-04-11 17:16:30",
"updated_at": "2017-04-11 17:16:30",
"points": []
}
]

2nd April, 2017

shinigaimi left a reply on Eloquent Relationships • 1 year ago

aergh

shinigaimi left a reply on Eloquent Relationships • 1 year ago

I figured on how to add the points for each winner via

WinnersController

        public function index(Winners $winner)
        {
            
            $winner = Winners::all();
            $winner->load('points');
            
            return view('winners.index', compact('winner'));
        }

and the output is displaying what I am asking BUT I want to get a TOTAL of the points

[
{
"id": 1,
"name": "John Doe",
"status": "active",
"created_at": "2017-04-01 20:07:52",
"updated_at": "2017-04-01 20:07:52",
"points": [
{
"id": 1,
"winners_id": 1,
"points": 5,
"body": "bahaerh",
"created_at": "2017-04-01 20:10:43",
"updated_at": "2017-04-01 20:10:43"
},
{
"id": 3,
"winners_id": 1,
"points": 4,
"body": "AWEGAERWG",
"created_at": "2017-04-02 04:20:03",
"updated_at": "2017-04-02 04:20:03"
}
]
},
{
"id": 2,
"name": "Jane Doe",
"status": "active",
"created_at": "2017-04-01 20:57:10",
"updated_at": "2017-04-01 20:57:10",
"points": [
{
"id": 2,
"winners_id": 2,
"points": 5,
"body": "aweg",
"created_at": "2017-04-01 21:46:40",
"updated_at": "2017-04-01 21:46:40"
}
]
}
]

in the above example John Doe would output a total of 9 Points AND jane Doe would output 5 points is this possible? and how? :)

31st March, 2017

shinigaimi left a reply on Eloquent Relationships • 1 year ago

I want to be able to count total, as an example

User X has 5pts , 2pts, 3pts assigned to his account, I want to SUM all his points and display the total but also OrderBy that new SUM. So if another use has a TOTAL of 5 points he is in 2nd place etc.

I did find the follow information https://laravel.com/docs/5.4/queries#aggregates

$price = DB::table('points')->sum('points');

but I am unsure if that new query goes into my controller

        public function index(Winners $winner)
        {
            $price = DB::table('points')->sum('points');
            
            return view('winners.index', compact('winner'));
        }

if so how is it used? I am a little confused on this aspect! :(

shinigaimi started a new conversation Eloquent Relationships • 1 year ago

Hey everyoneI am trying to get a total of "points" from a table that has a relationship

WinnersController.php

            $winner = Winners::with('points')->get();
            
            return view('winners.index', compact('winner'));

Winners.php (model)

public function points()
        {
            return $this->hasMany(Points::class)->orderBy('id', 'desc');
        }

I am attempting to get a total of "points" and sort by that total

24th March, 2017

shinigaimi started a new conversation Controller Redirect To Website Or Route? • 1 year ago

I am trying to force a redirect in a controller I am unable to get it to redirect in the controller but I am in the routes.

    Route::get('/challenge', function () {
        return redirect()->away('http://website.dev/');
    });

In the controller its not redirecting to the route

        public function __construct()
        {
            // CHECK TO SEE IF USER LOGGED IN VIA WORDPRESS
            if(!is_user_logged_in()){
                return \Redirect::away('/test');
            } else {
                echo "<h1>LOGGED IN</h1>";
            }
        }

If it is possible to redirect via the controller to a website that would be more efficient, I am so confused lol normally I would just do a PHP redirect so easy lol but I am learning the Laravel way!

   header( 'Location: http://www.yoursite.com/new_page.html' ) ;

22nd March, 2017

shinigaimi left a reply on Import Files Composer.json • 1 year ago

this is for WordPress, i

shinigaimi started a new conversation Import Files Composer.json • 1 year ago

Hey guys, IM trying to import a file with all its functions,

"files": [
            "wp-blog-header.php"
        ],

if I test a dummy page not laravel it works just fine I am able to do

    require('../wp-blog-header.php');

and load what I need like

        $current_user = wp_get_current_user();
        /**
         * @example Safe usage: $current_user = wp_get_current_user();
         * if ( !($current_user instanceof WP_User) )
         *     return;
         */
        echo 'Username: ' . $current_user->user_login . '<br />';

this works just fine BUT when I try to do this with larval it breaks!

I am importing the file via composer.json

"files": [
            "wp-blog-header.php",
        ],

but it produces this error

ErrorException in 44625c55fbcc3ae8accfaec47732d73f8468c833.php line 3:
Call to undefined function is_user_logged_in() (View: C:\wamp64\www\sunfield\resources\views\moveouts\index.blade.php)

is there a way to import the initial file plus any dependencies ?

shinigaimi started a new conversation Sharing Login Between Laravel & Wordpress • 1 year ago

Hey all I am having a tough time I found literally what my question was here is a quote from a previous post Pretty much I have a woocommerce store with subs etc and creating a dashboard for services purchased so they can access what they've purchased.

"We are using WordPress as our store (using woocommerce). our backend use laravel where users who bought our services can use and manage the services they bought from us. we will eventually move to custom implementation of our store in laravel but right now we don't want to break anything. what i want is to integrate wordpress and laravels login so they don't have to login or register twice. something like github use (if you login at github you are automatically logged in at gist). both laravel and wordpress will use different database (or user tables at least). i can create a user in laravel when someone register at wordpress. but i have no clue how to share login session. why both ? we are using different readily available plugins of woocommerce (multiple subscriptions, addons, product variants etc) which will take a lot of time to port to laravel. any help would be great"

and the solution that they gave was given was

Route::get('/wordpress', function(){ require('..\wordpress\wp-load.php'); return loginUser(Auth::user()->username); });

This part goes in the wordpress function.php function loginFunction($username){ $user_id = username_exists($username); $userdata = get_userdata($user_id); $user = set_current_user($user_id,$username); wp_set_auth_cookie($user_id); do_action('wp_login',$userdata->ID); // you can redirect the authenticated user to the "logged-in-page", define('MY_PROFILE_PAGE',1); f.e. first header("Location:".get_page_link(MY_PROFILE_PAGE)); }

but when I do this I am given an error when I load the /wordpress route

FatalErrorException in l10n.php line 203: Cannot redeclare __() (previously declared in C:\wamp64\www\sunfield\vendor\laravel\framework\src\Illuminate\Foundation\helpers.php:848)

This is a brand new project and I am getting this error :( here's a link to the original post: https://laracasts.com/discuss/channels/general-discussion/sharing-login-between-laravel-wordpress?page=1

if you guys know of a much easier way to incorporate this login system across both platforms I would love to hear!

21st March, 2017

shinigaimi left a reply on Laravel And Wordpress • 1 year ago

I was thinking of importing my Laravel library and putting WordPress in the "public" folder and working off that structure so I can set up my routing for the dashboard to work without a subdomain

shinigaimi started a new conversation Laravel And Wordpress • 1 year ago

Hey all,

I am in the process of setting up an e-commerce store via WordPress and a dashboard created via Laravel for the dashboard.

My question is what do you guys would be the best way to accomplish this? to piggyback off from the WordPress login system to authenticate and handle that aspect to either grant or deny access to dashboard features.

I am very new to Laravel and started crafting apps and wanted to use this as my next project to get familiar with.

Eventually, I want to migrate everything from the Wordpress (e-commerce) + Laravel (dashboard) to EVERYTHING Laravel but that will take too long and I want to open the doors sooner than later so I can get the ball rolling on the business.

28th February, 2017

shinigaimi left a reply on HTML Form To Database • 1 year ago

@slewis

I think I will use the

    protected $guarded = ['price', 'user_id'];

as it will ALLOW everything BUT PROTECT very specific items like "user_id" "price" or other unique ID's that I don't want to have manipulated.

27th February, 2017

shinigaimi left a reply on HTML Form To Database • 1 year ago

if I use the below command will it protect from injection to protect "user_id" etc

public function store(Request $request) { $this->validate($request, [ 'title' => 'required', 'body' => 'required' ]);

    MoveOut::create($request->all());
    
    return redirect('/');
}

the below command is my guarded model to project in the future "user_id" and other information that I dont want to be altered by some bad guys

class Model extends Eloquent
{
    
    // Protects only whats listed like user_id, allows everything else
    // Empty [] means protecting no field
    protected $guarded = [];
}

I understand that currently its not protecting any variables but that is currently by design :)

shinigaimi left a reply on HTML Form To Database • 1 year ago

I was just curious, :)

I am currently doing this;

    public function store(Request $request)
    {
        $this->validate(request(), [
            'title' => 'required',
            'body'  => 'required',
        
        ]);
        
        MoveOut::create(request([
                                    'title',
                                    'body',
                                ]));
        
        return redirect('/');
    }

I guess I will leave it alone and go about my coding Lol :) I am just learning from the tutorials : ) but I am building my first project right now

shinigaimi started a new conversation HTML Form To Database • 1 year ago

Hello All,

I am brand spanking new to Laravel I am building a form with around 20 form fields with assorted fields text, drop downs etc

My question is what would be the best way to store this information in a database?

if I do a dd(request()->all()); it will spit out an array I could turn it into json or leave as an array

would appreciate some good tips to minimize the space.

Thanks!

Edit Your Profile
Update

Want to change your profile photo? We pull from gravatar.com.