Cinek

Experience

17,520

30 Best Reply Awards

  • Member Since 10 Months Ago
  • 1 Lesson Completed
  • 0 Favorites

13th June, 2018

Cinek left a reply on Write User Information To Database On Every Request In Background • 5 days ago

@uchihaabhi yes, you can use middleware to do it:

class MyLogMiddleware {
public function handle(Request $request, Closure $next)
    {
    $requestData = $request->all();
Log::info($requestData);
$responseData = $next($request);
Log::info($responseData);
        return $responseData ;
}
}

7th June, 2018

Cinek left a reply on Laratrust Middleware Returns An Error When Permissions Check • 1 week ago

Have you used LaratrustUserTrait in your User model?

30th May, 2018

Cinek left a reply on Not Getting The Views • 2 weeks ago

You are redirect to name_of_categories not number_of_categories

14th May, 2018

Cinek left a reply on GroupBy And OrderBy On Relationship • 1 month ago

$tags = Tag::with(['faqs' => function($query){
            $query->orderBy('sequence','asc');
        }])->get();
foreach($tas as $tag){
    foreach($tag->faqs as $faq){
        ....
    }
}

10th May, 2018

Cinek left a reply on Get Posts By Balls, Rating, Votes And Rating Count • 1 month ago

You can use double orderBy clause:

Post::where(....)->orderBy('balls','desc')->orderBy('votes','desc');

26th April, 2018

Cinek left a reply on FirstOrCreate Does Not Update Properly • 1 month ago

Look at the source of firstOrCreate method:

public function firstOrCreate(array $attributes, array $values = [])
    {
        if (! is_null($instance = $this->where($attributes)->first())) {
            return $instance;
        }
        $instance = $this->model->newInstance($attributes + $values);
        $instance->save();
        return $instance;
    }

If object exists it only return this object, not updating. Try to use updateOrCreate.

Cinek left a reply on How Can I Send One Query Result (via Variable) Into An Other Query • 1 month ago

chef_food_ethics and food_ethic_managers should have same quantity of columns. You can use select to specify which columns should be selected in both queries.

Can you tell me what you want to do?

Cinek left a reply on Not Getting Distinct Result. • 1 month ago

Yes, this query returns unique results but unique based on all columns Invitelist. This is your query:

select distinct * from invitelist where unsubscribe = 0 order by companylist_id

distinct does not accept any parameters. This should work:

$invitelist = Invitelist::select('email')->where('unsubscribe', 0)->distinct()->get();

22nd April, 2018

Cinek left a reply on Service Provider Not Publishing Config File • 1 month ago

Is __DIR__ . '/../config/generator.php a good path for sure? In which directory is your GeneratorServiceProvider?

Cinek left a reply on Composer Install Error After Git Clone • 1 month ago

when does this error occur? What laravel version do you use?

19th April, 2018

Cinek left a reply on Relationship Problems: Collectors Favourite Book • 1 month ago

public function favourite_book()
    {
        return $this->hasOne(Book::class, 'id', favourite_book_id');
    }

Cinek left a reply on Return Response (json) And Abort • 1 month ago

You are returning response()->json() from validateData function, not from controller. To stop controller method you should do return $this->validateData();.

13th April, 2018

Cinek left a reply on Can We Use Where Clause With Laravel Update • 2 months ago

If you want to update many object at the same time you can do this:

$data = [
'post_title' => $request->input('title'),
'updated_at' => date('Y-m-d h:i:s'),
....
];
Post::where(.....)->update($data);

12th April, 2018

Cinek left a reply on Eloquent Multiple Relationship With Condition • 2 months ago

Are you sure that $this->society is always 'A' or 'B' and there are no other values like 'a', 'b' or null?

Cinek left a reply on After Foreach It Show Two Arrays [] [] How To Merge In [] • 2 months ago

At first, Post::whereUserId($myFriend->friend_id)->get() returns a Laravel Collection, not an array so you should use:

$FriendPostsCollections = collect();
        foreach ($myFriends as $myFriend) {
            $FriendPostsCollections = $FriendPostsCollections->merge(Post::whereUserId($myFriend->friend_id)->get());
        }
        dd($FriendPostsCollections);

but in this case you do so many queries to DB. Better solution is:

        $ids = $myFriends->pluck('friend_id')->toArray();
        $FriendPostsCollections = Post::whereIn('user_id', $ids);

11th April, 2018

Cinek left a reply on How Can I Query By User Input? • 2 months ago

What does it mean "this code is not work"? We need more details

Cinek left a reply on Variable From The Function Parameter To Querying Relationship (whereHas) • 2 months ago

You should use php use http://php.net/manual/en/functions.anonymous.php#example-165

$product_with_subcategory = Product::whereHas('subcategories', function ($query) use ($subkategoria) {
            $query->where('name', $subkategoria);
        })->get();

10th April, 2018

Cinek left a reply on Filter Eloquent Query With Many To Many Relationship Table • 2 months ago

Can you show your roles relation in User model?

Cinek left a reply on How To Redirect The User To The Same Page After Login? • 2 months ago

You can store previous url in session when login form has been opened(in showLoginForm method) and redirect to this url when user will be authenticated.

Cinek left a reply on Laravel HTTP Error 500 After Deployment • 2 months ago

paste the error located in /storage/logs/laravel.log

Cinek left a reply on Guzzle - Who Can Help Me Any Kind Of Guzzle Related Issue ? • 2 months ago

$call is an object, not an array of objects so you can't use foreach on $call variable. You can do something like this:

{{$call->action }} @foreach($call->message as $message) {{$message->FacilityName }} @endforeach

Cinek left a reply on Change Default Login Redirect Url • 2 months ago

In Exceptions/Handler.php override the unauthenticated method.

8th April, 2018

Cinek left a reply on Laravel Insert One More Record After Str_replace Function: Why? • 2 months ago

Look,

Token::insert($insert_arr);

is executed in foreach, so it will be executed as many times as there are elements in $cmds. Put this after a foreach brace. Remember to declare $insert_arr = []; before foreach because it will throw an error when $cmds will be empty.

Cinek left a reply on Display Related Posts Except For A Specific Post • 2 months ago

Add ->where('id','!=',$id) to your query:

$related_posts = Blog::with('category')->where('blogcategory_id', '=', 
$show_blog_post->blogcategory_id)->where('id','!=',$id)->get();

6th April, 2018

Cinek left a reply on How To Pass The Price To The Payment Page? • 2 months ago

and remember to change your blade tickets[{{ $ticket->title }}] to tickets[{{ $ticket->id }}] my mistake.

Cinek left a reply on How To Pass The Price To The Payment Page? • 2 months ago

You can create and use custom validator: https://laravel.com/docs/5.6/validation#custom-validation-rules

Cinek left a reply on How To Pass The Price To The Payment Page? • 2 months ago

You can:

<select name=tickets[{{ $ticket->title }}]>
                    <option selected>0</option>
                     <option value="1">1</option>
                     ....
                </select>

and in controller read only a selected quantity for each ticket, without price. The price will be fetched from DB in controller. Something like this:

$ticketQuantities = $request->get('tickets');
foreach($ticketQuantities as $ticketId => $quantity){
    $ticket = Ticket::find($ticketId);
    $price = $ticket->price;
}

4th April, 2018

Cinek left a reply on Model Not Bringing HasOne Table • 2 months ago

I suggest that you try to install the plugin https://github.com/barryvdh/laravel-debugbar (or other that log all sql queries) and follow all generated queries. It is very helpful with these situations.

Cinek left a reply on Input Checkboxes (checked) From Array Associative • 2 months ago

You don't need a foreach:

<input type="checkbox" name="" value="" {{ !empty($rol->permisos['editar-rol'] ? 'checked' : ''}}>1
<input type="checkbox" name="" value="" {{ !empty($rol->permisos['editar-rol'] ? 'checked' : ''}}>2

Why you have checkbox with editar-rol twice?

Cinek left a reply on Changing Language • 2 months ago

Yes. You must change all of the strings in your "blades" to keys and then translate these keys to each languages, which u want in /resources/lang directory.

Cinek left a reply on Model Not Bringing HasOne Table • 2 months ago

It looks like your season_id in growerProgram is null and then return $this->hasOne('App\Season','season_id'); returns null.

31st March, 2018

Cinek left a reply on Laravel Eloquent One To One Error Trying To Get Property 'id' Of Non-object • 2 months ago

Do all your orders have been assigned a delivery? order_id is able to store null so maybe in one order the address_id is null and $order->delivery is null.

28th March, 2018

Cinek left a reply on Laravel Retrieve Data • 2 months ago

$user = new User();
$user->name = 'test';
$user->save();
$lastInsertIId = $user->id;

Cinek left a reply on Call To A Member Function GetRelationExistenceQuery() On Null • 2 months ago

if ($this->roll->slug == 'student')
        return $this->hasOne('App\Student');
    else if ($this->roll->slug == 'teacher')
        return $this->hasOne('App\Teacher');

You did not handle the case when roll is different than 'student' and 'teacher'.

27th March, 2018

Cinek left a reply on BadMethodCallException In Builder.php Line 2450: Call To Undefined Method Illuminate\Database\Query\Builder::checkSomething() • 2 months ago

$auth_id = Auth::user()->checkSomething($params['id']);

Have you a method checkSomething inside User model?

26th March, 2018

Cinek left a reply on CustomRequest Is Empty In 5.5 • 2 months ago

Let me see your form

23rd March, 2018

Cinek left a reply on Broadcast And Queue Job • 2 months ago

I don't know what happened. I can only recommend you to debug this package.

Cinek left a reply on Broadcast And Queue Job • 2 months ago

Which version of predis package do you use?

Cinek left a reply on Search Whith Laravel • 2 months ago

Can you explain what does it mean " but did not work"?

22nd March, 2018

Cinek left a reply on ChartJS Not Accepting String As Data, How Do I Pass Non-string • 2 months ago

To data you should pass an array of values. If u have string '1, 2, 3, 4, 5' you can split it to array like this:

data: salesByMonth.split(', '); 

21st March, 2018

Cinek left a reply on Calendar Event Scheduling Design • 2 months ago

Try use whereDoesntHave method:

$calendarsWithoutEvents = Calendar::whereDoesntHave('events', function ($query) use ($from, $to) {
            $query->where(function ($query) use ($from) {
                $query->whereDate('start', '<', $from)
                    ->whereDate('end', '>', $from);
            })->orWhere(function ($query) use ($to) {
                $query->whereDate('start', '<', $to)
                    ->whereDate('end', '>', $to);
            })->orWhere(function ($query) use ($from, $to) {
                $query->whereDate('start', '>', $from)
                    ->whereDate('end', '<', $to);
            });
        })->get();

Cinek left a reply on Appending Key->Value With An Existing JSON Data • 2 months ago

 {"at_quest": ["1.1"], "quest_1.1_score": "67", "quest_1.1_passed" : "2018-03-20 09:48:47.886849","at_quest": ["1.2"], "quest_1.2_score": "67", "quest_1.2_passed" : "2018-03-20 09:48:47.886849"}

It's not valid JSON. You have 2 same property names.

Cinek left a reply on Problem With Sending HTTP Request Using Controller • 2 months ago

According to docs: https://github.com/guzzle/guzzle/blob/master/UPGRADING.md

GuzzleHttp\ClientInterface::setDefaultOption has been removed.

Try use this:

$client = new Client(['verify' => false, 'auth' => ['user', 'pass']]);

20th March, 2018

Cinek left a reply on Mark All Fields From A Query • 2 months ago

PrivateMessage::where('recipient_id', '=', $request->authedUser->id)->update(['read'=>1]);

Cinek left a reply on Filter And Count A Many-to-Many Relations Using Eloquent Model • 2 months ago

Try this:

public function isAdmin(){
    return $this->groups()->where('id',1)->count();
}
Edit Your Profile
Update

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